class CarthageCacheRes::ConfiguratorWizard

Public Class Methods

new(ask_proc, password_proc) click to toggle source
# File lib/carthage_cache_res/configurator_wizard.rb, line 5
def initialize(ask_proc, password_proc)
  @ask_proc = ask_proc
  @password_proc = password_proc
end

Public Instance Methods

start() click to toggle source
# File lib/carthage_cache_res/configurator_wizard.rb, line 10
def start
  config = Configuration.new
  config.bucket_name = ask("What is the Amazon S3 bucket name?", ENV["CARTHAGE_CACHE_DEFAULT_BUCKET_NAME"])
  config.archive_base_path = ask("What base path do you want to use as archive's prefix? (default none)", nil)
  config.prune_on_publish = confirm("Do you want to prune unused framework when publishing?")
  config.aws_region = ask("What is the Amazon S3 region?")
  config.aws_access_key_id = password("What is the AWS access key?")
  config.aws_secret_access_key = password(" What is the AWS secret access key?")
  config.aws_session_token = ask("What is the AWS session token (optional)?", nil, "*") 
  config
end

Private Instance Methods

ask(message, default_value = nil, mask = nil) click to toggle source
# File lib/carthage_cache_res/configurator_wizard.rb, line 24
def ask(message, default_value = nil, mask = nil)
  message = "#{message} [#{default_value}]" if default_value
  if mask
    answer = @ask_proc.call(message) { |q| q.echo = mask } 
  else
    answer = @ask_proc.call(message)  
  end
  
  if answer.empty?
    default_value
  else
    answer
  end
end
confirm(message) click to toggle source
# File lib/carthage_cache_res/configurator_wizard.rb, line 39
def confirm(message)
  ask("#{message} [N/y]", 'N').downcase == 'y'
end
password(message) click to toggle source
# File lib/carthage_cache_res/configurator_wizard.rb, line 43
def password(message)
   @password_proc.call(message)
end