angus-remote 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MjE0YTVkY2ZmYzYxNjZjMWU5MTFmMTRhYTk2ODRiNzRhNDlkOGFiNg==
5
+ data.tar.gz: !binary |-
6
+ MzM4NTVkMzljY2QwN2Q3MTJiOWMwODI1MWNmYjJhYWI0ODVlYTMzNA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NWVhYWFjMWY2NzA2NGI1Nzc5ZTEzNDBiNzVmOTYwYzhlMTdkOGJjOGFmMGZl
10
+ ZTM2MTg5MTdjOGIyZjc2NmU5YTUxMTg4ODAzZjIwYWJiMTYwZjM4OTJjNjhk
11
+ MzhkMzQ1ZGFjZWUzNzU1NTI1NDQzMDY2YzZiYWQyZjVmMTRjY2M=
12
+ data.tar.gz: !binary |-
13
+ ZDYwZWJiNDY2YzI2MjYzYjQ3NWI4OGNlZTBkOTMyZWZkODY0NjMwYzI4Nzc3
14
+ YzZhZjZlZmFiYjYzMTRmMmNhNTgyMDQwNTI1NzRmMTMxYzdhMzNiNTZmNGU4
15
+ Yzg4NjRjOWI3ZjEzOWZiYWE5NjMyNGYyOTU5NDQ0OTliYmJiOGM=
@@ -2,14 +2,13 @@ require 'uri'
2
2
 
3
3
  require_relative 'client'
4
4
  require_relative 'response/builder'
5
+ require_relative 'settings'
5
6
 
6
7
  module Angus
7
8
  module Remote
8
9
 
9
10
  module Builder
10
11
 
11
- DEFAULT_TIMEOUT = 60
12
-
13
12
  # Builds a client for a specific service.
14
13
  #
15
14
  # @param [String] code_name The service's name known to the service directory
@@ -42,7 +41,7 @@ module Angus
42
41
  code_name, service_definition)
43
42
  end
44
43
 
45
- remote_service_class.new(api_url, self.default_timeout, options)
44
+ remote_service_class.new(api_url, Settings.default_timeout, options)
46
45
  end
47
46
 
48
47
  def self.define_operation(client_class, namespace, operation, service_code_name,
@@ -192,14 +191,6 @@ module Angus
192
191
  encoded
193
192
  end
194
193
 
195
- def self.default_timeout
196
- @default_timeout || DEFAULT_TIMEOUT
197
- end
198
-
199
- def self.default_timeout=(default_timeout)
200
- @default_timeout = default_timeout
201
- end
202
-
203
194
  end
204
195
 
205
196
  end
@@ -22,8 +22,10 @@ module Angus
22
22
  :force_retry => false,
23
23
  :url => api_url,
24
24
 
25
+ :keep_alive => timeout,
25
26
  :read_timeout => timeout,
26
- :open_timeout => timeout
27
+ :open_timeout => timeout,
28
+ :idle_timeout => timeout
27
29
  )
28
30
 
29
31
  @api_base_path = @connection.default_path
@@ -13,12 +13,17 @@ module Angus
13
13
 
14
14
  module ServiceDirectory
15
15
 
16
- # Path to the configuration file that has the information about the
17
- # doc_url and api_url
18
- SERVICES_CONFIGURATION_FILE = 'config/services.yml'
19
-
20
16
  # Builds and returns a Client object for the service and version received
21
- def self.lookup(code_name, version = nil)
17
+ def self.lookup(*args)
18
+ if args.length == 1
19
+ definition = args.first
20
+ code_name = definition.delete(:code_name)
21
+ version = definition.delete(:version)
22
+ set_service_configuration(code_name, version, definition)
23
+ else
24
+ code_name, version = args
25
+ end
26
+
22
27
  version ||= service_version(code_name)
23
28
 
24
29
  @clients_cache ||= {}
@@ -252,14 +257,34 @@ module Angus
252
257
  #
253
258
  # @raise [ServiceConfigurationNotFound] When no configuration for the given service
254
259
  def self.service_configuration(code_name)
