Ruby gem for interacting with EveryPolitician data for a legislature
Ruby Shell
Latest commit 40dc460 Oct 28, 2016 @tmtmtmtm tmtmtmtm committed on GitHub Merge pull request #118 from everypolitician/warnings-in-tests
Enable warnings in tests
Failed to load latest commit information.
bin Initial commit Jan 11, 2016
lib/everypolitician bump version number Oct 28, 2016
test retain tests for current_legislative_period Oct 28, 2016
.rubocop.yml Inherit Rubocop config from everypolitician-data Aug 9, 2016
LICENSE.txt update example to use Aug 30, 2016
everypolitician-popolo.gemspec Require `require_all` Oct 4, 2016


EveryPolitician provides its data in Popolo format. If you want to interact with this data from Ruby then this library makes that task simpler.


Add this line to your application's Gemfile:

gem 'everypolitician-popolo'

And then execute:

$ bundle

Or install it yourself as:

$ gem install everypolitician-popolo


You can download a Popolo file manually from EveryPolitician (although there's another library if you want to automate that). The following example uses Åland Lagting (which is the legislature of the Åland islands, available as JSON data from the EveryPolitician page for Åland).

First you'll need to require the library and read in a file from disk.

require 'everypolitician/popolo'
popolo ='ep-popolo-v1.0.json')

All Popolo classes used by EveryPolitician are implemented:

There are methods defined for each property on a class, e.g. for a Person:

popolo.persons.count # => 47
person = popolo.persons.first # => "e3aab23e-a883-4763-be0d-92e5936024e2" # => "Aaltonen Carina"
person.image # => ""
person.wikidata # => "Q4934081"

You can also find individual records or collections based on their attributes:

popolo.persons.find_by(name: "Aaltonen Carina")
    # => #<Everypolitician::Popolo::Person:0x0000000237dfc8
    #      @document={:id=>"0c705344-23aa-4fa2-9391-af41c1c775b7",
    #                 :identifiers=>[{:identifier=>"Q4934081", :scheme=>"wikidata"}],
    #                 :name=>"Aaltonen Carina"}>

popolo.organizations.where(classification: "party")
    # => [
    #      <Everypolitician::Popolo::Organization:0x000000035779e0
    #       @document={:classification=>"party",
    #                  :id=>"123",
    #                  :name=>"Sunripe Tomato Party"}>,
    #      <Everypolitician::Popolo::Organization:0x000000035779e1
    #       @document={:classification=>"party",
    #                  :id=>"456",
    #                  :name=>"The Greens"}>
    #    ]

See also: everypolitician-ruby

In the example above, the Popolo data comes from a downloaded file (ep-popolo-v1.0.json), which is the kind of file you can get from the EveryPolitician website. But your Ruby application can also interact directly with the EveryPolitician data using the everypolitician-ruby gem, so you don't need to handle JSON files at all. The data the gem returns is in Everypolitician::Popolo format.

require 'everypolitician'

australia ='Australia')
australia.code # => "AU"
senate = australia.legislature('Senate')
senate.persons.find_by(name: "Aden Ridgeway")


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


Bug reports and pull requests are welcome on GitHub at


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