lang/ruby: rewrite rbenv support; add rvm support

This commit is contained in:
Henrik Lissner 2018-07-31 14:22:38 +02:00
parent 560d16d651
commit 3948255445
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
3 changed files with 46 additions and 33 deletions

View file

@ -13,3 +13,20 @@ buffers open."
(when (processp process)
(kill-process (get-buffer-process inf-buffer))
(kill-buffer inf-buffer)))))))
;;;###autoload
(defun +ruby-version ()
"Return the currently installed version of ruby on your system (the first
ruby executable found in your PATH).
This is not necessarily aware of env management tools like virtualenv, pyenv or
pipenv, unless those tools have modified the PATH that Emacs picked up when you
started it."
(unless (executable-find "ruby")
(user-error "Couldn't find ruby executable in PATH"))
(with-temp-buffer
(let ((p (call-process "ruby" nil (current-buffer) nil "--version"))
(output (string-trim (buffer-string))))
(unless (zerop p)
(user-error "ruby --version failed: %s" output))
(nth 1 (split-string output " " t)))))