parliament-grom-decorators 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/locales/en.yml +2 -0
- data/lib/parliament/grom/decorator.rb +2 -0
- data/lib/parliament/grom/decorator/constituency_group.rb +4 -2
- data/lib/parliament/grom/decorator/helpers.rb +10 -0
- data/lib/parliament/grom/decorator/helpers/date_helper.rb +23 -0
- data/lib/parliament/grom/decorator/house_incumbency.rb +2 -0
- data/lib/parliament/grom/decorator/incumbency.rb +2 -0
- data/lib/parliament/grom/decorator/parliaments.rb +45 -0
- data/lib/parliament/grom/decorator/party_membership.rb +2 -0
- data/lib/parliament/grom/decorator/person.rb +2 -0
- data/lib/parliament/grom/decorator/seat_incumbency.rb +1 -0
- data/lib/parliament/grom/decorator/version.rb +1 -1
- data/parliament-grom-decorators.gemspec +1 -0
- metadata +20 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1f63912e3e943808a3c19b71aaf4d91e4779392
|
4
|
+
data.tar.gz: 23e7cab82e27341e5cc054d0afacf314caa4c4bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b007328ad5f76db1d2ac219f527c1ab00986841d92a9f092b8e74898209889eb57bd8085087400d97a036bf1cdd90928409c912bed25de258836d40c450d4ad
|
7
|
+
data.tar.gz: af910edb99fced421aa1953972010fca15fc63df8f9e5413f8250abc77a83d20f5daad9e4997d636001ee3295f2be4fb58e04ef48ee62c8dfbf89b4e45de5370
|
data/config/locales/en.yml
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'parliament/grom/decorator/version'
|
2
|
+
require 'parliament/grom/decorator/helpers'
|
2
3
|
require 'parliament/grom/decorator/constituency_area'
|
3
4
|
require 'parliament/grom/decorator/constituency_group'
|
4
5
|
require 'parliament/grom/decorator/contact_point'
|
@@ -13,6 +14,7 @@ require 'parliament/grom/decorator/party_membership'
|
|
13
14
|
require 'parliament/grom/decorator/person'
|
14
15
|
require 'parliament/grom/decorator/postal_address'
|
15
16
|
require 'parliament/grom/decorator/seat_incumbency'
|
17
|
+
require 'parliament/grom/decorator/parliaments'
|
16
18
|
|
17
19
|
# Namespace for classes and modules that handle connections to, and processing of data from the parliamentary API.
|
18
20
|
# @since 0.1.0
|
@@ -5,6 +5,8 @@ module Parliament
|
|
5
5
|
#
|
6
6
|
# attr [Boolean] correct verifies that the Grom::Node is the expected constituency. This is used in conjunction with postcode lookup to verify if the Grom::Node is the expected constituency.
|
7
7
|
module ConstituencyGroup
|
8
|
+
include Helpers::DateHelper
|
9
|
+
|
8
10
|
attr_accessor :correct
|
9
11
|
# Alias constituencyGroupName with fallback.
|
10
12
|
#
|
@@ -123,9 +125,9 @@ module Parliament
|
|
123
125
|
else
|
124
126
|
@party_name = nil
|
125
127
|
end
|
126
|
-
@party_name
|
127
|
-
end
|
128
128
|
|
129
|
+
@party_name
|
130
|
+
end
|
129
131
|
end
|
130
132
|
end
|
131
133
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Parliament
|
2
|
+
module Grom
|
3
|
+
module Decorator
|
4
|
+
module Helpers
|
5
|
+
# Namespace for date helper methods
|
6
|
+
module DateHelper
|
7
|
+
# Format start_date and end_date into a readable string
|
8
|
+
# @param [String] date_format a string that represents the format we want to use for the date
|
9
|
+
# @example Format a node with an end_date with the date format YYYY-MM-DD
|
10
|
+
# "grom_node_instance.date_range('%Y-%m-%d)" #=> "2010-01-01 to 2015-01-01"
|
11
|
+
def date_range(date_format: '%-e %b %Y')
|
12
|
+
return '[Date unavailable]' if start_date.nil?
|
13
|
+
if end_date
|
14
|
+
"#{I18n.l(start_date, format: date_format)} #{I18n.t('to')} #{I18n.l(end_date, format: date_format)}"
|
15
|
+
else
|
16
|
+
"#{I18n.l(start_date, format: date_format)} #{I18n.t('to_present')}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -3,6 +3,8 @@ module Parliament
|
|
3
3
|
module Decorator
|
4
4
|
# Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/HouseIncumbency
|
5
5
|
module HouseIncumbency
|
6
|
+
include Helpers::DateHelper
|
7
|
+
|
6
8
|
# Alias incumbencyStartDate with fallback.
|
7
9
|
#
|
8
10
|
# @return [DateTime, nil] the start date of the Grom::Node or nil.
|
@@ -3,6 +3,8 @@ module Parliament
|
|
3
3
|
module Decorator
|
4
4
|
# Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/Incumbency
|
5
5
|
module Incumbency
|
6
|
+
include Helpers::DateHelper
|
7
|
+
|
6
8
|
# Alias incumbencyStartDate with fallback.
|
7
9
|
#
|
8
10
|
# @return [DateTime, nil] the start date of the Grom::Node or nil.
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Parliament
|
2
|
+
module Grom
|
3
|
+
module Decorator
|
4
|
+
# Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/Parliaments
|
5
|
+
module ParliamentPeriod
|
6
|
+
include Helpers::DateHelper
|
7
|
+
|
8
|
+
# Alias parliamentPeriodStartDate with fallback.
|
9
|
+
#
|
10
|
+
# @return [DateTime, nil] the start date of the Grom::Node or nil.
|
11
|
+
def start_date
|
12
|
+
@start_date ||= respond_to?(:parliamentPeriodStartDate) ? DateTime.parse(parliamentPeriodStartDate) : nil
|
13
|
+
end
|
14
|
+
|
15
|
+
# Alias parliamentPeriodEndDate with fallback.
|
16
|
+
#
|
17
|
+
# @return [DateTime, nil] the end date of the Grom::Node or nil.
|
18
|
+
def end_date
|
19
|
+
@end_date ||= respond_to?(:parliamentPeriodEndDate) ? DateTime.parse(parliamentPeriodEndDate) : nil
|
20
|
+
end
|
21
|
+
|
22
|
+
# Alias parliamentPeriodNumber with fallback.
|
23
|
+
#
|
24
|
+
# @return [Integer, nil] the incremented number of the parliament
|
25
|
+
def number
|
26
|
+
@number ||= respond_to?(:parliamentPeriodNumber) ? parliamentPeriodNumber.to_i : nil
|
27
|
+
end
|
28
|
+
|
29
|
+
# Checks whether ParliamentPeriod has a next Parliament
|
30
|
+
#
|
31
|
+
# @return [true, false]
|
32
|
+
def next_parliament?
|
33
|
+
respond_to?(:parliamentPeriodHasImmediatelyFollowingParliamentPeriod)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Checks whether ParliamentPeriod has a previous Parliament
|
37
|
+
#
|
38
|
+
# @return [true, false]
|
39
|
+
def previous_parliament?
|
40
|
+
respond_to?(:parliamentPeriodHasImmediatelyPreviousParliamentPeriod)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -3,6 +3,8 @@ module Parliament
|
|
3
3
|
module Decorator
|
4
4
|
# Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/PartyMembership
|
5
5
|
module PartyMembership
|
6
|
+
include Helpers::DateHelper
|
7
|
+
|
6
8
|
# Alias partyMembershipHasParty with fallback.
|
7
9
|
#
|
8
10
|
# @return [Grom::Node, nil] the party of the Grom::Node or nil.
|
@@ -4,6 +4,8 @@ module Parliament
|
|
4
4
|
# Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/Person.
|
5
5
|
# rubocop:disable ModuleLength
|
6
6
|
module Person
|
7
|
+
include Helpers::DateHelper
|
8
|
+
|
7
9
|
# Alias personGivenName with fallback.
|
8
10
|
#
|
9
11
|
# @return [String, String] the given name of the Grom::Node or an empty string.
|
@@ -3,6 +3,7 @@ module Parliament
|
|
3
3
|
module Decorator
|
4
4
|
# Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/SeatIncumbency
|
5
5
|
module SeatIncumbency
|
6
|
+
include Helpers::DateHelper
|
6
7
|
# Alias incumbencyStartDate with fallback.
|
7
8
|
#
|
8
9
|
# @return [DateTime, nil] the start date of the Grom::Node or nil.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parliament-grom-decorators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rebecca Appleyard
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05
|
11
|
+
date: 2017-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -136,6 +136,20 @@ dependencies:
|
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0.1'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: pry
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
139
153
|
description: Parliamentary Grom decorator
|
140
154
|
email:
|
141
155
|
- rklappleyard@gmail.com
|
@@ -162,10 +176,13 @@ files:
|
|
162
176
|
- lib/parliament/grom/decorator/contact_point.rb
|
163
177
|
- lib/parliament/grom/decorator/gender.rb
|
164
178
|
- lib/parliament/grom/decorator/gender_identity.rb
|
179
|
+
- lib/parliament/grom/decorator/helpers.rb
|
180
|
+
- lib/parliament/grom/decorator/helpers/date_helper.rb
|
165
181
|
- lib/parliament/grom/decorator/house.rb
|
166
182
|
- lib/parliament/grom/decorator/house_incumbency.rb
|
167
183
|
- lib/parliament/grom/decorator/house_seat.rb
|
168
184
|
- lib/parliament/grom/decorator/incumbency.rb
|
185
|
+
- lib/parliament/grom/decorator/parliaments.rb
|
169
186
|
- lib/parliament/grom/decorator/party.rb
|
170
187
|
- lib/parliament/grom/decorator/party_membership.rb
|
171
188
|
- lib/parliament/grom/decorator/person.rb
|
@@ -192,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
209
|
version: '0'
|
193
210
|
requirements: []
|
194
211
|
rubyforge_project:
|
195
|
-
rubygems_version: 2.6.
|
212
|
+
rubygems_version: 2.6.12
|
196
213
|
signing_key:
|
197
214
|
specification_version: 4
|
198
215
|
summary: Parliamentary Grom decorator
|