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

Instance Method Details

#find_option_setting(name) ⇒ Object



84
85
86
87
88
89
90
91
92
93
94
# File 'lib/elastic/beanstalk/config.rb', line 84

def find_option_setting(name)
  name = name.to_sym
  options.each_key do |namespace|
    options[namespace].each do |option_name, value|
      if option_name.eql? name
        return to_option_setting(namespace, option_name, value)
      end
    end
  end
  return nil
end

#find_option_setting_value(name) ⇒ Object



96
97
98
99
# File 'lib/elastic/beanstalk/config.rb', line 96

def find_option_setting_value(name)
  o = find_option_setting(name)
  o[:value] unless o.nil?
end

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



39
40
41
# File 'lib/elastic/beanstalk/config.rb', line 39

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



60
61
62
63
64
65
66
67
68
69
70
# File 'lib/elastic/beanstalk/config.rb', line 60

def option_settings
  result = []
  options.each_key do |namespace|
    options[namespace].each do |option_name, value|
      result << to_option_setting(namespace, option_name, value)
    end
  end

  #{"option_settings" => result}
  result
end

#resolve_path(relative_path) ⇒ Object



44
45
46
47
48
49
50
51
52
# File 'lib/elastic/beanstalk/config.rb', line 44

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

#seed_default_configurationObject

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
# File 'lib/elastic/beanstalk/config.rb', line 21

def seed_default_configuration
  # seed the sensible defaults here
  @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: {}
  }
end

#set_option(namespace, option_name, value) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/elastic/beanstalk/config.rb', line 72

def set_option(namespace, option_name, value)
  namespace = namespace.to_sym

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

  #puts '888888hello'
end

#to_option_setting(namespace, option_name, value) ⇒ Object



101
102
103
104
105
106
107
# File 'lib/elastic/beanstalk/config.rb', line 101

def to_option_setting(namespace, option_name, value)
  {
      :'namespace' => "#{namespace}",
      :'option_name' => "#{option_name}",
      :'value' => "#{value}"
  }
end