Method: Annex::Environment#initialize
- Defined in:
- lib/annex/environment.rb
#initialize(opts = nil) ⇒ Environment
Initializes a new environment with the given options. The options is a hash where the main available key is cwd, which defines the location of the environment. If cwd is nil, then it defaults to the Dir.pwd (which is the cwd of the executing process).
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/annex/environment.rb', line 16 def initialize(opts=nil) opts = { :cwd => nil, :windows => false, :supports_colors => true, :no_colors => false }.merge(opts || {}) # Set the default working directory opts[:cwd] ||= ENV["ANNEX_CWD"] if ENV.has_key?("ANNEX_CWD") opts[:cwd] ||= Dir.pwd opts[:cwd] = Pathname.new(opts[:cwd]) raise Errors::AnnexError.new("Unknown current working directory") if !opts[:cwd].directory? # Set instance variables for all the configuration parameters. @cwd = opts[:cwd] @colorize = opts[:supports_colors] || !opts[:no_colors] end |