parliament-ruby 0.5.6 → 0.5.7

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: a76fd77763a9fe33a35de30104d82946e7f07177
4
- data.tar.gz: 50b97f4b12cc039d3d27b32e10847492c781f5f6
3
+ metadata.gz: 5be3624320b2e71f2c866d40afafe52136efeff5
4
+ data.tar.gz: 42f22e3125fad051a6136ab25c94cccd50826aea
5
5
  SHA512:
6
- metadata.gz: 159d6a84432278a212bc1f882813475cef341a4d83adb6fc48b89cfaaf2610a80ba532402bf35beb2c749247e4bf64c87f6848ce43e63af962e2f8b3ee63df91
7
- data.tar.gz: b9bf0127cdf490412fe162eb88db4681981a924de28f2cdffc5f3cb37a92057de9e8da75245a6aded8b5522507972823da623186d38ef6335eaacceb6862cc7e
6
+ metadata.gz: f7ef3458bf75e223766b6a0d0e6e8e1c8b9604bd49afd74883aab3b40cc2b252ad8ea41e372e32b833418a5ae679ab5ddb3a2853c07c4c26bb9e0e425830a9f2
7
+ data.tar.gz: 245c285b50a42044f4791439e3081365ecd8e2933a9a80e4e1afd153569348fa5ad6ee255fb7b0f92ced6c22d71b182f92f8f802c6bf2132badc84ba745908ca
@@ -53,6 +53,12 @@ module Parliament
53
53
 
54
54
  @contact_points = contact_points.flatten.uniq
55
55
  end
56
+
57
+ def current?
58
+ has_end_date = respond_to?(:constituencyGroupEndDate)
59
+
60
+ !has_end_date
61
+ end
56
62
  end
57
63
  end
58
64
  end
@@ -22,6 +22,14 @@ module Parliament
22
22
  def contact_points
23
23
  respond_to?(:incumbencyHasContactPoint) ? incumbencyHasContactPoint : []
24
24
  end
25
+
26
+ def seat
27
+ respond_to?(:seatIncumbencyHasHouseSeat) ? seatIncumbencyHasHouseSeat.first : nil
28
+ end
29
+
30
+ def house
31
+ respond_to?(:houseIncumbencyHasHouse) ? houseIncumbencyHasHouse.first : nil
32
+ end
25
33
  end
26
34
  end
27
35
  end
@@ -10,7 +10,7 @@ module Parliament
10
10
  end
11
11
 
12
12
  def member_count
13
- respond_to?(:count) ? count : nil
13
+ respond_to?(:count) ? count.to_i : nil
14
14
  end
15
15
  end
16
16
  end
@@ -25,11 +25,27 @@ module Parliament
25
25
  end
26
26
 
27
27
  def incumbencies
28
- respond_to?(:memberHasIncumbency) ? memberHasIncumbency : []
28
+ if respond_to?(:memberHasIncumbency)
29
+ memberHasIncumbency.select { |inc| inc.type == 'http://id.ukpds.org/schema/Incumbency' }
30
+ else
31
+ []
32
+ end
29
33
  end
30
34
 
31
35
  def seat_incumbencies
32
- respond_to?(:memberHasIncumbency) ? memberHasIncumbency : []
36
+ if respond_to?(:memberHasIncumbency)
37
+ memberHasIncumbency.select { |inc| inc.type == 'http://id.ukpds.org/schema/SeatIncumbency' }
38
+ else
39
+ []
40
+ end
41
+ end
42
+
43
+ def house_incumbencies
44
+ if respond_to?(:memberHasIncumbency)
45
+ memberHasIncumbency.select { |inc| inc.type == 'http://id.ukpds.org/schema/HouseIncumbency' }
46
+ else
47
+ []
48
+ end
33
49
  end
34
50
 
35
51
  def seats
@@ -51,6 +67,10 @@ module Parliament
51
67
  houses << seat.house
52
68
  end
53
69
 
70
+ house_incumbencies.each do |inc|
71
+ houses << inc.house
72
+ end
73
+
54
74
  @houses = houses.flatten.uniq
55
75
  end
56
76
 
@@ -91,6 +111,18 @@ module Parliament
91
111
  def gender
92
112
  gender_identities.empty? ? nil : gender_identities.first.gender
93
113
  end
114
+
115
+ def statuses
116
+ return @statuses unless @statuses.nil?
117
+
118
+ statuses = []
119
+ statuses << 'Current MP' unless seat_incumbencies.select(&:current?).empty?
120
+ statuses << 'Lord' unless house_incumbencies.select(&:current?).empty?
121
+ statuses << 'Former Lord' if !house_incumbencies.empty? && house_incumbencies.select(&:current?).empty?
122
+ statuses << 'Former MP' if !seat_incumbencies.empty? && seat_incumbencies.select(&:current?).empty?
123
+
124
+ @statuses = statuses
125
+ end
94
126
  end
95
127
  end
96
128
  end
@@ -1,3 +1,3 @@
1
1
  module Parliament
2
- VERSION = '0.5.6'.freeze
2
+ VERSION = '0.5.7'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parliament-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.5.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Rayner
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-06 00:00:00.000000000 Z
11
+ date: 2017-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grom