Worldfactbook fetches data on countries for you from the CIA World Factbook.
$ sudo gem install worldfactbook
Or in Bundler:
Note: Worldfactbook requires Nokogiri as a dependency. If you encounter any issues with this gem, it's likely because of the libraries that need to be configured or updated for using Nokogiri. Please refer to its installation guide for help.
Please see the complete Worldfactbook documentation on the wiki.
require 'worldfactbook' w = Worldfactbook::Country.new('united states') OR w = Worldfactbook::Country.new('us') w.population => "313,232,044 (July 2011 est.) country comparison to the world: 3" w.gdp => "$14.66 trillion (2010 est.)" w.major_cities => "New York-Newark 19.3 million; Los Angeles-Long Beach-Santa Ana 12.675 million; Chicago 9.134 million; Miami 5.699 million; WASHINGTON, D.C. (capital) 4.421 million (2009)" w.internet_users => "245 million (2009) country comparison to the world: 2"
Command line usage:
$ worldfactbook japan => returns the location, major cities, population, GDP, unemployment rate, and more for Japan $ worldfactbook canada population => "34,030,589 (July 2011 est.) country comparison to the world: 37" $ worldfactbook help => lists all the command line options $ worldfactbook countries => lists all the countries available along with their two-letter country codes
Contributing to Worldfactbook
Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
Fork the project
Start a feature/bugfix branch
Commit and push until you are happy with your contribution
Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
(The MIT License)
Copyright © 2011:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.