Support gem execution with rbenv ruby.

This commit is contained in:
Martin Kretz 2013-10-18 12:39:32 +02:00
parent 055054e6e3
commit 8cb168f612
2 changed files with 27 additions and 0 deletions

View File

@ -16,6 +16,9 @@ def _gem(command, ruby=None, runas=None):
if __salt__['rvm.is_installed']():
return __salt__['rvm.do'](ruby, cmdline, runas=runas)
if __salt__['rbenv.is_installed'](runas=runas):
return __salt__['rbenv.do'](cmdline, runas=runas)
ret = __salt__['cmd.run_all'](
cmdline,
runas=runas

View File

@ -257,3 +257,27 @@ def list_(runas=None):
continue
ret.append(line.strip())
return ret
def do(cmdline=None, runas=None):
'''
Execute a ruby command with rbenv's shims from the user or the system.
CLI Example:
.. code-block:: bash
salt '*' rbenv.do "gem list bundler"
salt '*' rbenv.do "gem list bundler" deploy
'''
path = _rbenv_path(runas)
result = __salt__['cmd.run_all'](
"env PATH={0}/shims:$PATH {1}".format(path, cmdline),
runas=runas
)
if result['retcode'] == 0:
return result['stdout']
else:
return False