Class: AppStack::Configuration
- Inherits:
-
Object
- Object
- AppStack::Configuration
- Defined in:
- lib/app_stack/configuration.rb
Overview
configuration from yaml file
Instance Attribute Summary collapse
-
#attrs ⇒ Object
Returns the value of attribute attrs.
-
#exclude ⇒ Object
Returns the value of attribute exclude.
-
#export ⇒ Object
Returns the value of attribute export.
-
#import ⇒ Object
Returns the value of attribute import.
-
#render ⇒ Object
Returns the value of attribute render.
-
#render_local ⇒ Object
Returns the value of attribute render_local.
-
#stack_dir ⇒ Object
Returns the value of attribute stack_dir.
-
#sync ⇒ Object
Returns the value of attribute sync.
Instance Method Summary collapse
-
#default_config ⇒ Object
rubocop:enable LineLength.
-
#initialize(filename = nil) ⇒ Configuration
constructor
rubocop:disable LineLength.
Constructor Details
#initialize(filename = nil) ⇒ Configuration
rubocop:disable LineLength
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/app_stack/configuration.rb', line 12 def initialize(filename = nil) # use yaml file to set configuration config = default_config.dup YAML.load(File.open(filename, 'r:utf-8').read).each do |k, v| fail ParseError, "unkown option `#{k}` in #{filename}" unless default_config[k.to_sym] fail ParseError, "'#{k}' must be a #{default_config[k.to_sym].class.to_s}" unless v.is_a?(default_config[k.to_sym].class) config[k.to_sym] = v end if filename config.each { |k, v| send("#{k}=", v) } end |
Instance Attribute Details
#attrs ⇒ Object
Returns the value of attribute attrs.
8 9 10 |
# File 'lib/app_stack/configuration.rb', line 8 def attrs @attrs end |
#exclude ⇒ Object
Returns the value of attribute exclude.
8 9 10 |
# File 'lib/app_stack/configuration.rb', line 8 def exclude @exclude end |
#export ⇒ Object
Returns the value of attribute export.
8 9 10 |
# File 'lib/app_stack/configuration.rb', line 8 def export @export end |
#import ⇒ Object
Returns the value of attribute import.
8 9 10 |
# File 'lib/app_stack/configuration.rb', line 8 def import @import end |
#render ⇒ Object
Returns the value of attribute render.
8 9 10 |
# File 'lib/app_stack/configuration.rb', line 8 def render @render end |
#render_local ⇒ Object
Returns the value of attribute render_local.
8 9 10 |
# File 'lib/app_stack/configuration.rb', line 8 def render_local @render_local end |
#stack_dir ⇒ Object
Returns the value of attribute stack_dir.
8 9 10 |
# File 'lib/app_stack/configuration.rb', line 8 def stack_dir @stack_dir end |
#sync ⇒ Object
Returns the value of attribute sync.
8 9 10 |
# File 'lib/app_stack/configuration.rb', line 8 def sync @sync end |
Instance Method Details
#default_config ⇒ Object
rubocop:enable LineLength
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/app_stack/configuration.rb', line 25 def default_config { import: [], sync: [], render: [], render_local: {}, export: [], exclude: [], attrs: {}, stack_dir: '..' } end |