Class: Babushka::CurrentRuby

Inherits:
Object
  • Object
show all
Defined in:
lib/babushka/current_ruby.rb

Instance Method Summary collapse

Instance Method Details

#bin_dirObject



16
17
18
19
20
# File 'lib/babushka/current_ruby.rb', line 16

def bin_dir
  # The directory in which the binaries from gems are found. This is
  # sometimes different to where `gem` itself is running from.
  gem_env.val_for('EXECUTABLE DIRECTORY').p
end

#gem_dirObject



22
23
24
# File 'lib/babushka/current_ruby.rb', line 22

def gem_dir
  gem_env.val_for('INSTALLATION DIRECTORY') / 'gems'
end

#gem_versionObject



34
35
36
# File 'lib/babushka/current_ruby.rb', line 34

def gem_version
  gem_env.val_for('RUBYGEMS VERSION').to_version
end

#gemspec_dirObject



26
27
28
# File 'lib/babushka/current_ruby.rb', line 26

def gemspec_dir
  gem_env.val_for('INSTALLATION DIRECTORY') / 'specifications'
end

#pathObject



4
5
6
# File 'lib/babushka/current_ruby.rb', line 4

def path
  @path ||= Babushka::ShellHelpers.which('ruby').p
end

#rbenv?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/babushka/current_ruby.rb', line 8

def rbenv?
  path.to_s[%r{\brbenv/}]
end

#rvm?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/babushka/current_ruby.rb', line 12

def rvm?
  path.to_s[%r{\brvm/}]
end

#versionObject



30
31
32
# File 'lib/babushka/current_ruby.rb', line 30

def version
  @_version ||= Babushka::ShellHelpers.shell('ruby --version').scan(/^ruby (\S+)/).flatten.first.to_version
end