parliament-grom-decorators 0.27.0 → 0.27.1

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: 9420b51cfdc70c699ffbda37e7e4875c11ddc0d8
4
- data.tar.gz: 83d3202ecace607648a92282e1d7228c8645061f
3
+ metadata.gz: 2c866a69215ac0adf7a90e112020a6172133b5ba
4
+ data.tar.gz: 15fd269735a2616a26b5fb105d8ab7ea5493137b
5
5
  SHA512:
6
- metadata.gz: a61e8879c6ae40bf635066cb0e0f937cbbc94cb4f88d67d08195853c3f9f8fc73a6f883c5d4815e13d9c2209c2511621add79f3dd693c54686e300a78a5c2ea4
7
- data.tar.gz: e38fe70757aad8f58e196443dcb148e4ae0fcb235744807069d5dabcb2d48f143657868433905945bc03683f29f7201358c8d6521d09d4ed1efbd1cb936f8ff1
6
+ metadata.gz: a7a09452f95927c69bfced55d6ed1d54fd03dc9f34725aaeb663514f62a6687dfb53bfe82572259f27ea7f81e3c3b1f0dec33d2e1c393b968d263168cef9b54d
7
+ data.tar.gz: 6383d980a79169160f2f7f50b213776fbf30e77f1eb24b9a4784537ab4651405272ac8abca7e630934c199b6f975c8058e56024aa603b721273baa26d0b8175d
@@ -1,41 +1,47 @@
1
1
  require 'parliament/grom/decorator/version'
2
2
  require 'parliament/grom/decorator/helpers'
3
+ require 'parliament/grom/decorator/answer'
4
+ require 'parliament/grom/decorator/answering_body_allocation'
5
+ require 'parliament/grom/decorator/article_type'
6
+ require 'parliament/grom/decorator/audience'
7
+ require 'parliament/grom/decorator/business_item'
8
+ require 'parliament/grom/decorator/collection'
9
+ require 'parliament/grom/decorator/concept'
3
10
  require 'parliament/grom/decorator/constituency_area'
4
11
  require 'parliament/grom/decorator/constituency_group'
5
12
  require 'parliament/grom/decorator/contact_point'
6
13
  require 'parliament/grom/decorator/european_region'
14
+ require 'parliament/grom/decorator/formal_body'
15
+ require 'parliament/grom/decorator/formal_body_chair'
16
+ require 'parliament/grom/decorator/formal_body_membership'
17
+ require 'parliament/grom/decorator/formal_body_type'
7
18
  require 'parliament/grom/decorator/gender'
8
19
  require 'parliament/grom/decorator/gender_identity'
20
+ require 'parliament/grom/decorator/government_incumbency'
21
+ require 'parliament/grom/decorator/government_position'
22
+ require 'parliament/grom/decorator/gov_register_government_organisation'
23
+ require 'parliament/grom/decorator/group'
9
24
  require 'parliament/grom/decorator/house'
10
25
  require 'parliament/grom/decorator/house_seat'
26
+ require 'parliament/grom/decorator/incumbency'
27
+ require 'parliament/grom/decorator/member_image'
11
28
  require 'parliament/grom/decorator/parliamentary_incumbency'
29
+ require 'parliament/grom/decorator/parliaments'
12
30
  require 'parliament/grom/decorator/party'
13
31
  require 'parliament/grom/decorator/party_membership'
14
32
  require 'parliament/grom/decorator/person'
33
+ require 'parliament/grom/decorator/position'
15
34
  require 'parliament/grom/decorator/postal_address'
35
+ require 'parliament/grom/decorator/procedure_route'
36
+ require 'parliament/grom/decorator/procedure_step'
37
+ require 'parliament/grom/decorator/procedure'
38
+ require 'parliament/grom/decorator/question'
16
39
  require 'parliament/grom/decorator/seat_incumbency'
