class Rockette::Configurator

Configure Rockette application

Attributes

config[R]

Public Class Methods

config() click to toggle source
# File lib/rockette/controller/configurator.rb, line 21
def self.config
  @config ||= self.class.new.config
end
new() click to toggle source
# File lib/rockette/controller/configurator.rb, line 12
def initialize
  @config = TTY::Config.new
  @config.append_path APP_PATH
  @config.read

  @pastel = Pastel.new
  @prompt = TTY::Prompt.new
end

Public Instance Methods

add_url() click to toggle source
# File lib/rockette/controller/configurator.rb, line 50
def add_url
  uri = @prompt.ask("Please enter APEX deployment URI (base path):") do |u|
    u.validate(%r{^https://\w+.\w+})
  end
  @config.set(:rockette, :controller_url, value: uri)
  @config.write(force: true)
  refresh_conf
end
do_action(action) click to toggle source
# File lib/rockette/controller/configurator.rb, line 39
def do_action(action)
  case action
  when "editor"
    edit_config
  when "url"
    add_url
  else
    puts "\nI don't understand that command.\n\n"
  end
end
edit_config() click to toggle source
# File lib/rockette/controller/configurator.rb, line 59
def edit_config
  edit = TTY::Editor.open(CONF)
  puts "There seems to have been an issue trying to open the file: #{CONF}" unless edit
  refresh_conf if edit
end
first_run() click to toggle source
# File lib/rockette/controller/configurator.rb, line 65
def first_run
  puts
  puts "I see this is your first time running Rockette. Entering an APEX deployment"
  puts "uri will allow me to discover more about your environments."
  puts
  response = @prompt.yes?("Would you like to enter a URI?")
  if response == true
    add_url
  else
    response = @prompt.yes?("Would you like to disable these checks in the future?")
    @config.set(:rockette, :check_for_url, value: false) if response == true
  end
  @config.write(force: true) if response == true
  refresh_conf
end
launch!() click to toggle source
# File lib/rockette/controller/configurator.rb, line 25
def launch!
  puts
  puts @pastel.yellow("Configure Rockette here. Choosing 'editor' will let you edit the config file directly.")
  puts @pastel.yellow("Choose 'url' to enter a controller url, the api endpoint with your environments, etc.")
  puts
  # input/action loop
  loop do
    action = @prompt.select("What will it be?", %w[editor url back])
    break if action == "back"

    do_action(action)
  end
end
refresh_conf() click to toggle source
# File lib/rockette/controller/configurator.rb, line 81
def refresh_conf
  @config.read
end