parliament-ruby 0.7.3.pre → 0.7.4

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: 85abecdcd5ffc39c4d3d886aa558bfad25e84ef1
4
- data.tar.gz: cdc28cf4ab1ee9fae3a19214d95fe16e2aa9565c
3
+ metadata.gz: 72c73709b14ab1591a287636e7735c9758de56da
4
+ data.tar.gz: 14aaef8e1f7233189d8f99488ea4ecfe740341a2
5
5
  SHA512:
6
- metadata.gz: 50b1146fe2b6908239916bb5fc6b7e5365a05d0a151068531375a82bfa85e45221fb457295f36c38f7335c796c74c6061461bc5d3a78b0adb990cd3b8ec5d895
7
- data.tar.gz: eb032db60e9364d06c772401e16251b52afe89222f309db76c9ba28e73f0bc8be835b3320eef09d0f56d2dc66fede8e3761656034fbbbf2600fcc7d30dd22eb1
6
+ metadata.gz: 13f59fb73e8b3078dc74b8899fd39ddf0c8d013cfb0ab8c4a005d216e275fe18ea266f10337ad46a1ff86a0be2bb17e49cb4e9f86661d9f6d028e91041e30689
7
+ data.tar.gz: cc3d3831a3a52395f0bfb979f06fcfc56f47c36d589493ca79aa25597dcac4e3da5bb7463852d3696b810410398ac0ae3e50157d231434f26164b81c79d27de8
data/Gemfile CHANGED
@@ -5,6 +5,3 @@ gemspec
5
5
 
6
6
  # Include coveralls for CI coverage reports
7
7
  gem 'coveralls', require: false
8
-
9
- gem 'pry'
10
- gem 'rb-readline'
@@ -14,7 +14,7 @@ require 'parliament/server_error'
14
14
  require 'parliament/no_content_response_error'
15
15
 
16
16
  # Namespace for classes and modules that handle connections to, and processing of data from the parliamentary API.
17
- # @since 0.0.1
17
+ # @since 0.1.0
18
18
  module Parliament
19
19
  # Currently just a namespace definition
20
20
  end
@@ -1,9 +1,8 @@
1
1
  module Parliament
2
+ # Namespace for classes and modules that processes data from http requests.
3
+ # @since 0.7.0
2
4
  module Builder
3
- require_relative '../parliament/builder/base_response_builder'
4
-
5
- require_relative '../parliament/builder/ntriple_response_builder'
6
-
7
- require_relative '../parliament/builder/open_search_response_builder'
5
+ require 'parliament/builder/base_response_builder'
6
+ require 'parliament/builder/ntriple_response_builder'
8
7
  end
9
8
  end
@@ -170,8 +170,8 @@ module Parliament
170
170
  def build_house_membership_status(no_current_seat_incumbency, no_current_house_incumbency, former_lord, former_mp)
171
171
  statuses = []
172
172
  statuses << 'Current MP' unless no_current_seat_incumbency
173
- statuses << 'Lord' unless no_current_house_incumbency
174
- statuses << 'Former Lord' if former_lord
173
+ statuses << 'Member of the House of Lords' unless no_current_house_incumbency
174
+ statuses << 'Former Member of the House of Lords' if former_lord
175
175
  statuses << 'Former MP' if former_mp
176
176
 
177
177
  statuses
@@ -1,14 +1,8 @@
1
1
  module Parliament
2
- # API request object, allowing the user to build a request to a graph-based API, download n-triple data and create
3
- # ruby objects from that data.
4
- #
5
- # @since 0.1.0
6
- #
7
- # @attr_reader [String] base_url the base url of our api. (expected: http://example.com - without the trailing slash).
8
- # @attr_reader [Hash] headers the headers being sent in the request.
2
+ # Namespace for classes and modules that handle http connections.
3
+ # @since 0.7.0
9
4
  module Request
10
- require_relative '../parliament/request/base_request'
11
- require_relative '../parliament/request/open_search_request'
12
- require_relative '../parliament/request/url_request'
5
+ require 'parliament/request/base_request'
6
+ require 'parliament/request/url_request'
13
7
  end
14
8
  end
@@ -1,3 +1,3 @@
1
1
  module Parliament
2
- VERSION = '0.7.3.pre'.freeze
2
+ VERSION = '0.7.4'.freeze
3
3
  end
@@ -20,7 +20,6 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ['lib']
22
22
 
23
- spec.add_dependency 'feedjira', '~> 2.1.2'
24
23
  spec.add_dependency 'grom', '~> 0.3.6'
25
24
 
26
25
  spec.add_development_dependency 'bundler', '~> 1.13'
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.7.3.pre
4
+ version: 0.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Rayner
@@ -10,20 +10,6 @@ bindir: exe
10
10
  cert_chain: []