255
- @services_configuration ||= YAML.load_file(SERVICES_CONFIGURATION_FILE)
260
+ @services_configuration ||= load_services_configuration_file
256
261
 
257
262
  @services_configuration[code_name] or
258
263
  raise ServiceConfigurationNotFound.new(code_name)
259
264
  end
260
265
  private_class_method :service_configuration
261
266
 
262
- end
267
+ def self.set_service_configuration(code_name, version, configuration)
268
+ @services_configuration ||= load_services_configuration_file
269
+ @services_configuration[code_name] ||= {}
263
270
 
271
+ @services_configuration[code_name]["v#{version}"] = configuration.inject({}) do |config, entry|
272
+ k, v = entry
273
+ config.merge!({ k.to_s => v })
274
+ end
275
+ end
276
+ private_class_method :set_service_configuration
277
+
278
+ def self.load_services_configuration_file
279
+ return {} unless File.exists?(Settings.configuration_file)
280
+ configuration = YAML.load_file(Settings.configuration_file)
281
+
282
+ configuration = {} unless configuration.is_a?(Hash)
283
+
284
+ configuration
285
+ end
286
+ private_class_method :load_services_configuration_file
287
+
288
+ end
264
289
  end
265
290
  end
@@ -19,9 +19,11 @@ module Angus
19
19
  end
20
20
 
21
21
  DEFAULT_TIMEOUT = 60
22
+ DEFAULT_CONFIGURATION_FILE = 'config/services.yml'
22
23
 
23
24
  add_option(:default_timeout, DEFAULT_TIMEOUT)
24
25
  add_option(:redis, {})
26
+ add_option(:configuration_file, DEFAULT_CONFIGURATION_FILE)
25
27
 
26
28
  end
27
29
 
@@ -1,7 +1,7 @@
1
1
  module Angus
2
2
  module Remote
3
3
 
4
- VERSION = '0.0.8'
4
+ VERSION = '0.0.9'
5
5
 
6
6
  end
7
7
  end
@@ -8,8 +8,8 @@ describe Angus::Remote::ServiceDirectory do
8
8
 
9
9
  let(:code_name) { 'vpos' }
10
10
  let(:version) { '0.1' }
11
- let(:doc_url) { 'some_url/doc' }
12
- let(:api_url) { 'some_url/api' }
11
+ let(:doc_url) { 'http://example.com/some_url/doc' }
12
+ let(:api_url) { 'http://example.com/some_url/api' }
13
13
 
14
14
  before do
