Top Level Namespace

Includes:
RegApi2

Defined Under Namespace

Modules: RegApi2

Constant Summary

Constants included from RegApi2

RegApi2::VERSION

Constants included from RegApi2::Action

RegApi2::Action::API_URI, RegApi2::Action::DEFAULT_IO_ENCODING, RegApi2::Action::DEFAULT_LANG, RegApi2::Action::DEFAULT_PASSWORD, RegApi2::Action::DEFAULT_USERNAME

Instance Method Summary collapse

Methods included from RegApi2

bill, common, domain, dump_requests, dump_responses, folder, form_to_be_sent, got_response, hosting, service, shop, user, zone

Methods included from RegApi2::Action

#clear_http, #create_http, #get_form_data, #handle_response, #http, #make_action

Instance Method Details

#try_lo_load_defaultsObject

Try to load defaults from ~/.regapi2



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/reg_api2/console_helpers.rb', line 7

def try_lo_load_defaults
  filename = "#{ENV['HOME']}/.regapi2"
  props = %w[ username password lang pem pem_password ca_cert_path ]

  if File.readable?(filename)
    IO.read(filename).split("\n").each do |line|
      line.strip!
      next  if line =~ /\A\s*#/ # skip comments
      if line !~ /\A\s*(\w+)\s*\=(.+)\s*\z/
        $stderr.puts "#{filename}: We expect key=value string but got \"#{line}\""
        exit 1
      end
      name, value = $1, $2
      unless props.include?(name)
        $stderr.puts "#{filename}: Unknown name: \"#{name}\", we know only #{props.join(', ')}"
        exit 1
      end
      RegApi2.send("#{name}=", value)
    end
  end

  puts "Your default username: \"#{RegApi2.username}\", and You can change it with \"#{filename}\"."
end