lib/veewee/environment.rb in veewee-0.3.6 vs lib/veewee/environment.rb in veewee-0.3.7
- old
+ new
@@ -49,29 +49,29 @@
attr_accessor :providers
# Hash elelement of all OStypes
attr_reader :ostypes
- def initialize(options={})
+ def initialize(options = {})
cwd = ENV['VEEWEE_DIR'] || Dir.pwd
# If a cwd was provided as option it overrules the default
cwd = options[:cwd] if options.has_key?(:cwd)
- defaults={
+ defaults = {
:cwd => cwd,
:veewee_filename => "Veeweefile",
:loglevel => :info,
- :definition_dir => File.join(cwd,"definitions"),
- :template_path => [File.expand_path(File.join(File.dirname(__FILE__),"..","..",'templates')),"templates"],
- :iso_dir => File.join(cwd,"iso"),
- :validation_dir => File.join(File.expand_path(File.join(File.dirname(__FILE__),"..","..")),"validation"),
- :tmp_dir => File.join(cwd,"tmp")
+ :definition_dir => File.join(cwd, "definitions"),
+ :template_path => [File.expand_path(File.join(File.dirname(__FILE__), "..", "..", 'templates')), "templates"],
+ :iso_dir => File.join(cwd, "iso"),
+ :validation_dir => File.join(File.expand_path(File.join(File.dirname(__FILE__), "..", "..")), "validation"),
+ :tmp_dir => File.join(cwd, "tmp")
}
options = defaults.merge(options)
- veeweefile_config = defaults.keys.inject({}) do |memo,obj|
+ veeweefile_config = defaults.keys.inject({}) do |memo, obj|
if config.env.methods.include?(obj) && !config.env.send(obj).nil?
memo.merge({ obj => config.env.send(obj) })
else
memo
end
@@ -79,11 +79,11 @@
options = options.merge(veeweefile_config)
# We need to set this variable before the first call to the logger object
if options.has_key?("debug")
if options["debug"] == true
- ENV['VEEWEE_LOG']="STDOUT"
+ ENV['VEEWEE_LOG'] = "STDOUT"
end
end
logger.info("environment") { "Environment initialized (#{self})" }
@@ -92,18 +92,18 @@
instance_variable_set("@#{key}".to_sym, options[key])
logger.info("environment") { " - #{key} : #{options[key]}" }
end
# Definitions
- @definitions=Veewee::Definitions.new(self)
- @templates=Veewee::Templates.new(self)
- @providers=Veewee::Providers.new(self)
+ @definitions = Veewee::Definitions.new(self)
+ @templates = Veewee::Templates.new(self)
+ @providers = Veewee::Providers.new(self, options)
# Read ostypes
- yamlfile=File.join(File.dirname(__FILE__),"config","ostypes.yml")
+ yamlfile = File.join(File.dirname(__FILE__), "config", "ostypes.yml")
logger.info "Reading ostype yamlfile #{yamlfile}"
- @ostypes=YAML.load_file(yamlfile)
+ @ostypes = YAML.load_file(yamlfile)
return self
end
#---------------------------------------------------------------
@@ -123,11 +123,11 @@
# Returns the {UI} for the environment, which is responsible
# for talking with the outside world.
#
# @return [UI]
def ui
- @ui ||= UI.new(self)
+ @ui ||= UI.new(self)
end
#---------------------------------------------------------------
# Load Methods
#---------------------------------------------------------------
@@ -153,10 +153,10 @@
self
end
end
def load_config!
- @config=Config.new({:env => self}).load_veewee_config()
+ @config = Config.new({ :env => self }).load_veewee_config()
return self
end
# Reloads the configuration of this environment.