11
11
  date: 2017-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: feedjira
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 2.1.2
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 2.1.2
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: grom
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -161,7 +147,6 @@ files:
161
147
  - lib/parliament/builder.rb
162
148
  - lib/parliament/builder/base_response_builder.rb
163
149
  - lib/parliament/builder/ntriple_response_builder.rb
164
- - lib/parliament/builder/open_search_response_builder.rb
165
150
  - lib/parliament/client_error.rb
166
151
  - lib/parliament/decorator.rb
167
152
  - lib/parliament/decorator/constituency_area.rb
@@ -182,7 +167,6 @@ files:
182
167
  - lib/parliament/no_content_response_error.rb
183
168
  - lib/parliament/request.rb
184
169
  - lib/parliament/request/base_request.rb
185
- - lib/parliament/request/open_search_request.rb
186
170
  - lib/parliament/request/url_request.rb
187
171
  - lib/parliament/response.rb
188
172
  - lib/parliament/server_error.rb
@@ -204,9 +188,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
204
188
  version: '0'
205
189
  required_rubygems_version: !ruby/object:Gem::Requirement
206
190
  requirements:
207
- - - ">"
191
+ - - ">="
208
192
  - !ruby/object:Gem::Version
209
- version: 1.3.1
193
+ version: '0'
210
194
  requirements: []
211
195
  rubyforge_project:
212
196
  rubygems_version: 2.6.10
@@ -1,17 +0,0 @@
1
- require 'feedjira'
2
-
3
- module Parliament
4
- module Builder
5
- class OpenSearchResponseBuilder < Parliament::Builder::BaseResponseBuilder
6
- OPEN_SEARCH_ELEMENTS = %w(totalResults Query startIndex itemsPerPage).freeze
7
-
8
- def build
9
- OPEN_SEARCH_ELEMENTS.each do |element|
10
- Feedjira::Feed.add_common_feed_element(element)
11
- end
12
-
13
- Feedjira::Feed.parse(@response.body)
14
- end
15
- end
16
- end
17
- end
@@ -1,79 +0,0 @@
1
- module Parliament
2
- module Request
3
- class OpenSearchRequest < Parliament::Request::BaseRequest
4
- require 'rexml/document'
5
-
6
- OPEN_SEARCH_PARAMETERS = {
7
- count: 10,
8
- start_index: 1,
9
- start_page: 1,
10
- language: '*',
11
- output_encoding: 'UTF-8',
12
- input_encoding: 'UTF-8'
13
- }.freeze
14
-
15
- def initialize(base_url: nil, headers: nil, builder: nil)
16
- @base_url = Parliament::Request::OpenSearchRequest.get_description(base_url) || self.class.base_url || ENV['OPENSEARCH_DESCRIPTION_URL']
17
- @open_search_parameters = self.class.open_search_parameters
18
-
19
- super(base_url: @base_url, headers: headers, builder: builder)
20
- end
21
-
22
- def get(search_params, params: nil)
23
- setup_query_url(search_params)
24
-
25
- super(params: params)
26
- end
27
-
28
- private
29
-
30
- class << self
31
- attr_reader :base_url, :open_search_parameters
32
-
33
- def base_url=(base_url)
34
- @base_url = get_description(base_url)
35
- end
36
-
37
- def open_search_parameters
38
- OPEN_SEARCH_PARAMETERS.dup
39
- end
40
-
41
- def get_description(url)
42
- return if url.nil?
43
-
44
- # Make a straight Net::HTTP request to get our description file
45
- xml_response = Parliament::Request::BaseRequest.new(
46
- base_url: url,
47
- headers: { 'Accept' => 'application/opensearchdescription+xml' }
48
- ).get
49
-
50
- # Load the description as XML
51
- xml_root = REXML::Document.new(xml_response.body).root
52
- # TODO: Check for multiple 'Url' entries.
53
- xml_root.elements['Url'].attributes['template'] # Get the URL
54
- end
55
- end
56
-
57
- def query_url
58
- @query_url
59
- end
60
-
61
- def setup_query_url(search_params)
62
- search_terms = search_params[:query]
63
- query_url = @base_url.dup
64
- query_url.gsub!('{searchTerms}', search_terms)
65
-
66
- @open_search_parameters.each do |key, value|
67
- camel_case_key = ActiveSupport::Inflector.camelize(key.to_s, false)
68
- if search_params.keys.include?(key)
69
- query_url.gsub!("{#{camel_case_key}?}", search_params[key].to_s)
70
- else
71
- query_url.gsub!("{#{camel_case_key}?}", value.to_s)
72
- end
73
- end
74
-
75
- @query_url = query_url
76
- end
77
- end
78
- end
79
- end