Class: Babushka::CurrentRuby
Overview
This class provides information about the active ruby installation according to the system's $PATH. This might be different to the ruby via which babushka was invoked.
The preferred way to use this class is via `Babushka.ruby`.
Instance Method Summary collapse
-
#bin_dir ⇒ Object
The directory in which gem binaries are found.
-
#gem_dir ⇒ Object
The path to the current ruby's installed set of gems.
-
#gem_version ⇒ Object
The version of the `gem` in the path.
-
#gemspec_dir ⇒ Object
The path to the gemspecs for the current ruby's installed set of gems.
-
#path ⇒ Object
The path the ruby binary that is visible via the $PATH.
-
#rbenv? ⇒ Boolean
True if the current ruby is managed by rbenv.
-
#rvm? ⇒ Boolean
True if the current ruby is managed by rvm.
-
#version ⇒ Object
The version of the ruby in the path.
Instance Method Details
#bin_dir ⇒ Object
The directory in which gem binaries are found. This is sometimes different to the path that `gem` itself runs from.
27 28 29 |
# File 'lib/babushka/current_ruby.rb', line 27 def bin_dir gem_env.val_for('EXECUTABLE DIRECTORY').p end |
#gem_dir ⇒ Object
The path to the current ruby's installed set of gems.
32 33 34 |
# File 'lib/babushka/current_ruby.rb', line 32 def gem_dir gem_env.val_for('INSTALLATION DIRECTORY') / 'gems' end |
#gem_version ⇒ Object
The version of the `gem` in the path.
47 48 49 |
# File 'lib/babushka/current_ruby.rb', line 47 def gem_version gem_env.val_for('RUBYGEMS VERSION').to_version end |
#gemspec_dir ⇒ Object
The path to the gemspecs for the current ruby's installed set of gems.
37 38 39 |
# File 'lib/babushka/current_ruby.rb', line 37 def gemspec_dir gem_env.val_for('INSTALLATION DIRECTORY') / 'specifications' end |
#path ⇒ Object
The path the ruby binary that is visible via the $PATH.
11 12 13 |
# File 'lib/babushka/current_ruby.rb', line 11 def path @path ||= Babushka::ShellHelpers.which('ruby').p end |
#rbenv? ⇒ Boolean
True if the current ruby is managed by rbenv.
16 17 18 |
# File 'lib/babushka/current_ruby.rb', line 16 def rbenv? path.to_s[%r{\brbenv/}] end |
#rvm? ⇒ Boolean
True if the current ruby is managed by rvm.
21 22 23 |
# File 'lib/babushka/current_ruby.rb', line 21 def rvm? path.to_s[%r{\brvm/}] end |
#version ⇒ Object
The version of the ruby in the path.
42 43 44 |
# File 'lib/babushka/current_ruby.rb', line 42 def version @_version ||= Babushka::ShellHelpers.shell('ruby --version').scan(/^ruby (\S+)/).flatten.first.to_version end |