Module: Helper

Defined in:
lib/console-launcher.rb

Constant Summary collapse

CONFIG_FILE =
File.join(ENV['HOME'], '.console-launcher.rc.yaml')
OPTIONS =
{
    :print => false,
    :dryrun => false,
    :host => nil,
    :user => "admin@internal",
    :pass => nil
}

Instance Method Summary collapse

Instance Method Details

#get_password(prompt = "RHEV-M Password: ") ⇒ Object

queries the User for a password



190
191
192
# File 'lib/console-launcher.rb', line 190

def get_password(prompt="RHEV-M Password: ")
  ask(prompt) { |q| q.echo = "*" }
end

#load_optionsObject



175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/console-launcher.rb', line 175

def load_options
  if File.exists? CONFIG_FILE
    config_options = YAML.load_file(CONFIG_FILE)
    OPTIONS.merge!(config_options)

    unless config_options.has_key?(:viewer)
      File.open(CONFIG_FILE, 'w') { |file| YAML::dump(OPTIONS, file) }
    end
  else
    File.open(CONFIG_FILE, 'w') { |file| YAML::dump(OPTIONS, file) }
    STDERR.puts "Initialized configuration file in #{CONFIG_FILE}"
  end
end

#strip_url(url) ⇒ Object

Remove any leading http or https from the host



195
196
197
198
# File 'lib/console-launcher.rb', line 195

def strip_url(url)
  url = url.split("://")[1] if url.include? "://"
  return url
end