17
- require 'parliament/grom/decorator/parliaments'
18
- require 'parliament/grom/decorator/member_image'
19
- require 'parliament/grom/decorator/formal_body_membership'
20
- require 'parliament/grom/decorator/formal_body'
21
- require 'parliament/grom/decorator/formal_body_type'
22
- require 'parliament/grom/decorator/government_incumbency'
23
- require 'parliament/grom/decorator/government_position'
24
40
  require 'parliament/grom/decorator/opposition_incumbency'
25
41
  require 'parliament/grom/decorator/opposition_position'
26
42
  require 'parliament/grom/decorator/web_article'
27
- require 'parliament/grom/decorator/audience'
28
- require 'parliament/grom/decorator/article_type'
29
- require 'parliament/grom/decorator/collection'
30
- require 'parliament/grom/decorator/concept'
31
- require 'parliament/grom/decorator/incumbency'
32
- require 'parliament/grom/decorator/group'
33
- require 'parliament/grom/decorator/gov_register_government_organisation'
34
- require 'parliament/grom/decorator/position'
35
- require 'parliament/grom/decorator/formal_body_chair'
36
- require 'parliament/grom/decorator/question'
37
- require 'parliament/grom/decorator/answer'
38
- require 'parliament/grom/decorator/answering_body_allocation'
43
+ require 'parliament/grom/decorator/work_package'
44
+ require 'parliament/grom/decorator/work_packageable_thing'
39
45
 
40
46
  # Namespace for classes and modules that handle connections to, and processing of data from the parliamentary API.
41
47
  # @since 0.1.0
@@ -46,42 +52,48 @@ module Parliament
46
52
  # @since 0.1.0
47
53
  module Decorator
48
54
  MAPPING = {
55
+ 'Answer' => Answer,
56
+ 'AnsweringBodyAllocation' => AnsweringBodyAllocation,
57
+ 'ArticleType' => ArticleType,
58
+ 'Audience' => Audience,
59
+ 'BusinessItem' => BusinessItem,
60
+ 'Collection' => Collection,
61
+ 'Concept' => Concept,
49
62
  'ConstituencyArea' => ConstituencyArea,
50
63
  'ConstituencyGroup' => ConstituencyGroup,
51
64
  'ContactPoint' => ContactPoint,
52
65
  'EuropeanRegion' => EuropeanRegion,
66
+ 'FormalBodyChair' => FormalBodyChair,
67
+ 'FormalBodyMembership' => FormalBodyMembership,
68
+ 'FormalBodyType' => FormalBodyType,
69
+ 'FormalBody' => FormalBody,
53
70
  'Gender' => Gender,
54
71
  'GenderIdentity' => GenderIdentity,
72
+ 'GovernmentIncumbency' => GovernmentIncumbency,
73
+ 'GovernmentPosition' => GovernmentPosition,
74
+ 'GovRegisterGovernmentOrganisation' => GovRegisterGovernmentOrganisation,
75
+ 'Group' => Group,
55
76
  'House' => House,
56
77
  'HouseSeat' => HouseSeat,
78
+ 'Incumbency' => Incumbency,
57
79
  'MemberImage' => MemberImage,
80
+ 'OppositionIncumbency' => OppositionIncumbency,
81
+ 'OppositionPosition' => OppositionPosition,
58
82
  'ParliamentPeriod' => ParliamentPeriod,
59
83
  'ParliamentaryIncumbency' => ParliamentaryIncumbency,
60
84
  'Party' => Party,
61
85
  'PartyMembership' => PartyMembership,
62
86
  'Person' => Person,
87
+ 'Position' => Position,
88
+ 'Procedure' => Procedure,
89
+ 'ProcedureRoute' => ProcedureRoute,
90
+ 'ProcedureStep' => ProcedureStep,
63
91
  'PostalAddress' => PostalAddress,
92
+ 'Question' => Question,
64
93
  'SeatIncumbency' => SeatIncumbency,
65
- 'FormalBodyMembership' => FormalBodyMembership,
66
- 'FormalBody' => FormalBody,
67
- 'FormalBodyType' => FormalBodyType,
68
- 'GovernmentIncumbency' => GovernmentIncumbency,
69
- 'GovernmentPosition' => GovernmentPosition,
70
- 'OppositionIncumbency' => OppositionIncumbency,
71
- 'OppositionPosition' => OppositionPosition,
72
94
  'WebArticle' => WebArticle,
73
- 'Audience' => Audience,
74
- 'ArticleType' => ArticleType,
75
- 'Collection' => Collection,
76
- 'Concept' => Concept,
77
- 'Incumbency' => Incumbency,
78
- 'Group' => Group,
79
- 'GovRegisterGovernmentOrganisation' => GovRegisterGovernmentOrganisation,
80
- 'Position' => Position,
81
- 'FormalBodyChair' => FormalBodyChair,
82
- 'Question' => Question,
83
- 'Answer' => Answer,
84
- 'AnsweringBodyAllocation' => AnsweringBodyAllocation
95
+ 'WorkPackage' => WorkPackage,
96
+ 'WorkPackageableThing' => WorkPackageableThing
85
97
  }.freeze
