parliament-ruby 0.5.17 → 0.5.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/Rakefile +6 -0
- data/lib/parliament/decorators/person.rb +1 -5
- data/lib/parliament/response.rb +8 -11
- data/lib/parliament/utils.rb +35 -0
- data/lib/parliament/version.rb +1 -1
- data/lib/parliament.rb +1 -0
- metadata +4 -3
- data/Makefile +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3501f4829d180b5911b6c708883ea068a9f6fb6
|
4
|
+
data.tar.gz: c9b7f748e43e0ab6030e0b26bf4fee33937d5742
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88f09fafba3a44800dffd57f58011e9c7eb3ba1ad9fb9cad43bf1fd3e0d816ce70c00d3b5b270c87f21ad6c0eae4d92c389cd095a2f71bbc1eedf3de6158e0c4
|
7
|
+
data.tar.gz: e8f14118976032573c758784e8ed0024a3cc19e4098fc90dba076402a059924bacf8ca40d81e4bf097d564e7fcf7401a4a4c0738861dd87941edc676c3cebc92
|
data/README.md
CHANGED
@@ -72,7 +72,7 @@ Parliament::Request.new.base_url #=> 'http://example.com'
|
|
72
72
|
### Building an 'endpoint'
|
73
73
|
Now that we have a `base_url` set, we will want to build an 'endpoint' such as: `http://test.com/parties/current`.
|
74
74
|
|
75
|
-
An endpoint is effectively just a full URL to an n-triple file on a remote server
|
75
|
+
An endpoint is effectively just a full URL to an n-triple file on a remote server.
|
76
76
|
|
77
77
|
Building an endpoint is simple, once you have a Parliament::Request object, you do something like this:
|
78
78
|
```ruby
|
data/Rakefile
ADDED
@@ -25,11 +25,7 @@ module Parliament
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def incumbencies
|
28
|
-
|
29
|
-
memberHasIncumbency.select { |inc| inc.type == 'http://id.ukpds.org/schema/Incumbency' }
|
30
|
-
else
|
31
|
-
[]
|
32
|
-
end
|
28
|
+
respond_to?(:memberHasIncumbency) ? memberHasIncumbency : []
|
33
29
|
end
|
34
30
|
|
35
31
|
def seat_incumbencies
|
data/lib/parliament/response.rb
CHANGED
@@ -36,20 +36,17 @@ module Parliament
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def sort_by(*parameters)
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
parameters.map do |param|
|
44
|
-
node.send(param).is_a?(String) ? I18n.transliterate(node.send(param)).downcase : node.send(param)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
rejected.concat(grom_nodes)
|
39
|
+
Parliament::Utils.sort_by({
|
40
|
+
list: @nodes,
|
41
|
+
parameters: parameters
|
42
|
+
})
|
49
43
|
end
|
50
44
|
|
51
45
|
def reverse_sort_by(*parameters)
|
52
|
-
|
46
|
+
Parliament::Utils.reverse_sort_by({
|
47
|
+
list: @nodes,
|
48
|
+
parameters: parameters
|
49
|
+
})
|
53
50
|
end
|
54
51
|
end
|
55
52
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Parliament
|
2
|
+
module Utils
|
3
|
+
def self.sort_by(args)
|
4
|
+
rejected = []
|
5
|
+
args = sort_defaults.merge(args)
|
6
|
+
list = args[:list].dup
|
7
|
+
parameters = args[:parameters]
|
8
|
+
|
9
|
+
list.delete_if do |object|
|
10
|
+
rejected << object unless parameters.all? { |param| !object.send(param).nil? if object.respond_to?(param) }
|
11
|
+
end
|
12
|
+
|
13
|
+
list.sort_by! do |object|
|
14
|
+
parameters.map do |param|
|
15
|
+
object.send(param).is_a?(String) ? I18n.transliterate(object.send(param)).downcase : object.send(param)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Any rejected (nil) values will be added to the start of the result unless specified otherwise
|
20
|
+
args[:prepend_rejected] ? rejected.concat(list) : list.concat(rejected)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.reverse_sort_by(args)
|
24
|
+
Parliament::Utils.sort_by(args).reverse!
|
25
|
+
end
|
26
|
+
|
27
|
+
private_class_method
|
28
|
+
|
29
|
+
def self.sort_defaults
|
30
|
+
{
|
31
|
+
prepend_rejected: true
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/parliament/version.rb
CHANGED
data/lib/parliament.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parliament-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Rayner
|
@@ -138,8 +138,8 @@ files:
|
|
138
138
|
- CODE_OF_CONDUCT.md
|
139
139
|
- Gemfile
|
140
140
|
- LICENSE
|
141
|
-
- Makefile
|
142
141
|
- README.md
|
142
|
+
- Rakefile
|
143
143
|
- bin/console
|
144
144
|
- bin/setup
|
145
145
|
- lib/parliament.rb
|
@@ -160,6 +160,7 @@ files:
|
|
160
160
|
- lib/parliament/no_content_error.rb
|
161
161
|
- lib/parliament/request.rb
|
162
162
|
- lib/parliament/response.rb
|
163
|
+
- lib/parliament/utils.rb
|
163
164
|
- lib/parliament/version.rb
|
164
165
|
- parliament-ruby.gemspec
|
165
166
|
homepage: http://github.com/ukparliament/parliament_ruby
|
@@ -182,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
183
|
version: '0'
|
183
184
|
requirements: []
|
184
185
|
rubyforge_project:
|
185
|
-
rubygems_version: 2.
|
186
|
+
rubygems_version: 2.6.6
|
186
187
|
signing_key:
|
187
188
|
specification_version: 4
|
188
189
|
summary: Internal parliamentary data API wrapper for ruby
|