Class: Elastic::Beanstalk::Config

Inherits:
Dry::Config::Base
  • Object
show all
Includes:
Singleton
Defined in:
lib/elastic/beanstalk/config.rb

Overview

If this behavior of merging arrays or the defaults are somehow un-sensible, file an issue and we’ll revisit it.

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Config

it’s a singleton, thus implemented as a self-extended module extend self



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/elastic/beanstalk/config.rb', line 21

def initialize(options = {})
  # seed the sensible defaults here
  options = {
      symbolize: true,
      interpolation: false,
      default_configuration: {
          environment: nil,
          secrets_dir: '~/.aws',
          disallow_environments: %w(cucumber test),
          strategy: :blue_green,
          package: {
              dir: 'pkg',
              verbose: false,
              includes: %w(**/* .ebextensions/**/*),
              exclude_files: [],
              exclude_dirs: %w(pkg tmp log test-reports)
          },
          options: {},
          inactive: {}
      }
  }.merge(options)
  super(options)
end

Instance Method Details

#find_inactive_setting(name) ⇒ Object



87
88
89
# File 'lib/elastic/beanstalk/config.rb', line 87

def find_inactive_setting(name)
  find_setting(name, inactive)
end

#find_inactive_setting_value(name) ⇒ Object



91
92
93
# File 'lib/elastic/beanstalk/config.rb', line 91

def find_inactive_setting_value(name)
  find_setting_value(name, inactive)
end

#find_option_setting(name) ⇒ Object



79
80
81
# File 'lib/elastic/beanstalk/config.rb', line 79

def find_option_setting(name)
  find_setting(name, options)
end

#find_option_setting_value(name) ⇒ Object



83
84
85
# File 'lib/elastic/beanstalk/config.rb', line 83

def find_option_setting_value(name)
  find_setting_value(name, options)
end

#inactive_settingsObject



66
67
68
# File 'lib/elastic/beanstalk/config.rb', line 66

def inactive_settings
  generate_settings(inactive)
end

#load!(environment = nil, filename = resolve_path('config/eb.yml')) ⇒ Object



46
47
48
# File 'lib/elastic/beanstalk/config.rb', line 46

def load!(environment = nil, filename = resolve_path('config/eb.yml'))
  super(environment, filename)
end

#option_settingsObject

custom methods for the specifics of eb.yml settings



62
63
64
# File 'lib/elastic/beanstalk/config.rb', line 62

def option_settings
  generate_settings(options)
end

#resolve_path(relative_path) ⇒ Object



51
52
53
54
55
56
57
58
59
# File 'lib/elastic/beanstalk/config.rb', line 51

def resolve_path(relative_path)
  if defined?(Rails)
    Rails.root.join(relative_path)
  elsif defined?(Rake.original_dir)
    File.expand_path(relative_path, Rake.original_dir)
  else
    File.expand_path(relative_path, Dir.pwd)
  end
end

#set_option(namespace, option_name, value) ⇒ Object



70
71
72
73
74
75
76
77
# File 'lib/elastic/beanstalk/config.rb', line 70

def set_option(namespace, option_name, value)
  current_options = to_option_setting(namespace, option_name, value)
  namespace = current_options[:namespace].to_sym
  option_name = current_options[:option_name].to_sym

  options[namespace] = {} if options[namespace].nil?
  options[namespace][option_name] = value
end

#to_option_setting(namespace, option_name, value) ⇒ Object



95
96
97
98
99
100
101
102
103
104
105
# File 'lib/elastic/beanstalk/config.rb', line 95

def to_option_setting(namespace, option_name, value)
  erb_value = "#{value}".scan(/<%=.*%>/).first
  unless erb_value.nil?
    value = ERB.new(erb_value).result
  end
  {
      :'namespace' => "#{namespace}",
      :'option_name' => "#{option_name}",
      :'value' => "#{value}"
  }
end