gds-api-adapters 1.1.0 → 1.3.0

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.
@@ -12,6 +12,7 @@ module GdsApi
12
12
  @kind = options[:kind] || 'custom-application'
13
13
  @panopticon = options[:panopticon]
14
14
  @platform = options[:platform] || Plek.current.environment
15
+ @timeout = options[:timeout] || 10
15
16
  end
16
17
 
17
18
  def record_to_artefact(record)
@@ -59,7 +60,7 @@ module GdsApi
59
60
 
60
61
  def panopticon
61
62
  options = {
62
- timeout: 5
63
+ timeout: @timeout
63
64
  }
64
65
  @panopticon ||= GdsApi::Panopticon.new(@platform, options.merge(panopticon_api_credentials))
65
66
  end
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '1.1.0'
2
+ VERSION = '1.3.0'
3
3
  end
@@ -0,0 +1,55 @@
1
+ require_relative 'test_helper'
2
+ require 'gds_api/panopticon'
3
+
4
+ describe GdsApi::Panopticon::Registerer do
5
+
6
+
7
+ describe "creating an instance of the panopticon client" do
8
+ describe "setting the platform" do
9
+ it "should create an instance using the current Plek environment as the platform by default" do
10
+ Plek.stubs(:current).returns(stub(environment: "Something"))
11
+
12
+ GdsApi::Panopticon.expects(:new).with("Something", anything()).returns(:panopticon_instance)
13
+ r = GdsApi::Panopticon::Registerer.new({})
14
+ assert_equal :panopticon_instance, r.send(:panopticon)
15
+ end
16
+
17
+ it "should allow overriding the platform" do
18
+ Plek.stubs(:current).returns(stub(environment: "Something"))
19
+
20
+ GdsApi::Panopticon.expects(:new).with("Something_else", anything()).returns(:panopticon_instance)
21
+ r = GdsApi::Panopticon::Registerer.new({platform: "Something_else"})
22
+ assert_equal :panopticon_instance, r.send(:panopticon)
23
+ end
24
+ end
25
+
26
+ describe "setting other options" do
27
+ it "should create an instance with a default timeout of 10 seconds" do
28
+ GdsApi::Panopticon.expects(:new).with(anything(), {timeout: 10}).returns(:panopticon_instance)
29
+ r = GdsApi::Panopticon::Registerer.new({})
30
+ assert_equal :panopticon_instance, r.send(:panopticon)
31
+ end
32
+
33
+ it "should allow overriding the timeout" do
34
+ GdsApi::Panopticon.expects(:new).with(anything(), {timeout: 15}).returns(:panopticon_instance)
35
+ r = GdsApi::Panopticon::Registerer.new({timeout: 15})
36
+ assert_equal :panopticon_instance, r.send(:panopticon)
37
+ end
38
+
39
+ it "shoule merge in the api credentials" do
40
+ GdsApi::Panopticon::Registerer.any_instance.stubs(:panopticon_api_credentials).returns({foo: "Bar", baz: "kablooie"})
41
+ GdsApi::Panopticon.expects(:new).with(anything(), {timeout: 10, foo: "Bar", baz: "kablooie"}).returns(:panopticon_instance)
42
+ r = GdsApi::Panopticon::Registerer.new({})
43
+ assert_equal :panopticon_instance, r.send(:panopticon)
44
+ end
45
+ end
46
+
47
+ it "should memoize the panopticon instance" do
48
+ GdsApi::Panopticon.expects(:new).once.returns(:panopticon_instance)
49
+ r = GdsApi::Panopticon::Registerer.new({})
50
+
51
+ assert_equal :panopticon_instance, r.send(:panopticon)
52
+ assert_equal :panopticon_instance, r.send(:panopticon)
53
+ end
54
+ end
55
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: gds-api-adapters
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.1.0
5
+ version: 1.3.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - James Stewart
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-08-23 00:00:00 Z
13
+ date: 2012-08-31 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: plek
@@ -46,8 +46,19 @@ dependencies:
46
46
  prerelease: false
47
47
  version_requirements: *id003
48
48
  - !ruby/object:Gem::Dependency
49
- name: rake
49
+ name: rdoc
50
50
  requirement: &id004 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - "="
