Class: Cadre::Config
- Inherits:
-
Object
- Object
- Cadre::Config
- Defined in:
- lib/cadre/config.rb
Instance Attribute Summary collapse
-
#component ⇒ Object
readonly
Returns the value of attribute component.
-
#valise ⇒ Object
readonly
Returns the value of attribute valise.
Instance Method Summary collapse
- #backtrace_limit ⇒ Object
- #backtrace_pattern ⇒ Object
- #config_hash ⇒ Object
- #include_pending ⇒ Object (also: #include_pending?)
-
#initialize(valise, component) ⇒ Config
constructor
A new instance of Config.
- #output_path ⇒ Object
- #quiet ⇒ Object (also: #quiet?)
- #value_or_fail(value, common = true) ⇒ Object
- #verbose ⇒ Object (also: #verbose?)
Constructor Details
#initialize(valise, component) ⇒ Config
Returns a new instance of Config.
3 4 5 6 |
# File 'lib/cadre/config.rb', line 3 def initialize(valise, component) @valise = valise @component = component end |
Instance Attribute Details
#component ⇒ Object (readonly)
Returns the value of attribute component.
7 8 9 |
# File 'lib/cadre/config.rb', line 7 def component @component end |
#valise ⇒ Object (readonly)
Returns the value of attribute valise.
7 8 9 |
# File 'lib/cadre/config.rb', line 7 def valise @valise end |
Instance Method Details
#backtrace_limit ⇒ Object
41 42 43 |
# File 'lib/cadre/config.rb', line 41 def backtrace_limit value_or_fail('backtrace_limit') end |
#backtrace_pattern ⇒ Object
37 38 39 |
# File 'lib/cadre/config.rb', line 37 def backtrace_pattern Regexp.new(value_or_fail('backtrace_pattern')) end |
#config_hash ⇒ Object
9 10 11 |
# File 'lib/cadre/config.rb', line 9 def config_hash valise.find("config.yaml").contents end |
#include_pending ⇒ Object Also known as: include_pending?
45 46 47 |
# File 'lib/cadre/config.rb', line 45 def include_pending !!value_or_fail('include_pending') end |
#output_path ⇒ Object
23 24 25 |
# File 'lib/cadre/config.rb', line 23 def output_path value_or_fail("output_path", false) end |
#quiet ⇒ Object Also known as: quiet?
32 33 34 |
# File 'lib/cadre/config.rb', line 32 def quiet !verbose end |
#value_or_fail(value, common = true) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/cadre/config.rb', line 13 def value_or_fail(value, common=true) if common config_hash.fetch(component, {}).fetch(value){config_hash.fetch(value)} else config_hash.fetch(component).fetch(value) end rescue KeyError raise "Field not configurated: #{value}" #yep: configurated end |
#verbose ⇒ Object Also known as: verbose?
27 28 29 |
# File 'lib/cadre/config.rb', line 27 def verbose !!value_or_fail("verbose") end |