everypolitician-popolo 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e348db6764ddeea2411de793f0b2f46b4c23e32b
4
- data.tar.gz: bdff4880f9a916bcb8e125f9ff11be5dcc2e5bd1
3
+ metadata.gz: 06d7ef4f90694c7c3bb3dd1b0c3c3d625ddb3b2b
4
+ data.tar.gz: 522b022a34eba1f04a62cf095fc13c4d32c73d49
5
5
  SHA512:
6
- metadata.gz: 86f64b7e31c8b3d428572d38023b974813d4f919f78bb3b49294da84ec5b2b91e1b3f5f19b22391452ff9912c87fadaa8c032c207dc63b24e3e1bf5d7d757623
7
- data.tar.gz: 6c59a7b46223324ce61a264422028a5a75ec71b7e80c0a73e34573f2dd5479a64562edb7e834cac2d1a25c87f9cdda3e7d0f7ff23afa1943aa93eb10d4a165cc
6
+ metadata.gz: 90aeb9436dd7897f98cf8c79932d68d3b78482de94e56d3fc23b49df30a6172e43582b0bf0b5c34ed92b606fd240f798d97764de2c066ee87346b04f8c0729e1
7
+ data.tar.gz: a202df2c86a1eaf3d5005c010c87a8361904a5c75b3c4a36b2b9927d960970f0f0195dcb6301e74e356ae6cef50a032a60bdd824e738b11df2269f14c6850c31
@@ -0,0 +1,11 @@
1
+ # Problem
2
+
3
+ # Proposed Solution
4
+
5
+ # Acceptance Criteria
6
+
7
+ # Not Required
8
+
9
+ # Prerequisites
10
+
11
+ # Related Issues
data/CHANGELOG.md CHANGED
@@ -3,6 +3,19 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ ## [0.4.0] - 2016-07-04
7
+
8
+ ### Added
9
+
10
+ - Added `Organization#wikidata`
11
+
12
+ ## [0.3.2] - 2016-06-06
13
+
14
+ ### Fixed
15
+
16
+ - Added missing attribute definition for `Event#start_date` and
17
+ `Event#end_date`
18
+
6
19
  ## [0.3.1] - 2016-05-04
7
20
 
8
21
  ### Fixed
@@ -30,28 +30,38 @@ module Everypolitician
30
30
  end
31
31
 
32
32
  def persons
33
- People.new(popolo[:persons])
33
+ People.new(popolo[:persons], self)
34
34
  end
35
35
 
36
36
  def organizations
37
- Organizations.new(popolo[:organizations])
37
+ Organizations.new(popolo[:organizations], self)
38
38
  end
39
39
 
40
40
  def areas
41
- Areas.new(popolo[:areas])
41
+ Areas.new(popolo[:areas], self)
42
42
  end
43
43
 
44
44
  def events
45
- Events.new(popolo[:events])
45
+ Events.new(popolo[:events], self)
46
46
  end
47
47
 
48
48
  def posts
49
- Posts.new(popolo[:posts])
49
+ Posts.new(popolo[:posts], self)
50
50
  end
51
51
 
52
52
  def memberships
53
- Memberships.new(popolo[:memberships])
53
+ Memberships.new(popolo[:memberships], self)
54
54
  end
55
+
56
+ def legislative_periods
57
+ events.where(classification: 'legislative period').sort_by(&:start_date)
58
+ end
59
+ alias_method :terms, :legislative_periods
60
+
61
+ def current_legislative_period
62
+ legislative_periods.last
63
+ end
64
+ alias_method :current_term, :current_legislative_period
55
65
  end
56
66
  end
57
67
  end
@@ -4,9 +4,11 @@ module Everypolitician
4
4
  include Enumerable
5
5
 
6
6
  attr_reader :documents
7
+ attr_reader :popolo
7
8
 
8
- def initialize(documents)
9
- @documents = documents ? documents.map { |p| klass.new(p) } : []
9
+ def initialize(documents, popolo = nil)
10
+ @documents = documents ? documents.map { |p| klass.new(p, popolo) } : []
11
+ @popolo = popolo
10
12
  end
