Class: Mineshaft::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/mineshaft/environment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir, options) ⇒ Environment

Returns a new instance of Environment.



17
18
19
20
21
# File 'lib/mineshaft/environment.rb', line 17

def initialize(dir, options)
  @dir = options[:global] ? File.join(Dir.home, ".mineshaft", dir) : dir
  @options = options
  @version = @options[:version] ? @options[:version] : Mineshaft::Constants::RUBY_VERSION_STABLE
end

Instance Attribute Details

#dirObject (readonly)

Returns the value of attribute dir.



15
16
17
# File 'lib/mineshaft/environment.rb', line 15

def dir
  @dir
end

Instance Method Details

#createObject



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/mineshaft/environment.rb', line 23

def create
  FileUtils::mkdir_p(@dir)
  install_ruby
  if @options[:global]
    set_new_global
    `gem install mineshaft`
    Mineshaft.reload
  else
    create_activate_script
  end
end

#useObject



35
36
37
38
# File 'lib/mineshaft/environment.rb', line 35

def use
  set_new_global
  puts "Now using the environment at: #@dir" 
end