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.



16
17
18
19
20
21
22
23
24
25
# File 'lib/mineshaft/environment.rb', line 16

def initialize(dir, options)
  if options[:global]
    @dir = File.join(Dir.home, ".mineshaft", dir)
  else
    @dir = dir
  end
  @options = options
  @versions = YAML.load_file(File.join(File.dirname(File.expand_path(__FILE__)), '../../versions/versions.yaml'))
  @version = @options[:version] ? @options[:version] : Mineshaft::Constants::RUBY_VERSION_STABLE
end

Instance Attribute Details

#dirObject (readonly)

Returns the value of attribute dir.



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

def dir
  @dir
end

Instance Method Details

#createObject



27
28
29
30
31
32
33
34
35
# File 'lib/mineshaft/environment.rb', line 27

def create
  FileUtils::mkdir_p(@dir)
  install_ruby
  if @options[:global]
    set_new_global @dir
  else
    create_template
  end
end

#useObject



37
38
39
40
# File 'lib/mineshaft/environment.rb', line 37

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