86
98
 
87
99
  class << self
@@ -0,0 +1,45 @@
1
+ module Parliament
2
+ module Grom
3
+ module Decorator
4
+ # Decorator namespace for Grom::Node instances with type: https://id.parliament.uk/schema/BusinessItem
5
+ module BusinessItem
6
+ include Helpers::DateHelper
7
+ # Alias businessItemHasProcedureStep with fallback.
8
+ #
9
+ # @return [Array, Array] an array of ProcedureStep Grom::Nodes of the Grom::Node or an empty array.
10
+ def procedure_steps
11
+ respond_to?(:businessItemHasProcedureStep) ? businessItemHasProcedureStep : []
12
+ end
13
+
14
+ # Each procedure step has a distance from origin
15
+ #
16
+ # @return [Array] an array of ProcedureStep Grom::Nodes sorted by distance from origin.
17
+ def sorted_procedure_steps_by_distance
18
+ procedure_steps.sort_by(&:distance_from_origin)
19
+ end
20
+
21
+ # Alias businessItemDate with fallback.
22
+ #
23
+ # @return [Date, nil] a laying date or nil.
24
+ def date
25
+ respond_to?(:businessItemDate) ? DateTime.parse(businessItemDate) : nil
26
+ end
27
+
28
+ # Alias businessItemHasBusinessItemWebLink with fallback.
29
+ #
30
+ # @return [String, String] a web link to view business item Grom::Node or an empty string.
31
+ def weblink
32
+ respond_to?(:businessItemHasBusinessItemWebLink) ? businessItemHasBusinessItemWebLink : ''
33
+ end
34
+
35
+ # Alias layingHasLayingBody with fallback.
36
+ # NB. One and only one group has to lay, so it will always be the first laying body
37
+ #
38
+ # @return [Grom::Node, nil] a Grom::Node representing the group that did the laying.
39
+ def laying_body
40
+ respond_to?(:layingHasLayingBody) ? layingHasLayingBody.first : nil
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,22 @@
1
+ module Parliament
2
+ module Grom
3
+ module Decorator
4
+ # Decorator namespace for Grom::Node instances with type: https://id.parliament.uk/schema/Procedure
5
+ module Procedure
6
+ # Alias procedureName with fallback.
7
+ #
8
+ # @return [String, String] the name of the Grom::Node or an empty string.
9
+ def name
10
+ respond_to?(:procedureName) ? procedureName : ''
11
+ end
12
+
13
+ # Alias procedureHasWorkPackage with fallback.
14
+ #
15
+ # @return [Array, Array] an array of WorkPackage Grom::Nodes or an empty array.
16
+ def work_packages
17
+ respond_to?(:procedureHasWorkPackage) ? procedureHasWorkPackage : []
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,15 @@
1
+ module Parliament
2
+ module Grom
3
+ module Decorator
4
+ # Decorator namespace for Grom::Node instances with type: https://id.parliament.uk/schema/ProcedureRoute
5
+ module ProcedureRoute
6
+ # Alias procedureRouteIsToProcedureStep with fallback.
7
+ #
8
+ # @return [Array, Array] an array of ProcedureStep Grom::Nodes or an empty array.
9
+ def steps
10
+ respond_to?(:procedureRouteIsToProcedureStep) ? procedureRouteIsToProcedureStep : []
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,29 @@
1
+ module Parliament
2
+ module Grom
3
+ module Decorator
4
+ # Decorator namespace for Grom::Node instances with type: https://id.parliament.uk/schema/ProcedureStep
5
+ module ProcedureStep
6
+ # Alias procedureStepName with fallback.
7
+ #
8
+ # @return [String, String] the name of the Grom::Node or an empty string.
9
+ def name
10
+ respond_to?(:procedureStepName) ? procedureStepName : ''
11
+ end
12
+
13
+ # Alias procedureStepHasHouse with fallback.
14
+ #
15
+ # @return [Array, Array] an array of House Grom::Nodes or an empty array.
16
+ def houses
17
+ respond_to?(:procedureStepHasHouse) ? procedureStepHasHouse : []
18
+ end
19
+
20
+ # Alias distance with fallback.
21
+ #
22
+ # @return [Integer, Integer] an array of House Grom::Nodes or an empty array.
23
+ def distance_from_origin
24
+ respond_to?(:distance) ? distance.to_i : 0
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,7 +1,7 @@
1
1
  module Parliament
