Class: Fox::Configuration
- Inherits:
-
Object
- Object
- Fox::Configuration
- Defined in:
- lib/fox/configuration.rb
Instance Attribute Summary collapse
-
#base_dir ⇒ Object
Returns the value of attribute base_dir.
-
#project_name ⇒ Object
Returns the value of attribute project_name.
Instance Method Summary collapse
- #base_configuration ⇒ Hash
-
#initialize(confguration_file = nil) ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize(confguration_file = nil) ⇒ Configuration
Returns a new instance of Configuration.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/fox/configuration.rb', line 20 def initialize confguration_file = nil configuration = if confguration_file base_configuration.merge(YAML.load_file(confguration_file)) else base_configuration end # @todo add a deep loop for inner key-value pair configuration.each do |key, value| # if Default configuration not contain property, then we should raise exception raise Exception.new("Unexpected #{key} for Fox configuration") unless base_configuration.include?(key) instance_variable_set(:"@#{key}", value) end end |
Instance Attribute Details
#base_dir ⇒ Object
Returns the value of attribute base_dir.
14 15 16 |
# File 'lib/fox/configuration.rb', line 14 def base_dir @base_dir end |
#project_name ⇒ Object
Returns the value of attribute project_name.
13 14 15 |
# File 'lib/fox/configuration.rb', line 13 def project_name @project_name end |
Instance Method Details
#base_configuration ⇒ Hash
38 39 40 41 42 43 |
# File 'lib/fox/configuration.rb', line 38 def base_configuration { "project_name" => "project-#{rand(100)}", "base_dir" => Dir.pwd } end |