Class: Rebi::Config
Instance Attribute Summary collapse
Instance Method Summary collapse
- #app_description ⇒ Object
- #app_name ⇒ Object
- #config_file ⇒ Object
- #config_file=(path) ⇒ Object
- #env_by_name(name) ⇒ Object
- #environment(stg_name, env_name) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #reload! ⇒ Object
- #stage(stage) ⇒ Object
- #stages ⇒ Object
- #timeout ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
5 6 7 |
# File 'lib/rebi/config.rb', line 5 def initialize reload! end |
Instance Attribute Details
#aws_key ⇒ Object
22 23 24 |
# File 'lib/rebi/config.rb', line 22 def aws_key data[:aws_key] || ENV["AWS_ACCESS_KEY_ID"] end |
#aws_profile ⇒ Object
18 19 20 |
# File 'lib/rebi/config.rb', line 18 def aws_profile @aws_profile || data[:profile] || ENV["AWS_PROFILE"] end |
#aws_secret ⇒ Object
26 27 28 |
# File 'lib/rebi/config.rb', line 26 def aws_secret data[:aws_secret] || ENV["AWS_SECRET_ACCESS_KEY"] end |
#region ⇒ Object
30 31 32 |
# File 'lib/rebi/config.rb', line 30 def region data[:region] end |
Instance Method Details
#app_description ⇒ Object
44 45 46 |
# File 'lib/rebi/config.rb', line 44 def app_description data[:app_description] || "Created via rebi" end |
#app_name ⇒ Object
40 41 42 |
# File 'lib/rebi/config.rb', line 40 def app_name data[:app_name] end |
#config_file ⇒ Object
9 10 11 |
# File 'lib/rebi/config.rb', line 9 def config_file @config_file ||= "#{Rebi.root}/.rebi.yml" end |
#config_file=(path) ⇒ Object
13 14 15 |
# File 'lib/rebi/config.rb', line 13 def config_file=path @config_file = Pathname.new(path).realpath.to_s end |
#env_by_name(name) ⇒ Object
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/rebi/config.rb', line 62 def env_by_name name data[:stages].each do |stg_name, stg_conf| stg = stage stg_name stg_conf.keys.each do |env_name| env_conf = Rebi::ConfigEnvironment.new(stg_name, env_name, stg[env_name] || {}) return env_conf if env_conf.name == name end end return nil end |
#environment(stg_name, env_name) ⇒ Object
56 57 58 59 60 |
# File 'lib/rebi/config.rb', line 56 def environment stg_name, env_name stg = stage stg_name raise(Rebi::Error::ConfigNotFound.new("Environment config: #{env_name}")) unless stg.key?(env_name) return Rebi::ConfigEnvironment.new(stg_name, env_name, stg[env_name] || {}) end |
#reload! ⇒ Object
34 35 36 37 38 |
# File 'lib/rebi/config.rb', line 34 def reload! @data = nil set_aws_config return data end |
#stage(stage) ⇒ Object
48 49 50 |
# File 'lib/rebi/config.rb', line 48 def stage stage data[:stages][stage] || raise(Rebi::Error::ConfigNotFound.new("Stage: #{stage}")) end |
#stages ⇒ Object
73 74 75 |
# File 'lib/rebi/config.rb', line 73 def stages data[:stages].keys end |
#timeout ⇒ Object
52 53 54 |
# File 'lib/rebi/config.rb', line 52 def timeout (data[:timeout] || 60*10).second end |