class Jack::Config::Get

Attributes

current_name[R]
current_path[R]

Public Class Methods

new(options={}) click to toggle source
Calls superclass method
# File lib/jack/config/get.rb, line 11
def initialize(options={})
  super
  @current_path = "#{@saved_configs}/current-#{timestamp}.cfg.yml"
  @current_name = extract_name(@current_path)
  @updater = EbConfig::Update.new(env_name: @env_name)
  @updater.sync unless options[:noop]
end

Public Instance Methods

add_gitignore() click to toggle source
# 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) click to toggle source

remove both the local download file and remote eb config

# 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() click to toggle source
# 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() click to toggle source

for specs

# 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() click to toggle source
# 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() click to toggle source

for specs

# 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() click to toggle source
# File lib/jack/config/get.rb, line 40
def get_current_cfg
  UI.say "Downloading config file..."
  eb_config_save
end
run() click to toggle source
# File lib/jack/config/get.rb, line 19
def run
  download
end