2
2
  module Grom
3
3
  module Decorator
4
- VERSION = '0.27.0'.freeze
4
+ VERSION = '0.27.1'.freeze
5
5
  end
6
6
  end
7
7
  end
@@ -0,0 +1,42 @@
1
+ module Parliament
2
+ module Grom
3
+ module Decorator
4
+ # Decorator namespace for Grom::Node instances with type: https://id.parliament.uk/schema/WorkPackage
5
+ module WorkPackage
6
+ # Alias workPackageHasProcedure with fallback.
7
+ # NB: Currently, work packages only have one procedure
8
+ #
9
+ # @return [Grom::Node, nil] a Procedure Grom::Node of the Grom::Node or nil.
10
+ def procedure
11
+ respond_to?(:workPackageHasProcedure) ? workPackageHasProcedure.first : nil
12
+ end
13
+
14
+ # Alias workPackageHasWorkPackageableThing with fallback.
15
+ # NB: Currently, work packages only have one work packageable thing
16
+ #
17
+ # @return [Grom::Node, nil] a Procedure Grom::Node of the Grom::Node or nil.
18
+ def work_packageable_thing
19
+ respond_to?(:workPackageHasWorkPackageableThing) ? workPackageHasWorkPackageableThing.first : nil
20
+ end
21
+
22
+ # Alias workPackageHasBusinessItem with fallback.
23
+ #
24
+ # @return [Array, Array] an array of BusinessItem Grom::Nodes or an empty array.
25
+ def business_items
26
+ respond_to?(:workPackageHasBusinessItem) ? workPackageHasBusinessItem : []
27
+ end
28
+
29
+ # @return [Grom::Node, nil] a BusinessItem Grom::Node or nil.
30
+ def oldest_business_item
31
+ return unless business_items.any?
32
+ business_items.sort_by(&:date).last
33
+ end
34
+
35
+ # @return [Date, nil] an array of BusinessItem Grom::Nodes or an empty array.
36
+ def oldest_business_item_date
37
+ oldest_business_item&.date
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,55 @@
1
+ module Parliament
2
+ module Grom
3
+ module Decorator
4
+ # Decorator namespace for Grom::Node instances with type: https://id.parliament.uk/schema/WorkPackageableThing
5
+ module WorkPackageableThing
6
+ # Alias workPackageableThingName with fallback.
7
+ #
8
+ # @return [String, String] the name of the Grom::Node or an empty string.
9
+ def name
10
+ respond_to?(:workPackageableThingName) ? workPackageableThingName : ''
11
+ end
12
+
13
+ # Alias workPackageableThingHasWorkPackage with fallback.
14
+ # NB: Currently, a work packageable thing only has one work package
15
+ #
16
+ # @return [Grom::Node, nil] a WorkPackage Grom::Node or nil.
17
+ def work_package
18
+ respond_to?(:workPackageableThingHasWorkPackage) ? workPackageableThingHasWorkPackage.first : nil
19
+ end
20
+
21
+ # Alias workPackageableThingHasWorkPackage with fallback.
22
+ #
23
+ # @return [String, String] a web link or an empty string.
24
+ def weblink
25
+ respond_to?(:workPackageableThingHasWorkPackageableThingWebLink) ? workPackageableThingHasWorkPackageableThingWebLink : ''
26
+ end
27
+
28
+ # Uses work_package method in this set of decorators, which could return nil.
29
+ # Uses business_items method in WorkPackage decorators, which could return an empty array.
30
+ #
31
+ # @return [Boolean] whether a work packageable thing has both a work package and some business items.
32
+ def work_package_and_business_items?
33
+ work_package ? work_package.business_items.any? : false
34
+ end
35
+
36
+ # @return [Grom::Node, nil] a BusinessItem Grom::Node or nil.
37
+ def oldest_business_item
38
+ work_package_and_business_items? ? work_package.business_items.sort_by(&:date).last : nil
39
+ end
40
+
41
+ # @return [Date, nil] an array of BusinessItem Grom::Nodes or an empty array.
42
+ def oldest_business_item_date
43
+ oldest_business_item&.date
44
+ end
45
+
46
+ # Alias workPackageableThingComingIntoForceDate with fallback.
47
+ #
48
+ # @return [DateTime, nil] the expiry date (time limit) of a work package or nil.
49
+ def time_limit_for_objection_date
50
+ respond_to?(:workPackageableThingTimeLimitForObjectionEndDate) ? DateTime.parse(workPackageableThingTimeLimitForObjectionEndDate) : nil
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
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.27.0
4
+ version: 0.27.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rebecca Appleyard
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-18 00:00:00.000000000 Z
11
+ date: 2018-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -177,6 +177,7 @@ files:
177
177
  - lib/parliament/grom/decorator/answering_body_allocation.rb
