parliament-ruby 0.7.4 → 0.7.5.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,25 +0,0 @@
1
- module Parliament
2
- module Builder
3
- class NTripleResponseBuilder < Parliament::Builder::BaseResponseBuilder
4
- def build
5
- objects = Grom::Reader.new(@response.body).objects
6
- objects.map { |object| assign_decorator(object) }
7
-
8
- Parliament::Response.new(objects)
9
- end
10
-
11
- private
12
-
13
- def assign_decorator(object)
14
- return object unless object.respond_to?(:type)
15
-
16
- object_type = Grom::Helper.get_id(object.type)
17
-
18
- return object unless Parliament::Decorator.constants.include?(object_type.to_sym)
19
-
20
- decorator_module = Object.const_get("Parliament::Decorator::#{object_type}")
21
- object.extend(decorator_module)
22
- end
23
- end
24
- end
25
- end
@@ -1,27 +0,0 @@
1
- module Parliament
2
- # Decorator namespace
3
- module Decorator
4
- require_relative '../parliament/decorator/constituency_area'
5
- require_relative '../parliament/decorator/constituency_group'
6
-
7
- require_relative '../parliament/decorator/contact_point'
8
-
9
- require_relative '../parliament/decorator/gender'
10
- require_relative '../parliament/decorator/gender_identity'
11
-
12
- require_relative '../parliament/decorator/house'
13
- require_relative '../parliament/decorator/house_incumbency'
14
- require_relative '../parliament/decorator/house_seat'
15
-
16
- require_relative '../parliament/decorator/incumbency'
17
-
18
- require_relative '../parliament/decorator/party'
19
- require_relative '../parliament/decorator/party_membership'
20
-
21
- require_relative '../parliament/decorator/person'
22
-
23
- require_relative '../parliament/decorator/postal_address'
24
-
25
- require_relative '../parliament/decorator/seat_incumbency'
26
- end
27
- end
@@ -1,27 +0,0 @@
1
- module Parliament
2
- module Decorator
3
- # Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/ConstituencyArea
4
- module ConstituencyArea
5
- # Alias constituencyAreaLatitude with fallback.
6
- #
7
- # @return [String, String] the latitude of the Grom::Node or an empty string.
8
- def latitude
9
- respond_to?(:constituencyAreaLatitude) ? constituencyAreaLatitude : ''
10
- end
11
-
12
- # Alias constituencyAreaLongitude with fallback.
13
- #
14
- # @return [String, String] the longitude of the Grom::Node or an empty string.
15
- def longitude
16
- respond_to?(:constituencyAreaLongitude) ? constituencyAreaLongitude : ''
17
- end
18
-
19
- # Alias constituencyAreaExtent with fallback.
20
- #
21
- # @return [String, String] the polygon of the Grom::Node or an empty string.
22
- def polygon
23
- respond_to?(:constituencyAreaExtent) ? constituencyAreaExtent : ''
24
- end
25
- end
26
- end
27
- end
@@ -1,92 +0,0 @@
1
- module Parliament
2
- module Decorator
3
- # Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/ConstituencyGroup
4
- module ConstituencyGroup
5
- # Alias constituencyGroupName with fallback.
6
- #
7
- # @return [String, String] the name of the Grom::Node or an empty string.
8
- def name
9
- respond_to?(:constituencyGroupName) ? constituencyGroupName : ''
10
- end
11
-
12
- # Alias constituencyGroupStartDate with fallback.
13
- #
14
- # @return [DateTime, nil] the start date of the Grom::Node or nil.
15
- def start_date
16
- @start_date ||= respond_to?(:constituencyGroupStartDate) ? DateTime.parse(constituencyGroupStartDate) : nil
17
- end
18
-
19
- # Alias constituencyGroupEndDate with fallback.
20
- #
21
- # @return [DateTime, nil] the end date of the Grom::Node or nil.
22
- def end_date
23
- @end_date ||= respond_to?(:constituencyGroupEndDate) ? DateTime.parse(constituencyGroupEndDate) : nil
24
- end
25
-
26
- # Alias constituencyGroupHasHouseSeat with fallback.
27
- #
28
- # @return [Array, Array] the house seats of the Grom::Node or an empty array.
29
- def seats
30
- respond_to?(:constituencyGroupHasHouseSeat) ? constituencyGroupHasHouseSeat : []
31
- end
32
-
33
- # Alias houseSeatHasSeatIncumbency with fallback.
34
- #
35
- # @return [Array, Array] the seat incumbencies of the Grom::Node or an empty array.
36
- def seat_incumbencies
37
- return @seat_incumbencies unless @seat_incumbencies.nil?
38
-
39
- seat_incumbencies = []
40
- seats.each do |seat|
41
- seat_incumbencies << seat.seat_incumbencies
42
- end
43
-
44
- @seat_incumbencies = seat_incumbencies.flatten.uniq
45
- end
46
-
47
- # Alias incumbencyHasMember with fallback.
48
- #
49
- # @return [Array, Array] the members of the Grom::Node or an empty array.
50
- def members
51
- return @members unless @members .nil?
52
-
53
- members = []
54
- seat_incumbencies.each do |seat_incumbency|
55
- members << seat_incumbency.member
56
- end
57
-
58
- @members = members.flatten.uniq
59
- end
60
-
61
- # Alias constituencyGroupHasConstituencyArea with fallback.
62
- #
63
- # @return [Grom::Node, nil] a Grom::Node with type http://id.ukpds.org/schema/ConstituencyArea or nil.
64
- def area
65
- respond_to?(:constituencyGroupHasConstituencyArea) ? constituencyGroupHasConstituencyArea.first : nil
66
- end
67
-
68
- # Alias incumbencyHasContactPoint with fallback.
69
- #
70
- # @return [Array, Array] the contact points of the Grom::Node or an empty array.
71
- def contact_points
72
- return @contact_points unless @contact_points.nil?
73
-
74
- contact_points = []
75
- seat_incumbencies.each do |seat_incumbency|
76
- contact_points << seat_incumbency.contact_points
77
- end
78
-
79
- @contact_points = contact_points.flatten.uniq
80
- end
81
-
82
- # Checks if Grom::Node has an end date.
83
- #
84
- # @return [Boolean] a boolean depending on whether or not the Grom::Node has an end date.
85
- def current?
86
- has_end_date = respond_to?(:constituencyGroupEndDate)
87
-
88
- !has_end_date
89
- end
90
- end
91
- end
92
- end
@@ -1,48 +0,0 @@
1
- module Parliament
2
- module Decorator
3
- # Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/ContactPoint
4
- module ContactPoint
5
- # Alias contactPointHasPostalAddress with fallback.
6
- #
7
- # @return [Array, Array] an array of the postal addresses for the Grom::Node or an empty array.
8
- def postal_addresses
9
- respond_to?(:contactPointHasPostalAddress) ? contactPointHasPostalAddress : []
10
- end
11
-
12
- # Alias email with fallback.
13
- #
14
- # @return [String, String] the email of the Grom::Node or an empty string.
15
- def email
16
- instance_variable_get('@email'.to_sym).nil? ? '' : instance_variable_get('@email'.to_sym)
17
- end
18
-
19
- # Alias phoneNumber with fallback.
20
- #
21
- # @return [String, String] the phone number of the Grom::Node or an empty string.
22
- def phone_number
23
- respond_to?(:phoneNumber) ? phoneNumber : ''
24
- end
25
-
26
- # Alias faxNumber with fallback.
27
- #
28
- # @return [String, String] the fax number of the Grom::Node or an empty string.
29
- def fax_number
30
- respond_to?(:faxNumber) ? faxNumber : ''
31
- end
32
-
33
- # Alias contactPointHasPerson with fallback.
34
- #
35
- # @return [Array, Array] the person connected to the Grom::Node or an empty array.
36
- def person
37
- respond_to?(:contactPointHasPerson) ? contactPointHasPerson : []
38
- end
39
-
40
- # Alias contactPointHasIncumbency with fallback.
41
- #
42
- # @return [Grom::Node, nil] the incumbency of the Grom::Node or nil.
43
- def incumbency
44
- respond_to?(:contactPointHasIncumbency) ? contactPointHasIncumbency.first : nil
45
- end
46
- end
47
- end
48
- end
@@ -1,13 +0,0 @@
1
- module Parliament
2
- module Decorator
3
- # Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/Gender
4
- module Gender
5
- # Alias genderName with fallback.
6
- #
7
- # @return [String, String] the gender name of the Grom::Node or an empty string.
8
- def name
9
- respond_to?(:genderName) ? genderName : ''
10
- end
11
- end
12
- end
13
- end
@@ -1,13 +0,0 @@
1
- module Parliament
2
- module Decorator
3
- # Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/GenderIdentity
4
- module GenderIdentity
5
- # Alias genderIdentityHasGender with fallback.
6
- #
7
- # @return [Grom::Node, nil] a Grom::Node with type http://id.ukpds.org/schema/Gender or nil.
8
- def gender
9
- respond_to?(:genderIdentityHasGender) ? genderIdentityHasGender.first : nil
10
- end
11
- end
12
- end
13
- end
@@ -1,41 +0,0 @@
1
- module Parliament
2
- module Decorator
3
- # Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/House
4
- module House
5
- # Alias houseName with fallback.
6
- #
7
- # @return [String, String] the name of the Grom::Node or an empty string.
8
- def name
9
- respond_to?(:houseName) ? houseName : ''
10
- end
11
-
12
- # Alias houseSeatHasSeatIncumbency with fallback.
13
- #
14
- # @return [Array, Array] the seat incumbencies of the Grom::Node or an empty array.
15
- def seat_incumbencies
16
- return @seat_incumbencies unless @seat_incumbencies.nil?
17
-
18
- seat_incumbencies = []
19
- seats.each do |seat|
20
- seat_incumbencies << seat.seat_incumbencies
21
- end
22
-
23
- @seat_incumbencies = seat_incumbencies.flatten.uniq
24
- end
25
-
26
- # Alias houseHasHouseSeat with fallback.
27
- #
28
- # @return [Array, Array] the house seats of the Grom::Node or an empty array.
29
- def seats
30
- respond_to?(:houseHasHouseSeat) ? houseHasHouseSeat : []
31
- end
32
-
33
- # Alias houseHasHouseIncumbency with fallback.
34
- #
35
- # @return [Array, Array] the house incumbencies of the Grom::Node or an empty array.
36
- def house_incumbencies
37
- respond_to?(:houseHasHouseIncumbency) ? houseHasHouseIncumbency : []
38
- end
39
- end
40
- end
41
- end
@@ -1,48 +0,0 @@
1
- module Parliament
2
- module Decorator
3
- # Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/HouseIncumbency
4
- module HouseIncumbency
5
- # Alias incumbencyStartDate with fallback.
6
- #
7
- # @return [DateTime, nil] the start date of the Grom::Node or nil.
8
- def start_date
9
- @start_date ||= respond_to?(:incumbencyStartDate) ? DateTime.parse(incumbencyStartDate) : nil
10
- end
11
-
12
- # Alias incumbencyEndDate with fallback.
13
- #
14
- # @return [DateTime, nil] the end date of the Grom::Node or nil.
15
- def end_date
16
- @end_date ||= respond_to?(:incumbencyEndDate) ? DateTime.parse(incumbencyEndDate) : nil
17
- end
18
-
19
- # Checks if Grom::Node has an end date.
20
- #
21
- # @return [Boolean] a boolean depending on whether or not the Grom::Node has an end date.
22
- def current?
23
- end_date.nil?
24
- end
25
-
26
- # Alias houseIncumbencyHasHouse with fallback.
27
- #
28
- # @return [Grom::Node, nil] the house of the Grom::Node or nil.
29
- def house
30
- respond_to?(:houseIncumbencyHasHouse) ? houseIncumbencyHasHouse.first : nil
31
- end
32
-
33
- # Alias incumbencyHasMember with fallback.
34
- #
35
- # @return [Grom::Node, nil] the member connected to the Grom::Node or nil.
36
- def member
37
- respond_to?(:incumbencyHasMember) ? incumbencyHasMember.first : nil
38
- end
39
-
40
- # Alias incumbencyHasContactPoint with fallback.
41
- #
42
- # @return [Array, Array] the contact points of the Grom::Node or an empty array.
43
- def contact_points
44
- respond_to?(:incumbencyHasContactPoint) ? incumbencyHasContactPoint : []
45
- end
46
- end
47
- end
48
- end
@@ -1,27 +0,0 @@
1
- module Parliament
2
- module Decorator
3
- # Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/HouseSeat
4
- module HouseSeat
5
- # Alias houseSeatHasHouse with fallback.
6
- #
7
- # @return [Grom::Node, nil] the house of the Grom::Node or nil.
8
- def house
9
- respond_to?(:houseSeatHasHouse) ? houseSeatHasHouse.first : nil
10
- end
11
-
12
- # Alias houseSeatHasConstituencyGroup with fallback.
13
- #
14
- # @return [Grom::Node, nil] the constituency group of the Grom::Node or nil.
15
- def constituency
16
- respond_to?(:houseSeatHasConstituencyGroup) ? houseSeatHasConstituencyGroup.first : nil
17
- end
18
-
19
- # Alias houseSeatHasSeatIncumbency with fallback.
20
- #
21
- # @return [Array, Array] the seat incumbencies of the Grom::Node or an empty.
22
- def seat_incumbencies
23
- respond_to?(:houseSeatHasSeatIncumbency) ? houseSeatHasSeatIncumbency : []
24
- end
25
- end
26
- end
27
- end
@@ -1,55 +0,0 @@
1
- module Parliament
2
- module Decorator
3
- # Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/Incumbency
4
- module Incumbency
5
- # Alias incumbencyStartDate with fallback.
6
- #
7
- # @return [DateTime, nil] the start date of the Grom::Node or nil.
8
- def start_date
9
- @start_date ||= respond_to?(:incumbencyStartDate) ? DateTime.parse(incumbencyStartDate) : nil
10
- end
11
-
12
- # Alias incumbencyEndDate with fallback.
13
- #
14
- # @return [DateTime, nil] the end date of the Grom::Node or nil.
15
- def end_date
16
- @end_date ||= respond_to?(:incumbencyEndDate) ? DateTime.parse(incumbencyEndDate) : nil
17
- end
18
-
19
- # Checks if Grom::Node has an end date.
20
- #
21
- # @return [Boolean] a boolean depending on whether or not the Grom::Node has an end date.
22
- def current?
23
- end_date.nil?
24
- end
25
-
26
- # Alias incumbencyHasMember with fallback.
27
- #
28
- # @return [Grom::Node, nil] the member connected to the Grom::Node or nil.
29
- def member
30
- respond_to?(:incumbencyHasMember) ? incumbencyHasMember.first : nil
31
- end
32
-
33
- # Alias incumbencyHasContactPoint with fallback.
34
- #
35
- # @return [Array, Array] the contact points of the Grom::Node or an empty array.
36
- def contact_points
37
- respond_to?(:incumbencyHasContactPoint) ? incumbencyHasContactPoint : []
38
- end
39
-
40
- # Alias seatIncumbencyHasHouseSeat with fallback.
41
- #
42
- # @return [Grom::Node, nil] the seat of the Grom::Node or nil.
43
- def seat
44
- respond_to?(:seatIncumbencyHasHouseSeat) ? seatIncumbencyHasHouseSeat.first : nil
45
- end
46
-
47
- # Alias houseIncumbencyHasHouse with fallback.
48
- #
49
- # @return [Grom::Node, nil] the house of the Grom::Node or nil.
50
- def house
51
- respond_to?(:houseIncumbencyHasHouse) ? houseIncumbencyHasHouse.first : nil
52
- end
53
- end
54
- end
55
- end
@@ -1,27 +0,0 @@
1
- module Parliament
2
- module Decorator
3
- # Decorator namespace for Grom::Node instances with type: http://id.ukpds.org/schema/Party
4
- module Party
5
- # Alias partyName with fallback.
6
- #
7
- # @return [String, String] the party name of the Grom::Node or an empty string.
8
- def name
9
- respond_to?(:partyName) ? partyName : ''
10
- end
11
-
12
- # Alias partyHasPartyMembership with fallback.
13
- #
14
- # @return [Array, Array] the party memberships of the Grom::Node or an empty array.
15
- def party_memberships
16
- respond_to?(:partyHasPartyMembership) ? partyHasPartyMembership : []
17
- end
18
-
19
- # Alias count with fallback.
20
- #
21
- # @return [Integer, nil] the count of members of the Grom::Node or nil.
22
- def member_count
23
- respond_to?(:count) ? count.to_i : nil
24
- end
25
- end
26
- end
27
- end