15
15
  Angus::Remote::ServiceDirectory.stub(:service_configuration => { "v#{version}" => {
@@ -17,9 +17,33 @@ describe Angus::Remote::ServiceDirectory do
17
17
  })
18
18
  end
19
19
 
20
+ describe '.lookup' do
21
+
22
+ context 'when a definition hash is given' do
23
+ before do
24
+ service_directory.stub(:fetch_remote_service_definition => {})
25
+ service_definition = Angus::SDoc::Definitions::Service.new
26
+ Angus::SDoc::DefinitionsReader.stub(:build_service_definition => service_definition)
27
+ end
28
+
29
+ it 'returns the service definition' do
30
+ service_directory.lookup(
31
+ { :code_name => code_name, :version => version, :doc_url => version, :api_url => version}
32
+ ).should be_kind_of(Angus::Remote::Client)
33
+ end
34
+ end
35
+
36
+ context 'when the code name and version are given' do
37
+ it 'returns the service definition' do
38
+ service_directory.lookup(code_name, version).should be_kind_of(Angus::Remote::Client)
39
+ end
40
+ end
41
+
42
+ end
43
+
20
44
  describe '.get_service_definition' do
21
45
 
22
- let(:service_definition){ double(:service_definition)}
46
+ let(:service_definition) { Angus::SDoc::Definitions::Service.new }
23
47
 
24
48
  context 'when a file url' do
25
49
  let(:doc_url) { 'file://path/to/doc' }
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: angus-remote
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
5
- prerelease:
4
+ version: 0.0.9
6
5
  platform: ruby
7
6
  authors:
8
7
  - Adrian Gomez
@@ -10,34 +9,31 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-12-30 00:00:00.000000000 Z
12
+ date: 2014-06-02 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: angus-sdoc
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
18
  - - ~>
21
19
  - !ruby/object:Gem::Version
22
20
  version: '0.0'
23
21
  - - ! '>='
24
22
  - !ruby/object:Gem::Version
25
- version: 0.0.4
23
+ version: 0.0.6
26
24
  type: :runtime
27
25
  prerelease: false
28
26
  version_requirements: !ruby/object:Gem::Requirement
29
- none: false
30
27
  requirements:
31
28
  - - ~>
32
29
  - !ruby/object:Gem::Version
33
30
  version: '0.0'
34
31
  - - ! '>='
35
32
  - !ruby/object:Gem::Version
36
- version: 0.0.4
33
+ version: 0.0.6
37
34
  - !ruby/object:Gem::Dependency
38
35
  name: persistent_http
39
36
  requirement: !ruby/object:Gem::Requirement
40
- none: false
41
37
  requirements:
42
38
  - - ~>
43
39
  - !ruby/object:Gem::Version
@@ -45,7 +41,6 @@ dependencies:
45
41
  type: :runtime
46
42
  prerelease: false
47
43
  version_requirements: !ruby/object:Gem::Requirement
48
- none: false
49
44
  requirements:
50
45
  - - ~>
51
46
  - !ruby/object:Gem::Version
@@ -53,7 +48,6 @@ dependencies:
53
48
  - !ruby/object:Gem::Dependency
54
49
  name: multipart-post
55
50
  requirement: !ruby/object:Gem::Requirement
56
- none: false
57
51
  requirements:
58
52
  - - ~>
59
53
  - !ruby/object:Gem::Version
@@ -61,7 +55,6 @@ dependencies:
61
55
  type: :runtime
62
56
  prerelease: false
63
57
  version_requirements: !ruby/object:Gem::Requirement
64
- none: false
65
58
  requirements:
66
59
  - - ~>
67
60
  - !ruby/object:Gem::Version
@@ -69,7 +62,6 @@ dependencies:
69
62
  - !ruby/object:Gem::Dependency
70
63
  name: redis
71
64
  requirement: !ruby/object:Gem::Requirement
72
- none: false
73
65
  requirements:
74
66
  - - ! '>='
75
67
  - !ruby/object:Gem::Version
@@ -77,7 +69,6 @@ dependencies:
77
69
  type: :runtime
78
70
  prerelease: false
79
71
  version_requirements: !ruby/object:Gem::Requirement
80
- none: false
81
72
  requirements:
82
73
  - - ! '>='
83
74
  - !ruby/object:Gem::Version
@@ -85,7 +76,6 @@ dependencies:
85
76
  - !ruby/object:Gem::Dependency
86
77
  name: rake
87
78
  requirement: !ruby/object:Gem::Requirement
88
- none: false
89
79
  requirements:
90
80
  - - ! '>='
91
81
  - !ruby/object:Gem::Version
@@ -93,7 +83,6 @@ dependencies:
93
83
  type: :development
94
84
  prerelease: false
95
85
  version_requirements: !ruby/object:Gem::Requirement
96
- none: false
97
86
  requirements:
98
87
  - - ! '>='
99
88
  - !ruby/object:Gem::Version
@@ -101,7 +90,6 @@ dependencies:
101
90
  - !ruby/object:Gem::Dependency
102
91
  name: fakefs
103
92
  requirement: !ruby/object:Gem::Requirement
104
- none: false
105
93
  requirements:
106
94
  - - ~>
107
95
  - !ruby/object:Gem::Version
@@ -109,7 +97,6 @@ dependencies:
109
97
  type: :development
110
98
  prerelease: false
111
99
  version_requirements: !ruby/object:Gem::Requirement
112
- none: false
113
100
  requirements:
114
101
  - - ~>
115
102
  - !ruby/object:Gem::Version
@@ -117,7 +104,6 @@ dependencies:
117
104
  - !ruby/object:Gem::Dependency
118
105
  name: rspec
119
106
  requirement: !ruby/object:Gem::Requirement
120
- none: false
121
107
  requirements:
122
108
  - - ~>
123
109
  - !ruby/object:Gem::Version
@@ -125,7 +111,6 @@ dependencies:
125
111
  type: :development
126
112
  prerelease: false
127
113
  version_requirements: !ruby/object:Gem::Requirement
128
- none: false
129
114
  requirements:
130
115
  - - ~>
131
116
  - !ruby/object:Gem::Version
@@ -133,7 +118,6 @@ dependencies:
133
118
  - !ruby/object:Gem::Dependency
134
119
  name: mock_redis
135
120
  requirement: !ruby/object:Gem::Requirement
136
- none: false
137
121
  requirements:
138
122
  - - ! '>='
139
123
  - !ruby/object:Gem::Version
@@ -141,7 +125,6 @@ dependencies:
141
125
  type: :development
142
126
  prerelease: false
143
127
  version_requirements: !ruby/object:Gem::Requirement
144
- none: false
145
128
  requirements:
146
129
  - - ! '>='
147
130
  - !ruby/object:Gem::Version
@@ -149,7 +132,6 @@ dependencies:
149
132
  - !ruby/object:Gem::Dependency
150
133
  name: simplecov
151
134
  requirement: !ruby/object:Gem::Requirement
152
- none: false
153
135
  requirements:
154
136
  - - ~>
155
137
  - !ruby/object:Gem::Version
@@ -157,7 +139,6 @@ dependencies:
157
139
  type: :development
158
140
  prerelease: false
159
141
  version_requirements: !ruby/object:Gem::Requirement
160
- none: false
161
142
  requirements:
162
143
  - - ~>
163
144
  - !ruby/object:Gem::Version
@@ -165,7 +146,6 @@ dependencies:
165
146
  - !ruby/object:Gem::Dependency
166
147
  name: simplecov-rcov
167
148
  requirement: !ruby/object:Gem::Requirement
168
- none: false
169
149
  requirements:
170
150
  - - ~>
171
151
  - !ruby/object:Gem::Version
@@ -173,7 +153,6 @@ dependencies:
173
153
  type: :development
174
154
  prerelease: false
175
155
  version_requirements: !ruby/object:Gem::Requirement
176
- none: false
177
156
  requirements:
178
157
  - - ~>
179
158
  - !ruby/object:Gem::Version
@@ -181,7 +160,6 @@ dependencies:
181
160
  - !ruby/object:Gem::Dependency
182
161
  name: simplecov-rcov-text
183
162
  requirement: !ruby/object:Gem::Requirement
184
- none: false
185
163
  requirements:
186
164
  - - ~>
187
165
  - !ruby/object:Gem::Version
@@ -189,7 +167,6 @@ dependencies:
189
167
  type: :development
190
168
  prerelease: false
191
169
  version_requirements: !ruby/object:Gem::Requirement
192
- none: false
193
170
  requirements:
194
171
  - - ~>
195
172
  - !ruby/object:Gem::Version
@@ -197,7 +174,6 @@ dependencies:
197
174
  - !ruby/object:Gem::Dependency
198
175
  name: ci_reporter
199
176
  requirement: !ruby/object:Gem::Requirement
200
- none: false
201
177
  requirements:
202
178
  - - ~>
203
179
  - !ruby/object:Gem::Version
@@ -205,7 +181,6 @@ dependencies:
205
181
  type: :development
206
182
  prerelease: false
207
183
  version_requirements: !ruby/object:Gem::Requirement
208
- none: false
209
184
  requirements:
210
185
  - - ~>
211
186
  - !ruby/object:Gem::Version
@@ -221,62 +196,61 @@ extensions: []
221
196
  extra_rdoc_files: []
222
197
  files:
223
198
  - lib/angus-remote.rb
224
- - lib/angus/unmarshalling.rb
225
- - lib/angus/remote/representation.rb
226
- - lib/angus/remote/version.rb
227
- - lib/angus/remote/http/query_params.rb
228
- - lib/angus/remote/http/multipart_methods/multipart_put.rb
199
+ - lib/angus/authentication/client.rb
200
+ - lib/angus/authentication/redis_client.rb
201
+ - lib/angus/remote/builder.rb
202
+ - lib/angus/remote/client.rb
203
+ - lib/angus/remote/exceptions.rb
204
+ - lib/angus/remote/http/multipart.rb
229
205
  - lib/angus/remote/http/multipart_methods/multipart_base.rb
230
206
  - lib/angus/remote/http/multipart_methods/multipart_post.rb
231
- - lib/angus/remote/http/multipart.rb
207
+ - lib/angus/remote/http/multipart_methods/multipart_put.rb
208
+ - lib/angus/remote/http/query_params.rb
232
209
  - lib/angus/remote/message.rb
233
- - lib/angus/remote/settings.rb
234
- - lib/angus/remote/builder.rb
210
+ - lib/angus/remote/proxy_client.rb
235
211
  - lib/angus/remote/proxy_client_utils.rb
212
+ - lib/angus/remote/remote_response.rb
213
+ - lib/angus/remote/representation.rb
236
214
  - lib/angus/remote/response/builder.rb
237
- - lib/angus/remote/response/serializer.rb
238
215
  - lib/angus/remote/response/hash.rb
216
+ - lib/angus/remote/response/serializer.rb
239
217
  - lib/angus/remote/service_directory.rb
240
- - lib/angus/remote/remote_response.rb
241
- - lib/angus/remote/exceptions.rb
242
- - lib/angus/remote/client.rb
243
- - lib/angus/remote/proxy_client.rb
218
+ - lib/angus/remote/settings.rb
244
219
  - lib/angus/remote/utils.rb
245
- - lib/angus/authentication/redis_client.rb
246
- - lib/angus/authentication/client.rb
247
- - spec/angus/remote/service_directory_spec.rb
248
- - spec/angus/remote/proxy_client_utils_spec.rb
249
- - spec/angus/remote/http/query_params_spec.rb
250
- - spec/angus/remote/http/multipart_spec.rb
220
+ - lib/angus/remote/version.rb
221
+ - lib/angus/unmarshalling.rb
222
+ - spec/angus/remote/builder_spec.rb
223
+ - spec/angus/remote/client_spec.rb
251
224
  - spec/angus/remote/http/multipart_methods/multipart_base_spec.rb
252
- - spec/angus/remote/utils_spec.rb
225
+ - spec/angus/remote/http/multipart_spec.rb
226
+ - spec/angus/remote/http/query_params_spec.rb
227
+ - spec/angus/remote/proxy_client_utils_spec.rb
253
228
  - spec/angus/remote/response/builder_spec.rb
254
- - spec/angus/remote/client_spec.rb
255
- - spec/angus/remote/builder_spec.rb
229
+ - spec/angus/remote/service_directory_spec.rb
230
+ - spec/angus/remote/utils_spec.rb
256
231
  homepage: http://mooveit.github.io/angus-remote
257
232
  licenses:
258
233
  - MIT
234
+ metadata: {}
259
235
  post_install_message:
260
236
  rdoc_options: []
261
237
  require_paths:
262
238
  - lib
263
239
  required_ruby_version: !ruby/object:Gem::Requirement
264
- none: false
265
240
  requirements:
266
241
  - - ! '>='
267
242
  - !ruby/object:Gem::Version
268
243
  version: '0'
269
244
  required_rubygems_version: !ruby/object:Gem::Requirement
270
- none: false
271
245
  requirements:
272
246
  - - ! '>='
273
247
  - !ruby/object:Gem::Version
274
248
  version: '0'
275
249
  requirements: []
276
250
  rubyforge_project:
277
- rubygems_version: 1.8.25
251
+ rubygems_version: 2.2.2
278
252
  signing_key:
279
- specification_version: 3
253
+ specification_version: 4
280
254
  summary: Client for building service objects.
281
255
  test_files:
282
256
  - spec/angus/remote/service_directory_spec.rb