Module: NwmlsClient::Base

Defined in:
lib/nwmls_client/base.rb

Constant Summary collapse

NWMLS_FILE =
'nwmls.yml'

Class Method Summary collapse

Class Method Details

.load_configObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/nwmls_client/base.rb', line 10

def self.load_config()
  if not File.exist?(NWMLS_FILE)
    puts "Generating config file: #{NWMLS_FILE}"        
    store = YAML::Store.new NWMLS_FILE
    store.transaction do 
      store["default"] = { 
        "mls" => "NWMLS", 
        "schema" => "StandardXML1_3",
        "user_id" => "your_nwmls_user_id",
        "password" => "your_nwmls_password"
      }
    end
  end

  if File.exist?(NWMLS_FILE)
    data = YAML::load_file(NWMLS_FILE)
  else
    raise "Unable to generate config file: #{NWMLS_FILE}"
  end

  return data['default']

end