Class: Mineshaft::Environment
- Inherits:
-
Object
- Object
- Mineshaft::Environment
- Defined in:
- lib/mineshaft/environment.rb
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
Instance Method Summary collapse
- #create ⇒ Object
-
#initialize(dir, options) ⇒ Environment
constructor
A new instance of Environment.
- #use ⇒ Object
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, ) @dir = [:global] ? File.join(Dir.home, ".mineshaft", dir) : dir = @version = [:version] ? [:version] : Mineshaft::Constants::RUBY_VERSION_STABLE end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
15 16 17 |
# File 'lib/mineshaft/environment.rb', line 15 def dir @dir end |
Instance Method Details
#create ⇒ Object
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 [:global] set_new_global `gem install mineshaft` Mineshaft.reload else create_activate_script end end |
#use ⇒ Object
35 36 37 38 |
# File 'lib/mineshaft/environment.rb', line 35 def use set_new_global puts "Now using the environment at: #@dir" end |