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



181
182
183
# File 'lib/console-launcher.rb', line 181

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

#load_optionsObject



166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/console-launcher.rb', line 166

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



186
187
188
189
# File 'lib/console-launcher.rb', line 186

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