Class: AppStack::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/app_stack/configuration.rb

Overview

configuration from yaml file

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#attrsObject

Returns the value of attribute attrs.



8
9
10
# File 'lib/app_stack/configuration.rb', line 8

def attrs
  @attrs
end

#excludeObject

Returns the value of attribute exclude.



8
9
10
# File 'lib/app_stack/configuration.rb', line 8

def exclude
  @exclude
end

#exportObject

Returns the value of attribute export.



8
9
10
# File 'lib/app_stack/configuration.rb', line 8

def export
  @export
end

#importObject

Returns the value of attribute import.



8
9
10
# File 'lib/app_stack/configuration.rb', line 8

def import
  @import
end

#renderObject

Returns the value of attribute render.



8
9
10
# File 'lib/app_stack/configuration.rb', line 8

def render
  @render
end

#render_localObject

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_dirObject

Returns the value of attribute stack_dir.



8
9
10
# File 'lib/app_stack/configuration.rb', line 8

def stack_dir
  @stack_dir
end

#syncObject

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_configObject

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