11
13
 
12
14
  def each(&block)
@@ -4,9 +4,11 @@ module Everypolitician
4
4
 
5
5
  attr_accessor :id
6
6
  attr_reader :document
7
+ attr_reader :popolo
7
8
 
8
- def initialize(document)
9
+ def initialize(document, popolo = nil)
9
10
  @document = document
11
+ @popolo = popolo
10
12
 
11
13
  document.each do |key, value|
12
14
  if respond_to?("#{key}=")
@@ -26,10 +28,13 @@ module Everypolitician
26
28
  end
27
29
 
28
30
  def ==(other)
29
- id == other.id
31
+ self.class == other.class && id == other.id
30
32
  end
31
33
  alias eql? ==
32
34
 
35
+ def identifier(scheme)
36
+ identifiers.find(->{{}}) { |i| i[:scheme] == scheme }[:identifier]
37
+ end
33
38
  end
34
39
  end
35
40
  end
@@ -1,6 +1,8 @@
1
1
  module Everypolitician
2
2
  module Popolo
3
3
  class Events < Collection; end
4
- class Event < Entity; end
4
+ class Event < Entity;
5
+ attr_accessor :start_date, :end_date
6
+ end
5
7
  end
6
8
  end
@@ -4,6 +4,10 @@ module Everypolitician
4
4
 
5
5
  class Membership < Entity
6
6
  attr_accessor :person_id, :on_behalf_of_id, :organization_id, :area_id, :role, :start_date, :end_date
7
+
8
+ def person
9
+ popolo.persons.find_by(id: person_id)
10
+ end
7
11
  end
8
12
  end
9
13
  end
@@ -1,6 +1,11 @@
1
1
  module Everypolitician
2
2
  module Popolo
3
3
  class Organizations < Collection; end
4
- class Organization < Entity; end
4
+
5
+ class Organization < Entity
6
+ def wikidata
7
+ identifier('wikidata')
8
+ end
9
+ end
5
10
  end
6
11
  end
@@ -5,7 +5,7 @@ module Everypolitician
5
5
  class Person < Entity
6
6
  class Error < StandardError; end
7
7
 
8
- attr_accessor :name, :email, :image, :gender, :birth_date, :death_date
8
+ attr_accessor :name, :email, :image, :gender, :birth_date, :death_date, :honorific_prefix, :honorific_suffix
9
9
 
10
10
  def links
11
11
  document.fetch(:links, [])
@@ -19,11 +19,6 @@ module Everypolitician
19
19
  document.fetch(:contact_details, [])
20
20
  end
21
21
 
22
-
23
- def identifier(scheme)
24
- identifiers.find(->{{}}) { |i| i[:scheme] == scheme }[:identifier]
25
- end
26
-
27
22
  def contact(type)
28
23
  contact_details.find(->{{}}) { |i| i[:type] == type }[:value]
29
24
  end
@@ -73,6 +68,10 @@ module Everypolitician
73
68
  fail Error, "Too many names at #{date}: #{at_date}" if at_date.count > 1
74
69
  at_date.first[:name]
75
70
  end
71
+
72
+ def memberships
73
+ popolo.memberships.where(person_id: id)
74
+ end
76
75
  end
77
76
  end
78
77
  end
@@ -1,5 +1,5 @@
1
1
  module Everypolitician
2
2
  module Popolo
3
- VERSION = '0.3.1'
3
+ VERSION = '0.4.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: everypolitician-popolo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Mytton
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-04 00:00:00.000000000 Z
11
+ date: 2016-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -73,6 +73,7 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
+ - ".github/ISSUE_TEMPLATE.md"
76
77
  - ".gitignore"
77
78
  - ".travis.yml"
78
79
  - CHANGELOG.md
@@ -118,3 +119,4 @@ signing_key:
118
119
  specification_version: 4
119
120
  summary: Makes it easy to work with EveryPolitician's Popolo output files from Ruby
120
121
  test_files: []
122
+ has_rdoc: