This gem is a simple wrapper for the geonames.org JSON API. It will raise an exception, if the API responds with an error, or if the HTTP GET request fails. If the request is successful, it will parse the JSON response and return it as a Hashie::Mash object.
Currently the gem supports the following methods:
Feel free to add any missing methods and send a pull request!
Add this line to your application's Gemfile:
gem 'geonames-api-client', require: 'geonames', github: 'teoulas/ruby-geonames-api-client'
And then execute:
$ bundle
Or install it yourself as:
$ gem install geonames-api-client
Configure:
Geonames.configuration = {
:username => 'your-username',
:host => 'api.geonames.org'
}
Make requests:
Geonames.get(123)
Geonames.search({:q => 'london'})
config = {:username => 'demo'}
client = Geonames::Client.new(config)
client.get(123)
The methods are defined on Geonames::Client, but the Geonames module uses
method_missing
magic to instantiate a client and call the relevant method
with the parameters passed.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request