lib/leadtune/config.rb in leadtune-0.0.2 vs lib/leadtune/config.rb in leadtune-0.0.3
- old
+ new
@@ -14,14 +14,10 @@
@@username = nil
@@password = nil
@@organization = nil
@@timeout = nil
- def initialize(config_file=nil)
- load_config_file_values(config_file)
- end
-
def self.username=(username)
@@username = username
end
def self.password=(password)
@@ -35,36 +31,31 @@
def self.leadtune_host=(leadtune_host)
@@leadtune_host = leadtune_host
end
def self.timeout=(timeout)
- @@timeout = timeout.to_i
+ @@timeout = timeout
end
def username
- @username ||= @@username || ENV["LEADTUNE_USERNAME"] || @config_file_values["username"]
+ @username ||= @@username
end
def password
- @password ||= @@password || ENV["LEADTUNE_PASSWORD"] || @config_file_values["password"]
+ @password ||= @@password
end
def timeout
- @timeout ||= (@@timeout ||
- ENV["LEADTUNE_TIMEOUT"] ||
- @config_file_values["timeout"] ||
- DEFAULT_TIMEOUT).to_i
+ @timeout ||= @@timeout || DEFAULT_TIMEOUT
end
def organization
- @@organization || ENV["LEADTUNE_ORGANIZATION"] || @config_file_values["organization"]
+ @@organization
end
def leadtune_host
- @leadtune_host ||= (ENV["LEADTUNE_HOST"] ||
- @config_file_values["host"] ||
- LEADTUNE_HOSTS[environment])
+ @leadtune_host ||= @@leadtune_host || LEADTUNE_HOSTS[environment]
end
def environment
@environment ||= production_environment_detected? ? :production : :sandbox
end
@@ -80,31 +71,9 @@
end
end
private
-
- def load_config_file_values(config_file)
- @config_file_values = {}
-
- find_config_file(config_file) do |config_file|
- @config_file_values = YAML::load(config_file)
- end
- end
-
- def find_config_file(config_file)
- case config_file
- when String
- yield File.open(config_file)
- when File, StringIO
- yield config_file
- when nil
- if File.exist?("leadtune.yml")
- yield File.open("leadtune.yml")
- end
- end
- end
-
DEFAULT_TIMEOUT = 5
LEADTUNE_HOST_SANDBOX = "https://sandbox-appraiser.leadtune.com".freeze
LEADTUNE_HOST_PRODUCTION = "https://appraiser.leadtune.com".freeze
LEADTUNE_HOSTS = {