Class: Veewee::Config
- Inherits:
-
Object
- Object
- 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
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
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/veewee/config.rb', line 20 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
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 58 |
# File 'lib/veewee/config.rb', line 32 def load_veewee_config() veewee_configurator = self begin filename = File.join(Dir.pwd, "Veeweefile") if File.exists?(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 |