54
+ - !ruby/object:Gem::Version
55
+ version: "3.12"
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: *id004
59
+ - !ruby/object:Gem::Dependency
60
+ name: rake
61
+ requirement: &id005 !ruby/object:Gem::Requirement
51
62
  none: false
52
63
  requirements:
53
64
  - - ~>
@@ -55,10 +66,10 @@ dependencies:
55
66
  version: 0.9.2.2
56
67
  type: :development
57
68
  prerelease: false
58
- version_requirements: *id004
69
+ version_requirements: *id005
59
70
  - !ruby/object:Gem::Dependency
60
71
  name: webmock
61
- requirement: &id005 !ruby/object:Gem::Requirement
72
+ requirement: &id006 !ruby/object:Gem::Requirement
62
73
  none: false
63
74
  requirements:
64
75
  - - ~>
@@ -66,10 +77,10 @@ dependencies:
66
77
  version: "1.8"
67
78
  type: :development
68
79
  prerelease: false
69
- version_requirements: *id005
80
+ version_requirements: *id006
70
81
  - !ruby/object:Gem::Dependency
71
82
  name: mocha
72
- requirement: &id006 !ruby/object:Gem::Requirement
83
+ requirement: &id007 !ruby/object:Gem::Requirement
73
84
  none: false
74
85
  requirements:
75
86
  - - ~>
@@ -77,10 +88,10 @@ dependencies:
77
88
  version: 0.10.0
78
89
  type: :development
79
90
  prerelease: false
80
- version_requirements: *id006
91
+ version_requirements: *id007
81
92
  - !ruby/object:Gem::Dependency
82
93
  name: minitest
83
- requirement: &id007 !ruby/object:Gem::Requirement
94
+ requirement: &id008 !ruby/object:Gem::Requirement
84
95
  none: false
85
96
  requirements:
86
97
  - - ~>
@@ -88,10 +99,10 @@ dependencies:
88
99
  version: 2.10.0
89
100
  type: :development
90
101
  prerelease: false
91
- version_requirements: *id007
102
+ version_requirements: *id008
92
103
  - !ruby/object:Gem::Dependency
93
104
  name: rack
94
- requirement: &id008 !ruby/object:Gem::Requirement
105
+ requirement: &id009 !ruby/object:Gem::Requirement
95
106
  none: false
96
107
  requirements:
97
108
  - - ">="
@@ -99,10 +110,10 @@ dependencies:
99
110
  version: "0"
100
111
  type: :development
101
112
  prerelease: false
102
- version_requirements: *id008
113
+ version_requirements: *id009
103
114
  - !ruby/object:Gem::Dependency
104
115
  name: simplecov
105
- requirement: &id009 !ruby/object:Gem::Requirement
116
+ requirement: &id010 !ruby/object:Gem::Requirement
106
117
  none: false
107
118
  requirements:
108
119
  - - ~>
@@ -110,10 +121,10 @@ dependencies:
110
121
  version: 0.5.4
111
122
  type: :development
112
123
  prerelease: false
113
- version_requirements: *id009
124
+ version_requirements: *id010
114
125
  - !ruby/object:Gem::Dependency
115
126
  name: simplecov-rcov
116
- requirement: &id010 !ruby/object:Gem::Requirement
127
+ requirement: &id011 !ruby/object:Gem::Requirement
117
128
  none: false
118
129
  requirements:
119
130
  - - ">="
@@ -121,10 +132,10 @@ dependencies:
121
132
  version: "0"
122
133
  type: :development
123
134
  prerelease: false
124
- version_requirements: *id010
135
+ version_requirements: *id011
125
136
  - !ruby/object:Gem::Dependency
126
137
  name: gem_publisher
127
- requirement: &id011 !ruby/object:Gem::Requirement
138
+ requirement: &id012 !ruby/object:Gem::Requirement
128
139
  none: false
129
140
  requirements:
130
141
  - - ~>
@@ -132,7 +143,7 @@ dependencies:
132
143
  version: 1.1.1
133
144
  type: :development
134
145
  prerelease: false
135
- version_requirements: *id011
146
+ version_requirements: *id012
136
147
  description: A set of adapters providing easy access to the GDS gov.uk APIs
137
148
  email:
138
149
  - jystewart@gmail.com
@@ -143,38 +154,39 @@ extensions: []
143
154
  extra_rdoc_files: []
144
155
 
