0.01
No commit activity in last 3 years
No release in over 3 years
Interface with EveryPolitician data from your Ruby app
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.10
~> 5.9.0
~> 0.10.4
~> 10.0
~> 0.42.0
~> 3.0.3
~> 2.0.3

Runtime

 Project Readme

Everypolitician Build Status Gem Version

Interface with EveryPolitician data from your Ruby application.

Installation

Add this line to your application's Gemfile:

gem 'everypolitician'

And then execute:

$ bundle

Or install it yourself as:

$ gem install everypolitician

Usage

Pass the :slug of the country to the country method, and the :slug of the legislature to the legislature method.

Examples:

require 'everypolitician'

australia = Everypolitician::Index.new.country('Australia')
australia.code # => "AU"
senate = australia.legislature('Senate')
senate.popolo # => #<Everypolitician::Popolo::JSON>

united_kingdom = Everypolitician::Index.new.country('UK')
house_of_commons = united_kingdom.legislature('Commons')

american_samoa = Everypolitician::Index.new.country('American-Samoa')
house_of_representatives = american_samoa.legislature('House')

united_arab_emirates = Everypolitician::Index.new.country('United-Arab-Emirates')
national_council = united_arab_emirates.legislature('Federal-National-Council')

algeria = Everypolitician::Index.new.country('Algeria')
national_assembly = algeria.legislature('Majlis')

# Iterate though all known countries
Everypolitician::Index.new.countries.each do |country|
  puts "#{country.name} has #{country.legislatures.size} legislature(s)"
end

# Iterate through all known legislatures
Everypolitician::Index.new.all_legislatures.each do |legislature|
  puts "#{legislature.name} in #{legislature.country.name} has #{legislature.person_count} member(s)"
end

# Fetch Everypolitician::Popolo::LegislativePeriod for the latest term
# Note that this may involve a **substantial download**
puts 'Members of the Assembly:'
assembly = Everypolitician::Index.new.country('Albania').lower_house
assembly.latest_term.memberships.map(&:person).uniq(&:id).each do |person|
  puts person.name
end

By default, the gem connects to EveryPolitician's data on GitHub over HTTPS and returns the most recent data. Specifically it uses the current index file, called countries.json, which itself contains links to specific versions of data files.

If you want to point at a different countries.json, you can override this default behavour by supplying an index_url option to Everypolitician::Index.new like this:

Everypolitician::Index.new(index_url: 'https://cdn.rawgit.com/everypolitician/everypolitician-data/080cb46/countries.json')

The example above is using a specific commit (indicated by the hash 080cb46). If you want to use a local copy of countries.json you can specify a local file path as the index_url instead of a fully-qualified URL.

For more about countries.json, see this description.

Remember that EveryPolitician data is frequently updated — see this information about using EveryPolitician data.

More information on the EveryPolitician site.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/everypolitician/everypolitician.

License

The gem is available as open source under the terms of the MIT License.