Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cabinet memberships documentation #15616

Merged
merged 2 commits into from
Mar 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,39 +110,6 @@ bundle exec rake test:all
bundle exec rake
```

## Internal documentation

### Interacting with unstable data

We use data from the `unstable/positions.csv` file in a legislature's
directory to display cabinet memberships on the website. Because this data
is unstable there currently aren't methods in [the `everypolitician`
gem](https://github.com/everypolitician/everypolitician-ruby) for
interacting with it, so viewer-sinatra has some of its own classes for
dealing with it. These classes live in the
`lib/everypolitician_extensions.rb` file and are documented below.

#### Get all cabinet memberships for a person

To print all of the known cabinet memberships for a person, you can do the
following:

```ruby
house_of_commons = Everypolitician::Index.new.country('UK').legislature('Commons')
person = house_of_commons.popolo.persons.find_by(name: 'Gordon Brown')

person.cabinet_memberships.each do |membership|
puts "#{person.name} was #{membership.label} #{membership.start_date} - #{membership.end_date}"
end
```

Which will output something like this:

```
Gordon Brown was Prime Minister of the United Kingdom 2007-06-27 - 2010-05-11
Gordon Brown was Chancellor of the Exchequer 1997-05-02 - 2007-06-27
```

## Sinatra, SASS, styling

The project uses [Sinatra](http://www.sinatrarb.com), an ultra-minimal Ruby MVC web app framework.
Expand Down
12 changes: 12 additions & 0 deletions lib/person_cards.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ def legislative_memberships
person.memberships.where(legislative_period_id: term.id)
end

# List of cabinet memberships this person held in this term
#
# @example Iterating through cabinet memberships for a {PersonCard} instance.
# person_card.cabinet_memberships.each do |membership|
# puts "#{person_card.name} was #{membership.label} #{membership.start_date} - #{membership.end_date}"
# end
#
# @return [Array<Everypolitician::LegislatureExtension::CabinetMembership>]
def cabinet_memberships
[]
end

private

attr_reader :person, :term
Expand Down
4 changes: 4 additions & 0 deletions t/page/term_table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@
af.legislative_memberships.first.area.name.must_equal 'Wahlkreis: 3B – Waldviertel'
end

it 'has a stub implementation of cabinet memberships' do
af.cabinet_memberships.must_equal []
end

it 'has two entries on bio card' do
af.bio.count.must_equal 2
end
Expand Down