145
156
  files:
146
- - lib/gds_api/version.rb
147
- - lib/gds_api/publisher.rb
148
- - lib/gds_api/panopticon/registerer.rb
149
- - lib/gds_api/typhoeus_client.rb
150
- - lib/gds_api/imminence.rb
151
- - lib/gds_api/contactotron.rb
152
- - lib/gds_api/test_helpers/publisher.rb
153
- - lib/gds_api/test_helpers/imminence.rb
157
+ - lib/gds_api/licence_application.rb
154
158
  - lib/gds_api/test_helpers/contactotron.rb
155
- - lib/gds_api/test_helpers/panopticon.rb
156
159
  - lib/gds_api/test_helpers/json_client_helper.rb
157
- - lib/gds_api/licence_application.rb
158
- - lib/gds_api/base.rb
159
- - lib/gds_api/json_client.rb
160
- - lib/gds_api/response.rb
161
- - lib/gds_api/panopticon.rb
162
- - lib/gds_api/core-ext/openstruct.rb
163
- - lib/gds_api/oauth2_client.rb
160
+ - lib/gds_api/test_helpers/publisher.rb
161
+ - lib/gds_api/test_helpers/panopticon.rb
162
+ - lib/gds_api/test_helpers/imminence.rb
164
163
  - lib/gds_api/part_methods.rb
165
164
  - lib/gds_api/needotron.rb
165
+ - lib/gds_api/typhoeus_client.rb
166
+ - lib/gds_api/json_client.rb
167
+ - lib/gds_api/contactotron.rb
168
+ - lib/gds_api/oauth2_client.rb
169
+ - lib/gds_api/response.rb
170
+ - lib/gds_api/panopticon/registerer.rb
171
+ - lib/gds_api/publisher.rb
166
172
  - lib/gds_api/exceptions.rb
173
+ - lib/gds_api/version.rb
167
174
  - lib/gds_api/helpers.rb
175
+ - lib/gds_api/base.rb
176
+ - lib/gds_api/panopticon.rb
177
+ - lib/gds_api/core-ext/openstruct.rb
178
+ - lib/gds_api/imminence.rb
168
179
  - README.md
169
180
  - Rakefile
170
- - test/contactotron_api_test.rb
171
- - test/panopticon_api_test.rb
172
- - test/publisher_api_test.rb
173
181
  - test/imminence_api_test.rb
174
- - test/json_client_test.rb
175
- - test/gds_api_base_test.rb
182
+ - test/contactotron_api_test.rb
176
183
  - test/licence_application_api_test.rb
184
+ - test/json_client_test.rb
185
+ - test/publisher_api_test.rb
186
+ - test/panopticon_registerer_test.rb
187
+ - test/panopticon_api_test.rb
177
188
  - test/test_helper.rb
189
+ - test/gds_api_base_test.rb
178
190
  homepage: http://github.com/alphagov/gds-api-adapters
179
191
  licenses: []
180
192
 
@@ -188,7 +200,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
188
200
  requirements:
189
201
  - - ">="
190
202
  - !ruby/object:Gem::Version
191
- hash: -4250669656012288164
203
+ hash: -3021938998109675237
192
204
  segments:
193
205
  - 0
194
206
  version: "0"
@@ -197,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
209
  requirements:
198
210
  - - ">="
199
211
  - !ruby/object:Gem::Version
200
- hash: -4250669656012288164
212
+ hash: -3021938998109675237
201
213
  segments:
202
214
  - 0
203
215
  version: "0"
@@ -209,11 +221,12 @@ signing_key:
209
221
  specification_version: 3
210
222
  summary: Adapters to work with GDS APIs
211
223
  test_files:
212
- - test/contactotron_api_test.rb
213
- - test/panopticon_api_test.rb
214
- - test/publisher_api_test.rb
215
224
  - test/imminence_api_test.rb
216
- - test/json_client_test.rb
217
- - test/gds_api_base_test.rb
225
+ - test/contactotron_api_test.rb
218
226
  - test/licence_application_api_test.rb
227
+ - test/json_client_test.rb
228
+ - test/publisher_api_test.rb
229
+ - test/panopticon_registerer_test.rb
230
+ - test/panopticon_api_test.rb
219
231
  - test/test_helper.rb
232
+ - test/gds_api_base_test.rb