parliament-grom-decorators 0.0.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.hound.yml +4 -0
- data/.rspec +2 -0
- data/.rubocop.yml +55 -0
- data/.travis.yml +3 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +10 -0
- data/LICENSE +7 -0
- data/README.md +47 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/parliament/grom/decorator.rb +40 -0
- data/lib/parliament/grom/decorator/constituency_area.rb +29 -0
- data/lib/parliament/grom/decorator/constituency_group.rb +94 -0
- data/lib/parliament/grom/decorator/contact_point.rb +50 -0
- data/lib/parliament/grom/decorator/gender.rb +15 -0
- data/lib/parliament/grom/decorator/gender_identity.rb +15 -0
- data/lib/parliament/grom/decorator/house.rb +43 -0
- data/lib/parliament/grom/decorator/house_incumbency.rb +50 -0
- data/lib/parliament/grom/decorator/house_seat.rb +29 -0
- data/lib/parliament/grom/decorator/incumbency.rb +57 -0
- data/lib/parliament/grom/decorator/party.rb +29 -0
- data/lib/parliament/grom/decorator/party_membership.rb +36 -0
- data/lib/parliament/grom/decorator/person.rb +190 -0
- data/lib/parliament/grom/decorator/postal_address.rb +28 -0
- data/lib/parliament/grom/decorator/seat_incumbency.rb +71 -0
- data/lib/parliament/grom/decorator/version.rb +7 -0
- data/parliament-grom-decorators.gemspec +31 -0
- metadata +170 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b2f75a3801ad85977ad528da1b1f2c0d3f26629b
|
4
|
+
data.tar.gz: 6448048f224bd2ee396c9e3ec456ea0111116761
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bc564c635935c2caf45966685c4a165c9f2329b17ca946d1312477d88354d668adfef4b6584b0c2fce20283a88d3ef8db2dce1df671110ca52dbe2416ced0c67
|
7
|
+
data.tar.gz: 29c972949860372dfb5e4b4c227f40515e8785c2452fde5b50a4da477bec03e4fa59b7a6a1e06da98860c5d15dd9fd4cd6dd21fe1ee67f35bcac3271968f2352
|
data/.gitignore
ADDED
data/.hound.yml
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
Metrics/LineLength:
|
2
|
+
Description: 'Limit lines to 120 characters.'
|
3
|
+
Max: 120
|
4
|
+
IgnoredPatterns: ['\A#', '\A([ ]{2}|[ ]{4})#']
|
5
|
+
|
6
|
+
Style/SpaceBeforeFirstArg:
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
Style/BracesAroundHashParameters:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
Style/IndentHash:
|
13
|
+
EnforcedStyle: consistent
|
14
|
+
|
15
|
+
Style/AlignHash:
|
16
|
+
Severity: fatal
|
17
|
+
Enabled: true
|
18
|
+
EnforcedHashRocketStyle: table
|
19
|
+
EnforcedColonStyle: table
|
20
|
+
|
21
|
+
Style/AlignParameters:
|
22
|
+
EnforcedStyle: with_fixed_indentation
|
23
|
+
|
24
|
+
Style/StringLiterals:
|
25
|
+
EnforcedStyle: single_quotes
|
26
|
+
|
27
|
+
Style/CollectionMethods:
|
28
|
+
PreferredMethods:
|
29
|
+
collect: 'map'
|
30
|
+
collect!: 'map!'
|
31
|
+
inject: 'reduce'
|
32
|
+
detect: 'find'
|
33
|
+
find_all: 'select'
|
34
|
+
|
35
|
+
Style/DotPosition:
|
36
|
+
EnforcedStyle: leading
|
37
|
+
|
38
|
+
Style/DoubleNegation:
|
39
|
+
Enabled: false
|
40
|
+
|
41
|
+
Style/SpaceAroundOperators:
|
42
|
+
# When true, allows most uses of extra spacing if the intent is to align
|
43
|
+
# with an operator on the previous or next line, not counting empty lines
|
44
|
+
# or comment lines.
|
45
|
+
AllowForAlignment: true
|
46
|
+
|
47
|
+
Style/FrozenStringLiteralComment:
|
48
|
+
Enabled: false
|
49
|
+
|
50
|
+
AllCops:
|
51
|
+
Exclude:
|
52
|
+
- '*.gemspec'
|
53
|
+
- 'vendor/**/*'
|
54
|
+
- 'spec/**/*'
|
55
|
+
- 'tmp/**/*'
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at mattrayner1@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in parliament-grom-decorator.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
# Include coveralls for CI coverage reports
|
7
|
+
gem 'coveralls', require: false
|
8
|
+
|
9
|
+
gem 'parliament-ntriple', path: '../parliament-ntriple'
|
10
|
+
gem 'parliament-ruby', path: '../parliament-ruby'
|
data/LICENSE
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright (c) 2016-2017 United Kingdom Parliament
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# Parliament::Grom::Decorators
|
2
|
+
|
3
|
+
[parliament-grom-decorators](http://rubygems.org/gems/parliament-grom-decorators) is a gem created by the [Parliamentary Digital Service](https://www.parliament.uk/mps-lords-and-offices/offices/bicameral/parliamentary-digital-service/) to allow Grom::Node objects to be extended with alias methods.
|
4
|
+
|
5
|
+
> **NOTE:** This gem is in active development and is likely to change at short notice. It is not recommended that you use this in any production environment.
|
6
|
+
|
7
|
+
## Requirements
|
8
|
+
[parliament-grom-decorators](http://github.com/ukparliament/parliament-grom-decorators) requires the following:
|
9
|
+
* [Ruby](https://www.ruby-lang.org/en/)
|
10
|
+
* [Bundler](http://http://bundler.io/)
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
This gem is currently not available on RubyGems. To use it in an application, install it directly from GitHub via your Gemfile
|
15
|
+
```bash
|
16
|
+
gem 'parliament-grom-decorators', git: 'https://github.com/ukparliament/parliament-grom-decorators.git', branch: 'master'
|
17
|
+
```
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
This gem's main function is to extend Grom::Node objects with alias methods.
|
22
|
+
|
23
|
+
> **Note:** Comprehensive class documentation can be found on [rubydocs](http://www.rubydoc.info/github/ukparliament/parliament-grom-decorators/master/file/README.md).
|
24
|
+
|
25
|
+
## Getting Started with Development
|
26
|
+
To clone the repository and set up the dependencies, run the following:
|
27
|
+
```bash
|
28
|
+
git clone https://github.com/ukparliament/parliament-grom-decorators.git
|
29
|
+
cd parliament-grom-decorators
|
30
|
+
bundle install
|
31
|
+
```
|
32
|
+
|
33
|
+
### Running the tests
|
34
|
+
We use [RSpec](http://rspec.info/) as our testing framework and tests can be run using:
|
35
|
+
```bash
|
36
|
+
bundle exec rake
|
37
|
+
```
|
38
|
+
|
39
|
+
## Contributing
|
40
|
+
If you wish to submit a bug fix or feature, you can create a pull request and it will be merged pending a code review.
|
41
|
+
|
42
|
+
1. Fork the repository
|
43
|
+
1. Create your feature branch (`git checkout -b my-new-feature`)
|
44
|
+
1. Commit your changes (`git commit -am 'Add some feature'`)
|
45
|
+
1. Push to the branch (`git push origin my-new-feature`)
|
46
|
+
1. Ensure your changes are tested using [Rspec](http://rspec.info/)
|
47
|
+
1. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'parliament/grom/decorator'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'parliament/grom/decorator/version'
|
2
|
+
require 'parliament/grom/decorator/constituency_area'
|
3
|
+
require 'parliament/grom/decorator/constituency_group'
|
4
|
+
require 'parliament/grom/decorator/contact_point'
|
5
|
+
require 'parliament/grom/decorator/gender'
|
6
|
+
require 'parliament/grom/decorator/gender_identity'
|
7
|
+
require 'parliament/grom/decorator/house'
|
8
|
+
require 'parliament/grom/decorator/house_incumbency'
|
9
|
+
require 'parliament/grom/decorator/house_seat'
|
10
|
+
require 'parliament/grom/decorator/incumbency'
|
11
|
+
require 'parliament/grom/decorator/party'
|
12
|
+
require 'parliament/grom/decorator/party_membership'
|
13
|
+
require 'parliament/grom/decorator/person'
|
14
|
+
require 'parliament/grom/decorator/postal_address'
|
15
|
+
require 'parliament/grom/decorator/seat_incumbency'
|
16
|
+
|
17
|
+
# Namespace for classes and modules that handle connections to, and processing of data from the parliamentary API.
|
18
|
+
# @since 0.1.0
|
19
|
+
module Parliament
|
20
|
+
module Grom
|
21
|
+
# Namespace for Grom decorators.
|
22
|
+
#
|
23
|
+
# @since 0.1.0
|
24
|
+
module Decorator
|
25
|
+
# Decorates objects with alias methods extended from its decorator module.
|
26
|
+
#
|
27
|
+
# @param [Grom::Node] object the object to be decorated.
|
28
|
+
def self.decorate(object)
|
29
|
+
return object unless object.respond_to?(:type)
|
30
|
+
|
31
|
+
object_type = ::Grom::Helper.get_id(object.type)
|
32
|
+
|
33
|
+
return object unless constants.include?(object_type.to_sym)
|
34
|
+
|
35
|
+
decorator_module = Object.const_get("Parliament::Grom::Decorator::#{object_type}")
|
36
|
+
object.extend(decorator_module)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Parliament
|
2
|
+
module Grom
|
3
|
+
module Decorator
|
4
|
+
# Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/ConstituencyArea
|
5
|
+
module ConstituencyArea
|
6
|
+
# Alias constituencyAreaLatitude with fallback.
|
7
|
+
#
|
8
|
+
# @return [String, String] the latitude of the Grom::Node or an empty string.
|
9
|
+
def latitude
|
10
|
+
respond_to?(:constituencyAreaLatitude) ? constituencyAreaLatitude : ''
|
11
|
+
end
|
12
|
+
|
13
|
+
# Alias constituencyAreaLongitude with fallback.
|
14
|
+
#
|
15
|
+
# @return [String, String] the longitude of the Grom::Node or an empty string.
|
16
|
+
def longitude
|
17
|
+
respond_to?(:constituencyAreaLongitude) ? constituencyAreaLongitude : ''
|
18
|
+
end
|
19
|
+
|
20
|
+
# Alias constituencyAreaExtent with fallback.
|
21
|
+
#
|
22
|
+
# @return [String, String] the polygon of the Grom::Node or an empty string.
|
23
|
+
def polygon
|
24
|
+
respond_to?(:constituencyAreaExtent) ? constituencyAreaExtent : ''
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
module Parliament
|
2
|
+
module Grom
|
3
|
+
module Decorator
|
4
|
+
# Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/ConstituencyGroup
|
5
|
+
module ConstituencyGroup
|
6
|
+
# Alias constituencyGroupName with fallback.
|
7
|
+
#
|
8
|
+
# @return [String, String] the name of the Grom::Node or an empty string.
|
9
|
+
def name
|
10
|
+
respond_to?(:constituencyGroupName) ? constituencyGroupName : ''
|
11
|
+
end
|
12
|
+
|
13
|
+
# Alias constituencyGroupStartDate with fallback.
|
14
|
+
#
|
15
|
+
# @return [DateTime, nil] the start date of the Grom::Node or nil.
|
16
|
+
def start_date
|
17
|
+
@start_date ||= respond_to?(:constituencyGroupStartDate) ? DateTime.parse(constituencyGroupStartDate) : nil
|
18
|
+
end
|
19
|
+
|
20
|
+
# Alias constituencyGroupEndDate with fallback.
|
21
|
+
#
|
22
|
+
# @return [DateTime, nil] the end date of the Grom::Node or nil.
|
23
|
+
def end_date
|
24
|
+
@end_date ||= respond_to?(:constituencyGroupEndDate) ? DateTime.parse(constituencyGroupEndDate) : nil
|
25
|
+
end
|
26
|
+
|
27
|
+
# Alias constituencyGroupHasHouseSeat with fallback.
|
28
|
+
#
|
29
|
+
# @return [Array, Array] the house seats of the Grom::Node or an empty array.
|
30
|
+
def seats
|
31
|
+
respond_to?(:constituencyGroupHasHouseSeat) ? constituencyGroupHasHouseSeat : []
|
32
|
+
end
|
33
|
+
|
34
|
+
# Alias houseSeatHasSeatIncumbency with fallback.
|
35
|
+
#
|
36
|
+
# @return [Array, Array] the seat incumbencies of the Grom::Node or an empty array.
|
37
|
+
def seat_incumbencies
|
38
|
+
return @seat_incumbencies unless @seat_incumbencies.nil?
|
39
|
+
|
40
|
+
seat_incumbencies = []
|
41
|
+
seats.each do |seat|
|
42
|
+
seat_incumbencies << seat.seat_incumbencies
|
43
|
+
end
|
44
|
+
|
45
|
+
@seat_incumbencies = seat_incumbencies.flatten.uniq
|
46
|
+
end
|
47
|
+
|
48
|
+
# Alias incumbencyHasMember with fallback.
|
49
|
+
#
|
50
|
+
# @return [Array, Array] the members of the Grom::Node or an empty array.
|
51
|
+
def members
|
52
|
+
return @members unless @members.nil?
|
53
|
+
|
54
|
+
members = []
|
55
|
+
seat_incumbencies.each do |seat_incumbency|
|
56
|
+
members << seat_incumbency.member
|
57
|
+
end
|
58
|
+
|
59
|
+
@members = members.flatten.uniq
|
60
|
+
end
|
61
|
+
|
62
|
+
# Alias constituencyGroupHasConstituencyArea with fallback.
|
63
|
+
#
|
64
|
+
# @return [Grom::Node, nil] a Grom::Node with type http://id.ukpds.org/schema/ConstituencyArea or nil.
|
65
|
+
def area
|
66
|
+
respond_to?(:constituencyGroupHasConstituencyArea) ? constituencyGroupHasConstituencyArea.first : nil
|
67
|
+
end
|
68
|
+
|
69
|
+
# Alias incumbencyHasContactPoint with fallback.
|
70
|
+
#
|
71
|
+
# @return [Array, Array] the contact points of the Grom::Node or an empty array.
|
72
|
+
def contact_points
|
73
|
+
return @contact_points unless @contact_points.nil?
|
74
|
+
|
75
|
+
contact_points = []
|
76
|
+
seat_incumbencies.each do |seat_incumbency|
|
77
|
+
contact_points << seat_incumbency.contact_points
|
78
|
+
end
|
79
|
+
|
80
|
+
@contact_points = contact_points.flatten.uniq
|
81
|
+
end
|
82
|
+
|
83
|
+
# Checks if Grom::Node has an end date.
|
84
|
+
#
|
85
|
+
# @return [Boolean] a boolean depending on whether or not the Grom::Node has an end date.
|
86
|
+
def current?
|
87
|
+
has_end_date = respond_to?(:constituencyGroupEndDate)
|
88
|
+
|
89
|
+
!has_end_date
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Parliament
|
2
|
+
module Grom
|
3
|
+
module Decorator
|
4
|
+
# Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/ContactPoint
|
5
|
+
module ContactPoint
|
6
|
+
# Alias contactPointHasPostalAddress with fallback.
|
7
|
+
#
|
8
|
+
# @return [Array, Array] an array of the postal addresses for the Grom::Node or an empty array.
|
9
|
+
def postal_addresses
|
10
|
+
respond_to?(:contactPointHasPostalAddress) ? contactPointHasPostalAddress : []
|
11
|
+
end
|
12
|
+
|
13
|
+
# Alias email with fallback.
|
14
|
+
#
|
15
|
+
# @return [String, String] the email of the Grom::Node or an empty string.
|
16
|
+
def email
|
17
|
+
instance_variable_get('@email'.to_sym).nil? ? '' : instance_variable_get('@email'.to_sym)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Alias phoneNumber with fallback.
|
21
|
+
#
|
22
|
+
# @return [String, String] the phone number of the Grom::Node or an empty string.
|
23
|
+
def phone_number
|
24
|
+
respond_to?(:phoneNumber) ? phoneNumber : ''
|
25
|
+
end
|
26
|
+
|
27
|
+
# Alias faxNumber with fallback.
|
28
|
+
#
|
29
|
+
# @return [String, String] the fax number of the Grom::Node or an empty string.
|
30
|
+
def fax_number
|
31
|
+
respond_to?(:faxNumber) ? faxNumber : ''
|
32
|
+
end
|
33
|
+
|
34
|
+
# Alias contactPointHasPerson with fallback.
|
35
|
+
#
|
36
|
+
# @return [Array, Array] the person connected to the Grom::Node or an empty array.
|
37
|
+
def person
|
38
|
+
respond_to?(:contactPointHasPerson) ? contactPointHasPerson : []
|
39
|
+
end
|
40
|
+
|
41
|
+
# Alias contactPointHasIncumbency with fallback.
|
42
|
+
#
|
43
|
+
# @return [Grom::Node, nil] the incumbency of the Grom::Node or nil.
|
44
|
+
def incumbency
|
45
|
+
respond_to?(:contactPointHasIncumbency) ? contactPointHasIncumbency.first : nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Parliament
|
2
|
+
module Grom
|
3
|
+
module Decorator
|
4
|
+
# Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/Gender
|
5
|
+
module Gender
|
6
|
+
# Alias genderName with fallback.
|
7
|
+
#
|
8
|
+
# @return [String, String] the gender name of the Grom::Node or an empty string.
|
9
|
+
def name
|
10
|
+
respond_to?(:genderName) ? genderName : ''
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Parliament
|
2
|
+
module Grom
|
3
|
+
module Decorator
|
4
|
+
# Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/GenderIdentity
|
5
|
+
module GenderIdentity
|
6
|
+
# Alias genderIdentityHasGender with fallback.
|
7
|
+
#
|
8
|
+
# @return [Grom::Node, nil] a Grom::Node with type http://id.ukpds.org/schema/Gender or nil.
|
9
|
+
def gender
|
10
|
+
respond_to?(:genderIdentityHasGender) ? genderIdentityHasGender.first : nil
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Parliament
|
2
|
+
module Grom
|
3
|
+
module Decorator
|
4
|
+
# Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/House
|
5
|
+
module House
|
6
|
+
# Alias houseName with fallback.
|
7
|
+
#
|
8
|
+
# @return [String, String] the name of the Grom::Node or an empty string.
|
9
|
+
def name
|
10
|
+
respond_to?(:houseName) ? houseName : ''
|
11
|
+
end
|
12
|
+
|
13
|
+
# Alias houseSeatHasSeatIncumbency with fallback.
|
14
|
+
#
|
15
|
+
# @return [Array, Array] the seat incumbencies of the Grom::Node or an empty array.
|
16
|
+
def seat_incumbencies
|
17
|
+
return @seat_incumbencies unless @seat_incumbencies.nil?
|
18
|
+
|
19
|
+
seat_incumbencies = []
|
20
|
+
seats.each do |seat|
|
21
|
+
seat_incumbencies << seat.seat_incumbencies
|
22
|
+
end
|
23
|
+
|
24
|
+
@seat_incumbencies = seat_incumbencies.flatten.uniq
|
25
|
+
end
|
26
|
+
|
27
|
+
# Alias houseHasHouseSeat with fallback.
|
28
|
+
#
|
29
|
+
# @return [Array, Array] the house seats of the Grom::Node or an empty array.
|
30
|
+
def seats
|
31
|
+
respond_to?(:houseHasHouseSeat) ? houseHasHouseSeat : []
|
32
|
+
end
|
33
|
+
|
34
|
+
# Alias houseHasHouseIncumbency with fallback.
|
35
|
+
#
|
36
|
+
# @return [Array, Array] the house incumbencies of the Grom::Node or an empty array.
|
37
|
+
def house_incumbencies
|
38
|
+
respond_to?(:houseHasHouseIncumbency) ? houseHasHouseIncumbency : []
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Parliament
|
2
|
+
module Grom
|
3
|
+
module Decorator
|
4
|
+
# Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/HouseIncumbency
|
5
|
+
module HouseIncumbency
|
6
|
+
# Alias incumbencyStartDate with fallback.
|
7
|
+
#
|
8
|
+
# @return [DateTime, nil] the start date of the Grom::Node or nil.
|
9
|
+
def start_date
|
10
|
+
@start_date ||= respond_to?(:incumbencyStartDate) ? DateTime.parse(incumbencyStartDate) : nil
|
11
|
+
end
|
12
|
+
|
13
|
+
# Alias incumbencyEndDate with fallback.
|
14
|
+
#
|
15
|
+
# @return [DateTime, nil] the end date of the Grom::Node or nil.
|
16
|
+
def end_date
|
17
|
+
@end_date ||= respond_to?(:incumbencyEndDate) ? DateTime.parse(incumbencyEndDate) : nil
|
18
|
+
end
|
19
|
+
|
20
|
+
# Checks if Grom::Node has an end date.
|
21
|
+
#
|
22
|
+
# @return [Boolean] a boolean depending on whether or not the Grom::Node has an end date.
|
23
|
+
def current?
|
24
|
+
end_date.nil?
|
25
|
+
end
|
26
|
+
|
27
|
+
# Alias houseIncumbencyHasHouse with fallback.
|
28
|
+
#
|
29
|
+
# @return [Grom::Node, nil] the house of the Grom::Node or nil.
|
30
|
+
def house
|
31
|
+
respond_to?(:houseIncumbencyHasHouse) ? houseIncumbencyHasHouse.first : nil
|
32
|
+
end
|
33
|
+
|
34
|
+
# Alias incumbencyHasMember with fallback.
|
35
|
+
#
|
36
|
+
# @return [Grom::Node, nil] the member connected to the Grom::Node or nil.
|
37
|
+
def member
|
38
|
+
respond_to?(:incumbencyHasMember) ? incumbencyHasMember.first : nil
|
39
|
+
end
|
40
|
+
|
41
|
+
# Alias incumbencyHasContactPoint with fallback.
|
42
|
+
#
|
43
|
+
# @return [Array, Array] the contact points of the Grom::Node or an empty array.
|
44
|
+
def contact_points
|
45
|
+
respond_to?(:incumbencyHasContactPoint) ? incumbencyHasContactPoint : []
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Parliament
|
2
|
+
module Grom
|
3
|
+
module Decorator
|
4
|
+
# Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/HouseSeat
|
5
|
+
module HouseSeat
|
6
|
+
# Alias houseSeatHasHouse with fallback.
|
7
|
+
#
|
8
|
+
# @return [Grom::Node, nil] the house of the Grom::Node or nil.
|
9
|
+
def house
|
10
|
+
respond_to?(:houseSeatHasHouse) ? houseSeatHasHouse.first : nil
|
11
|
+
end
|
12
|
+
|
13
|
+
# Alias houseSeatHasConstituencyGroup with fallback.
|
14
|
+
#
|
15
|
+
# @return [Grom::Node, nil] the constituency group of the Grom::Node or nil.
|
16
|
+
def constituency
|
17
|
+
respond_to?(:houseSeatHasConstituencyGroup) ? houseSeatHasConstituencyGroup.first : nil
|
18
|
+
end
|
19
|
+
|
20
|
+
# Alias houseSeatHasSeatIncumbency with fallback.
|
21
|
+
#
|
22
|
+
# @return [Array, Array] the seat incumbencies of the Grom::Node or an empty.
|
23
|
+
def seat_incumbencies
|
24
|
+
respond_to?(:houseSeatHasSeatIncumbency) ? houseSeatHasSeatIncumbency : []
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Parliament
|
2
|
+
module Grom
|
3
|
+
module Decorator
|
4
|
+
# Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/Incumbency
|
5
|
+
module Incumbency
|
6
|
+
# Alias incumbencyStartDate with fallback.
|
7
|
+
#
|
8
|
+
# @return [DateTime, nil] the start date of the Grom::Node or nil.
|
9
|
+
def start_date
|
10
|
+
@start_date ||= respond_to?(:incumbencyStartDate) ? DateTime.parse(incumbencyStartDate) : nil
|
11
|
+
end
|
12
|
+
|
13
|
+
# Alias incumbencyEndDate with fallback.
|
14
|
+
#
|
15
|
+
# @return [DateTime, nil] the end date of the Grom::Node or nil.
|
16
|
+
def end_date
|
17
|
+
@end_date ||= respond_to?(:incumbencyEndDate) ? DateTime.parse(incumbencyEndDate) : nil
|
18
|
+
end
|
19
|
+
|
20
|
+
# Checks if Grom::Node has an end date.
|
21
|
+
#
|
22
|
+
# @return [Boolean] a boolean depending on whether or not the Grom::Node has an end date.
|
23
|
+
def current?
|
24
|
+
end_date.nil?
|
25
|
+
end
|
26
|
+
|
27
|
+
# Alias incumbencyHasMember with fallback.
|
28
|
+
#
|
29
|
+
# @return [Grom::Node, nil] the member connected to the Grom::Node or nil.
|
30
|
+
def member
|
31
|
+
respond_to?(:incumbencyHasMember) ? incumbencyHasMember.first : nil
|
32
|
+
end
|
33
|
+
|
34
|
+
# Alias incumbencyHasContactPoint with fallback.
|
35
|
+
#
|
36
|
+
# @return [Array, Array] the contact points of the Grom::Node or an empty array.
|
37
|
+
def contact_points
|
38
|
+
respond_to?(:incumbencyHasContactPoint) ? incumbencyHasContactPoint : []
|
39
|
+
end
|
40
|
+
|
41
|
+
# Alias seatIncumbencyHasHouseSeat with fallback.
|
42
|
+
#
|
43
|
+
# @return [Grom::Node, nil] the seat of the Grom::Node or nil.
|
44
|
+
def seat
|
45
|
+
respond_to?(:seatIncumbencyHasHouseSeat) ? seatIncumbencyHasHouseSeat.first : nil
|
46
|
+
end
|
47
|
+
|
48
|
+
# Alias houseIncumbencyHasHouse with fallback.
|
49
|
+
#
|
50
|
+
# @return [Grom::Node, nil] the house of the Grom::Node or nil.
|
51
|
+
def house
|
52
|
+
respond_to?(:houseIncumbencyHasHouse) ? houseIncumbencyHasHouse.first : nil
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Parliament
|
2
|
+
module Grom
|
3
|
+
module Decorator
|
4
|
+
# Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/Party
|
5
|
+
module Party
|
6
|
+
# Alias partyName with fallback.
|
7
|
+
#
|
8
|
+
# @return [String, String] the party name of the Grom::Node or an empty string.
|
9
|
+
def name
|
10
|
+
respond_to?(:partyName) ? partyName : ''
|
11
|
+
end
|
12
|
+
|
13
|
+
# Alias partyHasPartyMembership with fallback.
|
14
|
+
#
|
15
|
+
# @return [Array, Array] the party memberships of the Grom::Node or an empty array.
|
16
|
+
def party_memberships
|
17
|
+
respond_to?(:partyHasPartyMembership) ? partyHasPartyMembership : []
|
18
|
+
end
|
19
|
+
|
20
|
+
# Alias count with fallback.
|
21
|
+
#
|
22
|
+
# @return [Integer, nil] the count of members of the Grom::Node or nil.
|
23
|
+
def member_count
|
24
|
+
respond_to?(:count) ? count.to_i : nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Parliament
|
2
|
+
module Grom
|
3
|
+
module Decorator
|
4
|
+
# Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/PartyMembership
|
5
|
+
module PartyMembership
|
6
|
+
# Alias partyMembershipHasParty with fallback.
|
7
|
+
#
|
8
|
+
# @return [Grom::Node, nil] the party of the Grom::Node or nil.
|
9
|
+
def party
|
10
|
+
respond_to?(:partyMembershipHasParty) ? partyMembershipHasParty.first : nil
|
11
|
+
end
|
12
|
+
|
13
|
+
# Alias partyMembershipStartDate with fallback.
|
14
|
+
#
|
15
|
+
# @return [DateTime, nil] the start date of the Grom::Node or nil.
|
16
|
+
def start_date
|
17
|
+
@start_date ||= respond_to?(:partyMembershipStartDate) ? DateTime.parse(partyMembershipStartDate) : nil
|
18
|
+
end
|
19
|
+
|
20
|
+
# Alias partyMembershipEndDate with fallback.
|
21
|
+
#
|
22
|
+
# @return [DateTime, nil] the end date of the Grom::Node or nil.
|
23
|
+
def end_date
|
24
|
+
@end_date ||= respond_to?(:partyMembershipEndDate) ? DateTime.parse(partyMembershipEndDate) : nil
|
25
|
+
end
|
26
|
+
|
27
|
+
# Checks if Grom::Node has an end date.
|
28
|
+
#
|
29
|
+
# @return [Boolean] a boolean depending on whether or not the Grom::Node has an end date.
|
30
|
+
def current?
|
31
|
+
end_date.nil?
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,190 @@
|
|
1
|
+
module Parliament
|
2
|
+
module Grom
|
3
|
+
module Decorator
|
4
|
+
# Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/Person.
|
5
|
+
# rubocop:disable ModuleLength
|
6
|
+
module Person
|
7
|
+
# Alias personGivenName with fallback.
|
8
|
+
#
|
9
|
+
# @return [String, String] the given name of the Grom::Node or an empty string.
|
10
|
+
def given_name
|
11
|
+
respond_to?(:personGivenName) ? personGivenName : ''
|
12
|
+
end
|
13
|
+
|
14
|
+
# Alias personFamilyName with fallback.
|
15
|
+
#
|
16
|
+
# @return [String, String] the family name of the Grom::Node or an empty string.
|
17
|
+
def family_name
|
18
|
+
respond_to?(:personFamilyName) ? personFamilyName : ''
|
19
|
+
end
|
20
|
+
|
21
|
+
# Alias personOtherNames with fallback.
|
22
|
+
#
|
23
|
+
# @return [String, String] the other names of the Grom::Node or an empty string.
|
24
|
+
def other_name
|
25
|
+
respond_to?(:personOtherNames) ? personOtherNames : ''
|
26
|
+
end
|
27
|
+
|
28
|
+
# Alias personDateOfBirth with fallback.
|
29
|
+
#
|
30
|
+
# @return [DateTime, nil] the date of birth of the Grom::Node or nil.
|
31
|
+
def date_of_birth
|
32
|
+
@date_of_birth ||= respond_to?(:personDateOfBirth) ? DateTime.parse(personDateOfBirth) : nil
|
33
|
+
end
|
34
|
+
|
35
|
+
# Builds a full name using personGivenName and personFamilyName.
|
36
|
+
#
|
37
|
+
# @return [String, String] the full name of the Grom::Node or an empty string.
|
38
|
+
def full_name
|
39
|
+
return @full_name unless @full_name.nil?
|
40
|
+
|
41
|
+
full_name = []
|
42
|
+
full_name << personGivenName if respond_to?(:personGivenName)
|
43
|
+
full_name << personFamilyName if respond_to?(:personFamilyName)
|
44
|
+
|
45
|
+
@full_name = full_name.join(' ')
|
46
|
+
end
|
47
|
+
|
48
|
+
# Alias memberHasIncumbency with fallback.
|
49
|
+
#
|
50
|
+
# @return [Array, Array] all the incumbencies of the Grom::Node or an empty array.
|
51
|
+
def incumbencies
|
52
|
+
respond_to?(:memberHasIncumbency) ? memberHasIncumbency : []
|
53
|
+
end
|
54
|
+
|
55
|
+
# Alias memberHasIncumbency with fallback.
|
56
|
+
#
|
57
|
+
# @return [Array, Array] the seat incumbencies of the Grom::Node or an empty array.
|
58
|
+
def seat_incumbencies
|
59
|
+
@seat_incumbencies ||= incumbencies.select { |inc| inc.type == 'http://id.ukpds.org/schema/SeatIncumbency' }
|
60
|
+
end
|
61
|
+
|
62
|
+
# Alias memberHasIncumbency with fallback.
|
63
|
+
#
|
64
|
+
# @return [Array, Array] the house incumbencies of the Grom::Node or an empty array.
|
65
|
+
def house_incumbencies
|
66
|
+
@house_incumbencies ||= incumbencies.select { |inc| inc.type == 'http://id.ukpds.org/schema/HouseIncumbency' }
|
67
|
+
end
|
68
|
+
|
69
|
+
# Alias seatIncumbencyHasHouseSeat with fallback.
|
70
|
+
#
|
71
|
+
# @return [Array, Array] the seats of the Grom::Node or an empty array.
|
72
|
+
def seats
|
73
|
+
@seats ||= seat_incumbencies.map(&:seat).flatten.uniq.compact
|
74
|
+
end
|
75
|
+
|
76
|
+
# Alias houseSeatHasHouse with fallback.
|
77
|
+
#
|
78
|
+
# @return [Array, Array] the houses of the Grom::Node or an empty array.
|
79
|
+
def houses
|
80
|
+
@houses ||= [seats.map(&:house), house_incumbencies.map(&:house)].flatten.uniq.compact
|
81
|
+
end
|
82
|
+
|
83
|
+
# Alias houseSeatHasConstituencyGroup with fallback.
|
84
|
+
#
|
85
|
+
# @return [Array, Array] the constituencies of the Grom::Node or an empty array.
|
86
|
+
def constituencies
|
87
|
+
@constituencies ||= seats.map(&:constituency).flatten.uniq.compact
|
88
|
+
end
|
89
|
+
|
90
|
+
# Alias partyMemberHasPartyMembership with fallback.
|
91
|
+
#
|
92
|
+
# @return [Array, Array] the party memberships of the Grom::Node or an empty array.
|
93
|
+
def party_memberships
|
94
|
+
respond_to?(:partyMemberHasPartyMembership) ? partyMemberHasPartyMembership : []
|
95
|
+
end
|
96
|
+
|
97
|
+
# Alias partyMembershipHasParty with fallback.
|
98
|
+
#
|
99
|
+
# @return [Array, Array] the parties of the Grom::Node or an empty array.
|
100
|
+
def parties
|
101
|
+
@parties ||= party_memberships.map(&:party).flatten.uniq.compact
|
102
|
+
end
|
103
|
+
|
104
|
+
# Alias personHasContactPoint with fallback.
|
105
|
+
#
|
106
|
+
# @return [Array, Array] the contact points of the Grom::Node or an empty array.
|
107
|
+
def contact_points
|
108
|
+
respond_to?(:personHasContactPoint) ? personHasContactPoint : []
|
109
|
+
end
|
110
|
+
|
111
|
+
# Alias personHasGenderIdentity with fallback.
|
112
|
+
#
|
113
|
+
# @return [Array, Array] the gender identities of the Grom::Node or an empty array.
|
114
|
+
def gender_identities
|
115
|
+
respond_to?(:personHasGenderIdentity) ? personHasGenderIdentity : []
|
116
|
+
end
|
117
|
+
|
118
|
+
# Alias genderIdentityHasGender with fallback.
|
119
|
+
#
|
120
|
+
# @return [Array, Array] the gender of the Grom::Node or nil.
|
121
|
+
def gender
|
122
|
+
gender_identities.empty? ? nil : gender_identities.first.gender
|
123
|
+
end
|
124
|
+
|
125
|
+
# Checks the statuses of the Grom::Node.
|
126
|
+
#
|
127
|
+
# @return [Hash, Hash] the statuses of the Grom::Node or an empty hash.
|
128
|
+
def statuses
|
129
|
+
return @statuses unless @statuses.nil?
|
130
|
+
|
131
|
+
statuses = {}
|
132
|
+
statuses[:house_membership_status] = house_membership_status
|
133
|
+
statuses[:general_membership_status] = general_membership_status
|
134
|
+
|
135
|
+
@statuses = statuses
|
136
|
+
end
|
137
|
+
|
138
|
+
# Alias D79B0BAC513C4A9A87C9D5AFF1FC632F with fallback.
|
139
|
+
#
|
140
|
+
# @return [String, String] the full title of the Grom::Node or an empty string.
|
141
|
+
def full_title
|
142
|
+
respond_to?(:D79B0BAC513C4A9A87C9D5AFF1FC632F) ? self.D79B0BAC513C4A9A87C9D5AFF1FC632F : ''
|
143
|
+
end
|
144
|
+
|
145
|
+
# Alias F31CBD81AD8343898B49DC65743F0BDF with fallback.
|
146
|
+
#
|
147
|
+
# @return [String, String] the display name of the Grom::Node or the full name.
|
148
|
+
def display_name
|
149
|
+
respond_to?(:F31CBD81AD8343898B49DC65743F0BDF) ? self.F31CBD81AD8343898B49DC65743F0BDF : full_name
|
150
|
+
end
|
151
|
+
|
152
|
+
# Alias A5EE13ABE03C4D3A8F1A274F57097B6C with fallback.
|
153
|
+
#
|
154
|
+
# @return [String, String] the sort name of the Grom::Node or an empty string.
|
155
|
+
def sort_name
|
156
|
+
respond_to?(:A5EE13ABE03C4D3A8F1A274F57097B6C) ? self.A5EE13ABE03C4D3A8F1A274F57097B6C : ''
|
157
|
+
end
|
158
|
+
|
159
|
+
private
|
160
|
+
|
161
|
+
def house_membership_status
|
162
|
+
no_current_seat_incumbency = seat_incumbencies.select(&:current?).empty?
|
163
|
+
no_current_house_incumbency = house_incumbencies.select(&:current?).empty?
|
164
|
+
former_lord = (!house_incumbencies.empty? && no_current_house_incumbency)
|
165
|
+
former_mp = (!seat_incumbencies.empty? && no_current_seat_incumbency)
|
166
|
+
|
167
|
+
build_house_membership_status(no_current_seat_incumbency, no_current_house_incumbency, former_lord, former_mp)
|
168
|
+
end
|
169
|
+
|
170
|
+
# TODO: Convert hard-coded strings to language file values
|
171
|
+
def build_house_membership_status(no_current_seat_incumbency, no_current_house_incumbency, former_lord, former_mp)
|
172
|
+
statuses = []
|
173
|
+
statuses << 'Current MP' unless no_current_seat_incumbency
|
174
|
+
statuses << 'Member of the House of Lords' unless no_current_house_incumbency
|
175
|
+
statuses << 'Former Member of the House of Lords' if former_lord
|
176
|
+
statuses << 'Former MP' if former_mp
|
177
|
+
|
178
|
+
statuses
|
179
|
+
end
|
180
|
+
|
181
|
+
def general_membership_status
|
182
|
+
statuses = []
|
183
|
+
statuses << 'Current Member' unless incumbencies.select(&:current?).empty?
|
184
|
+
statuses << 'Former Member' if !incumbencies.empty? && incumbencies.select(&:current?).empty?
|
185
|
+
statuses
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Parliament
|
2
|
+
module Grom
|
3
|
+
module Decorator
|
4
|
+
# Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/PostalAddress
|
5
|
+
module PostalAddress
|
6
|
+
# Builds a full address using the lines of the address and the postcode.
|
7
|
+
#
|
8
|
+
# @return [String, String] the full address of the Grom::Node or an empty string.
|
9
|
+
def full_address
|
10
|
+
address_array.join(', ')
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def address_array
|
16
|
+
address_array = []
|
17
|
+
(1..5).each do |i|
|
18
|
+
if respond_to?("addressLine#{i}".to_sym)
|
19
|
+
address_array << instance_variable_get("@addressLine#{i}".to_sym)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
address_array << postCode if respond_to?(:postCode)
|
23
|
+
address_array
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Parliament
|
2
|
+
module Grom
|
3
|
+
module Decorator
|
4
|
+
# Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/SeatIncumbency
|
5
|
+
module SeatIncumbency
|
6
|
+
# Alias incumbencyStartDate with fallback.
|
7
|
+
#
|
8
|
+
# @return [DateTime, nil] the start date of the Grom::Node or nil.
|
9
|
+
def start_date
|
10
|
+
respond_to?(:incumbencyStartDate) ? DateTime.parse(incumbencyStartDate) : nil
|
11
|
+
end
|
12
|
+
|
13
|
+
# Alias incumbencyEndDate with fallback.
|
14
|
+
#
|
15
|
+
# @return [DateTime, nil] the end date of the Grom::Node or nil.
|
16
|
+
def end_date
|
17
|
+
respond_to?(:incumbencyEndDate) ? DateTime.parse(incumbencyEndDate) : nil
|
18
|
+
end
|
19
|
+
|
20
|
+
# Alias seatIncumbencyHasHouseSeat with fallback.
|
21
|
+
#
|
22
|
+
# @return [Grom::Node, nil] the seat of the Grom::Node or nil.
|
23
|
+
def seat
|
24
|
+
respond_to?(:seatIncumbencyHasHouseSeat) ? seatIncumbencyHasHouseSeat.first : nil
|
25
|
+
end
|
26
|
+
|
27
|
+
# Checks if Grom::Node has no end date.
|
28
|
+
#
|
29
|
+
# @return [Boolean] a boolean depending on whether or not the Grom::Node has an end date.
|
30
|
+
def current?
|
31
|
+
!former?
|
32
|
+
end
|
33
|
+
|
34
|
+
# Checks if Grom::Node has an end date.
|
35
|
+
#
|
36
|
+
# @return [Boolean] a boolean depending on whether or not the Grom::Node has an end date.
|
37
|
+
def former?
|
38
|
+
respond_to?(:incumbencyEndDate)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Alias houseSeatHasHouse with fallback.
|
42
|
+
#
|
43
|
+
# @return [Grom::Node, nil] the house of the Grom::Node or nil.
|
44
|
+
def house
|
45
|
+
seat.nil? ? nil : seat.house
|
46
|
+
end
|
47
|
+
|
48
|
+
# Alias houseSeatHasConstituencyGroup with fallback.
|
49
|
+
#
|
50
|
+
# @return [Grom::Node, nil] the constituency of the Grom::Node or nil.
|
51
|
+
def constituency
|
52
|
+
seat.nil? ? nil : seat.constituency
|
53
|
+
end
|
54
|
+
|
55
|
+
# Alias incumbencyHasContactPoint with fallback.
|
56
|
+
#
|
57
|
+
# @return [Array, Array] the contact points of the Grom::Node or an empty array.
|
58
|
+
def contact_points
|
59
|
+
respond_to?(:incumbencyHasContactPoint) ? incumbencyHasContactPoint : []
|
60
|
+
end
|
61
|
+
|
62
|
+
# Alias incumbencyHasMember with fallback.
|
63
|
+
#
|
64
|
+
# @return [Grom::Node, nil] the member connected to the Grom::Node or nil.
|
65
|
+
def member
|
66
|
+
respond_to?(:incumbencyHasMember) ? incumbencyHasMember.first : nil
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'parliament/grom/decorator/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'parliament-grom-decorators'
|
8
|
+
spec.version = Parliament::Grom::Decorator::VERSION
|
9
|
+
spec.authors = ['Rebecca Appleyard']
|
10
|
+
spec.email = ['rklappleyard@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = %q{Parliamentary Grom decorator}
|
13
|
+
spec.description = %q{Parliamentary Grom decorator}
|
14
|
+
spec.homepage = 'http://github.com/ukparliament/parliament_grom_decorators'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = 'exe'
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ['lib']
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.14'
|
24
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
25
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
26
|
+
spec.add_development_dependency 'rubocop', '~> 0.47'
|
27
|
+
spec.add_development_dependency 'simplecov', '~> 0.12'
|
28
|
+
spec.add_development_dependency 'vcr', '~> 3.0'
|
29
|
+
spec.add_development_dependency 'webmock', '~> 2.3'
|
30
|
+
# spec.add_development_dependency 'parliament-ntriple'
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: parliament-grom-decorators
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.pre
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rebecca Appleyard
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-04-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.14'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.14'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.47'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.47'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.12'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.12'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: vcr
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: webmock
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '2.3'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '2.3'
|
111
|
+
description: Parliamentary Grom decorator
|
112
|
+
email:
|
113
|
+
- rklappleyard@gmail.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- ".hound.yml"
|
120
|
+
- ".rspec"
|
121
|
+
- ".rubocop.yml"
|
122
|
+
- ".travis.yml"
|
123
|
+
- CODE_OF_CONDUCT.md
|
124
|
+
- Gemfile
|
125
|
+
- LICENSE
|
126
|
+
- README.md
|
127
|
+
- Rakefile
|
128
|
+
- bin/console
|
129
|
+
- bin/setup
|
130
|
+
- lib/parliament/grom/decorator.rb
|
131
|
+
- lib/parliament/grom/decorator/constituency_area.rb
|
132
|
+
- lib/parliament/grom/decorator/constituency_group.rb
|
133
|
+
- lib/parliament/grom/decorator/contact_point.rb
|
134
|
+
- lib/parliament/grom/decorator/gender.rb
|
135
|
+
- lib/parliament/grom/decorator/gender_identity.rb
|
136
|
+
- lib/parliament/grom/decorator/house.rb
|
137
|
+
- lib/parliament/grom/decorator/house_incumbency.rb
|
138
|
+
- lib/parliament/grom/decorator/house_seat.rb
|
139
|
+
- lib/parliament/grom/decorator/incumbency.rb
|
140
|
+
- lib/parliament/grom/decorator/party.rb
|
141
|
+
- lib/parliament/grom/decorator/party_membership.rb
|
142
|
+
- lib/parliament/grom/decorator/person.rb
|
143
|
+
- lib/parliament/grom/decorator/postal_address.rb
|
144
|
+
- lib/parliament/grom/decorator/seat_incumbency.rb
|
145
|
+
- lib/parliament/grom/decorator/version.rb
|
146
|
+
- parliament-grom-decorators.gemspec
|
147
|
+
homepage: http://github.com/ukparliament/parliament_grom_decorators
|
148
|
+
licenses: []
|
149
|
+
metadata: {}
|
150
|
+
post_install_message:
|
151
|
+
rdoc_options: []
|
152
|
+
require_paths:
|
153
|
+
- lib
|
154
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - ">="
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
159
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
|
+
requirements:
|
161
|
+
- - ">"
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: 1.3.1
|
164
|
+
requirements: []
|
165
|
+
rubyforge_project:
|
166
|
+
rubygems_version: 2.6.6
|
167
|
+
signing_key:
|
168
|
+
specification_version: 4
|
169
|
+
summary: Parliamentary Grom decorator
|
170
|
+
test_files: []
|