Class: Jack::EbConfig::Base
- Inherits:
-
Object
- Object
- Jack::EbConfig::Base
- Includes:
- Util
- Defined in:
- lib/jack/eb_config/base.rb
Overview
Abstract Class Concrete classes should implement methods: platform and app_name
Instance Attribute Summary collapse
-
#eb_config_path ⇒ Object
readonly
Returns the value of attribute eb_config_path.
Instance Method Summary collapse
- #ensure_eb_init ⇒ Object
-
#initialize(options = {}) ⇒ Base
constructor
A new instance of Base.
- #sync ⇒ Object
- #write_eb_config_yml ⇒ Object
Methods included from Util
#app_name_convention, #aws_bin, #check_aws_setup, #confirm, #eb, #eb_base_flags, #eb_bin, #ensure_folder_exist, #get_answer, #get_region, #prerequisites, #settings, #sh
Constructor Details
#initialize(options = {}) ⇒ Base
Returns a new instance of Base.
9 10 11 12 13 14 15 |
# File 'lib/jack/eb_config/base.rb', line 9 def initialize(={}) @options = @root = [:root] || '.' @env_name = [:env_name] @eb_config_path = "#{@root}/.elasticbeanstalk/config.yml" ensure_folder_exist(File.dirname(@eb_config_path)) end |
Instance Attribute Details
#eb_config_path ⇒ Object (readonly)
Returns the value of attribute eb_config_path.
8 9 10 |
# File 'lib/jack/eb_config/base.rb', line 8 def eb_config_path @eb_config_path end |
Instance Method Details
#ensure_eb_init ⇒ Object
22 23 24 25 26 |
# File 'lib/jack/eb_config/base.rb', line 22 def ensure_eb_init unless File.exist?(eb_config_path) sh(%Q|#{eb_bin} init#{eb_base_flags} -p "#{platform}" "#{app_name}"|, @options) end end |
#sync ⇒ Object
17 18 19 20 |
# File 'lib/jack/eb_config/base.rb', line 17 def sync ensure_eb_init write_eb_config_yml end |
#write_eb_config_yml ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/jack/eb_config/base.rb', line 28 def write_eb_config_yml data = YAML.load_file(eb_config_path) data['global']['application_name'] = app_name # from subclass data['global']['default_platform'] = platform # from subclass dump = YAML.dump(data).gsub("!ruby/object:Hash", '') dump = dump.split("\n")[1..-1].join("\n") # strip first line File.write(eb_config_path, dump) end |