Class: Veewee::Config
- Defined in:
- lib/veewee/config.rb,
lib/veewee/config/veewee.rb,
lib/veewee/config/component.rb,
lib/veewee/config/collection.rb,
lib/veewee/config/definition.rb
Defined Under Namespace
Classes: Collection, Component, Definition, Veewee
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#veewee ⇒ Object
Returns the value of attribute veewee.
Instance Method Summary collapse
- #define {|config| ... } ⇒ Object
-
#initialize(options) ⇒ Config
constructor
A new instance of Config.
-
#load_veewee_config ⇒ Object
We put a long name to not clash with any function in the Veewee file itself.
Constructor Details
#initialize(options) ⇒ Config
12 13 14 15 16 |
# File 'lib/veewee/config.rb', line 12 def initialize() @env = [:env] # Initialize with defaults @veewee = ::Veewee::Config::Veewee.new(self) end |
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
10 11 12 |
# File 'lib/veewee/config.rb', line 10 def env @env end |
#veewee ⇒ Object
Returns the value of attribute veewee.
9 10 11 |
# File 'lib/veewee/config.rb', line 9 def veewee @veewee end |
Instance Method Details
#define {|config| ... } ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/veewee/config.rb', line 18 def define() config = OpenStruct.new # Expose the veewee config config.veewee = @veewee # Process config file yield config end |
#load_veewee_config ⇒ Object
We put a long name to not clash with any function in the Veewee file itself
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/veewee/config.rb', line 30 def load_veewee_config() veewee_configurator = self begin filename = @env.config_filepath if File.exists?(filename) env.logger.info("Loading config file: #{filename}") veeweefile = File.read(filename) veeweefile["Veewee::Config.run"] = "veewee_configurator.define" # http://www.dan-manges.com/blog/ruby-dsls-instance-eval-with-delegation instance_eval(veeweefile) else env.logger.info "No configfile found" end rescue LoadError => e env.ui.error "An error occurred" env.ui.error e. rescue NoMethodError => e env.ui.error "Some method got an error in the configfile - Sorry" env.ui.error $! env.ui.error e. raise Veewee::Error "Some method got an error in the configfile - Sorry" rescue Error => e env.ui.error "Error processing configfile - Sorry" env.ui.error e. raise Veewee::Error "Error processing configfile - Sorry" end return self end |