# GeoNames API This is a lightweight client for the [GeoNames](http://www.geonames.org) API. Huge thanks to them for such a great service! There are many GeoNames API clients. BUT, most are rewritten versions of a Java API whose interface is a little funny =| This is a simplified ruby implementation that does not implement the entire API. But, its lightweight and has a nice interface and will be easy to extend :) The gem was written by [@barelyknown](http://twitter.com/barelyknown). ## Getting Started Add this line to your application's Gemfile: gem 'geonames_api' And then execute: $ bundle Or install it yourself as: $ gem install geonames_api ## Usage ### FYI GeoNamesAPI uses conventions similar to Rails' ActiveRecord. If you add any features, please stick to `find` and `all` as the core query methods. The data is converted into the type implied by the content by default. If that isn't sufficient, let's create something more explicit for the exceptions. The GeoNamesAPI classes include getters and setters that are the GeoNames API field names converted dynamically to more rubyish names using Rails' ActiveSupport `underscore` method. If the API ever changes, the attributes of the classes will change. ### Configuration The gem is setup to use the `demo` user account by default. You'll need to provide your own credentials for anything but a simple set of test searches. > GeoNamesAPI.username = "yourusername@yourdomain.com" > GeoNamesAPI.lang = :en For a complete list of the config options, take a look at the `geonames_api.rb` file. ### Country The geonames api uses the ISO code of the country as its natural key. > GeoNamesAPI::Country.find("US") => # > GeoNamesAPI::Country.all => ... array of GeoNamesAPI::Country instances ### Weather The geonames api uses the latitude and longitude of the place as the parameters for its weather service. > GeoNamesAPI::Weather.find(41.88,-87.68) => # ### Others The other services will be implemented as needed. In the mean time, feel free to contribute! Let's keep the style consistent. ## Contributing 1. Fork it 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request 6. Thanks <3