Class: Jack::Config::Get
- Includes:
- Util
- Defined in:
- lib/jack/config/get.rb
Instance Attribute Summary collapse
-
#current_name ⇒ Object
readonly
Returns the value of attribute current_name.
-
#current_path ⇒ Object
readonly
Returns the value of attribute current_path.
Attributes inherited from Transmit
Instance Method Summary collapse
- #add_gitignore ⇒ Object
-
#clean(mute = false) ⇒ Object
remove both the local download file and remote eb config.
- #copy_to_local_cfg ⇒ Object
-
#do_copy_to_local_cfg ⇒ Object
for specs.
- #download ⇒ Object
-
#eb_config_save ⇒ Object
for specs.
- #get_current_cfg ⇒ Object
-
#initialize(options = {}) ⇒ Get
constructor
A new instance of Get.
- #run ⇒ 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
Methods inherited from Transmit
Constructor Details
#initialize(options = {}) ⇒ Get
Returns a new instance of Get.
11 12 13 14 15 16 17 |
# File 'lib/jack/config/get.rb', line 11 def initialize(={}) super @current_path = "#{@saved_configs}/current-#{}.cfg.yml" @current_name = extract_name(@current_path) @updater = EbConfig::Update.new(env_name: @env_name) @updater.sync unless [:noop] end |
Instance Attribute Details
#current_name ⇒ Object (readonly)
Returns the value of attribute current_name.
9 10 11 |
# File 'lib/jack/config/get.rb', line 9 def current_name @current_name end |
#current_path ⇒ Object (readonly)
Returns the value of attribute current_path.
9 10 11 |
# File 'lib/jack/config/get.rb', line 9 def current_path @current_path end |
Instance Method Details
#add_gitignore ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/jack/config/get.rb', line 31 def add_gitignore path = "#{@root}/.gitignore" if File.exist?(path) ignores = IO.read(path) has_ignore = ignores.include?("jack/cfg") end sh("echo 'jack/cfg/*.yml' >> #{path}") unless has_ignore end |
#clean(mute = false) ⇒ Object
remove both the local download file and remote eb config
66 67 68 69 70 71 72 73 74 |
# File 'lib/jack/config/get.rb', line 66 def clean(mute=false) return if @options[:dirty] UI.say "Cleaning up eb remote config and local files" unless mute eb.delete_configuration_template( application_name: @updater.app_name, template_name: current_name ) unless @options[:noop] FileUtils.rm_f(@current_path) end |
#copy_to_local_cfg ⇒ Object
50 51 52 53 54 55 |
# File 'lib/jack/config/get.rb', line 50 def copy_to_local_cfg UI.say "Writing to local config file: #{@local_config_path}" dirname = File.dirname("#{@root}/#{@local_config_path}") FileUtils.mkdir_p(dirname) unless File.exist?(dirname) do_copy_to_local_cfg end |
#do_copy_to_local_cfg ⇒ Object
for specs
58 59 60 61 62 63 |
# File 'lib/jack/config/get.rb', line 58 def do_copy_to_local_cfg return if @options[:noop] local_path = "#{@root}/#{@local_config_path}" FileUtils.cp(@current_path, local_path) YamlFormatter.new.process(local_path) end |
#download ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/jack/config/get.rb', line 23 def download # add_gitignore get_current_cfg copy_to_local_cfg clean UI.say "Config downloaded to #{@local_config_path}".colorize(:green) end |
#eb_config_save ⇒ Object
for specs
46 47 48 |
# File 'lib/jack/config/get.rb', line 46 def eb_config_save sh("#{eb_bin} config save#{eb_base_flags} --cfg #{current_name} #{@env_name}", @options) end |
#get_current_cfg ⇒ Object
40 41 42 43 |
# File 'lib/jack/config/get.rb', line 40 def get_current_cfg UI.say "Downloading config file..." eb_config_save end |
#run ⇒ Object
19 20 21 |
# File 'lib/jack/config/get.rb', line 19 def run download end |