178
178
  - lib/parliament/grom/decorator/article_type.rb
179
179
  - lib/parliament/grom/decorator/audience.rb
180
+ - lib/parliament/grom/decorator/business_item.rb
180
181
  - lib/parliament/grom/decorator/collection.rb
181
182
  - lib/parliament/grom/decorator/concept.rb
182
183
  - lib/parliament/grom/decorator/constituency_area.rb
@@ -208,10 +209,15 @@ files:
208
209
  - lib/parliament/grom/decorator/person.rb
209
210
  - lib/parliament/grom/decorator/position.rb
210
211
  - lib/parliament/grom/decorator/postal_address.rb
212
+ - lib/parliament/grom/decorator/procedure.rb
213
+ - lib/parliament/grom/decorator/procedure_route.rb
214
+ - lib/parliament/grom/decorator/procedure_step.rb
211
215
  - lib/parliament/grom/decorator/question.rb
212
216
  - lib/parliament/grom/decorator/seat_incumbency.rb
213
217
  - lib/parliament/grom/decorator/version.rb
214
218
  - lib/parliament/grom/decorator/web_article.rb
219
+ - lib/parliament/grom/decorator/work_package.rb
220
+ - lib/parliament/grom/decorator/work_packageable_thing.rb
215
221
  - makefile
216
222
  - parliament-grom-decorators.gemspec
217
223
  homepage: http://github.com/ukparliament/parliament-grom-decorators