lib/geonames_api.rb in geonames_api-0.0.6 vs lib/geonames_api.rb in geonames_api-0.1.0
- old
+ new
@@ -1,36 +1,47 @@
require 'open-uri'
require 'json'
require 'csv'
require 'active_support/all'
require 'zipruby'
-require "geonames_api/version"
-require "geonames_api/hash"
-require "geonames_api/error"
-require "geonames_api/object"
-require "geonames_api/country"
-require "geonames_api/weather"
-require "geonames_api/time_zone"
-require "geonames_api/wikipedia"
module GeoNamesAPI
-
+
mattr_accessor :url
- @@url = "http://api.geonames.org/"
+ self.url = 'http://api.geonames.org/'
- mattr_accessor :formatted
- @@formatted = true
-
mattr_accessor :lang
- @@lang = :en
+ self.lang = :en
mattr_accessor :username
- @@username = "demo"
-
+ self.username = 'demo'
+
+ mattr_accessor :token
+ self.token = nil
+
mattr_accessor :style
- @@style = :full
-
+ self.style = :full
+
+ mattr_accessor :logger
+ self.logger = nil
+
+ mattr_accessor :retries
+ self.retries = 3
+
+ mattr_accessor :max_sleep_time_between_retries
+ self.max_sleep_time_between_retries = 5
+
def self.params
- { formatted: formatted, lang: lang, username: username, style: style }
+ {
+ lang: lang,
+ username: username,
+ token: token,
+ style: style
+ }.delete_if{ |k, v| v.blank? }
end
+end
+
+Dir[File.dirname(__FILE__) + '/geonames_api/*.rb'].each do |file|
+ tgt = File.basename(file, File.extname(file))
+ GeoNamesAPI.autoload tgt.camelize, "geonames_api/#{tgt}"
end