acfs 0.37.0.1.b295 → 0.38.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.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MTg1MDkzMWYwNTJhYjMzM2QyODkyN2NmNTEyM2JkYzQ3NTYxZGQ2Yw==
5
- data.tar.gz: !binary |-
6
- OTIyZDUwMmQ4NmFmZGI3NGQ3NzQ1YjFhYjg2YzY2MzhiMzlmZjQ2Yg==
2
+ SHA1:
3
+ metadata.gz: 4c41f240bfe45822b18522601cca261151c29cf4
4
+ data.tar.gz: fb7b497921e065a03513abcbb41aa45fb490c949
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ZGI2YTRlYjZlMDIzOTdkNjBiMWU5MDJhYmZiOGRmMzRjZjVmYjdmNzdjY2Mx
10
- ZGQwYmE5ZmQ1NmMzM2Y1NDY0NDBiNzkwNzg1YWY2MDQyZWI1MDVmYTNmZTc0
11
- YzJkNmI2MDk3NDUxYWFhNDgzMTQ0MzBkYzliOTIzMDhhYzQ2YWY=
12
- data.tar.gz: !binary |-
13
- OGI0NDg1ODUzZjhlMThiZTI5ZGE3MzA5MDAzNThkNzU2MDU2NjI5N2ViYzli
14
- NjFjYjEzZTI4MmEwMGNhMThhZDI2ZmEzNDIwZWMxNmYzNmVkY2E0OTE2ZDgy
15
- NTY2MWMzNDliMTdmODlkOGQ0Y2IwZDgyODNiNmNjZmRhMDFjN2E=
6
+ metadata.gz: 443654b3e7f24db0639bcc17a7444e8d4ac8ec11ef2e09308c28a3e7e7ac4502e8c76a2a96f4b22121e832d53d0d3760d83a11e64e6c501468609c4cab37deaa
7
+ data.tar.gz: f915d55f3753f78730a18d45b9cb2e73df8d99eb50d8f26c1aff6aa26b16322980252396f566bf5e9acf8a11b0218d93fe0c6b3606344f6f073e1db3f4105fc3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.38.0
4
+
5
+ * Allow middlewares to abort request processing
6
+ * Allow middlewares to receive the request operation object (via the request)
7
+
3
8
  ## 0.37.0
4
9
 
5
10
  * Add Acfs.on
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Acfs - *API client for services*
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/acfs.png)](http://badge.fury.io/rb/acfs)
4
- [![Build Status](https://travis-ci.org/jgraichen/acfs.png?branch=master)](https://travis-ci.org/jgraichen/acfs)
5
- [![Coverage Status](https://coveralls.io/repos/jgraichen/acfs/badge.png?branch=master)](https://coveralls.io/r/jgraichen/acfs)
4
+ [![Build Status](https://travis-ci.org/jgraichen/acfs.png?branch=stable-0)](https://travis-ci.org/jgraichen/acfs)
5
+ [![Coverage Status](https://coveralls.io/repos/jgraichen/acfs/badge.png?branch=stable-0)](https://coveralls.io/r/jgraichen/acfs)
6
6
  [![Code Climate](https://codeclimate.com/github/jgraichen/acfs.png)](https://codeclimate.com/github/jgraichen/acfs)
7
7
  [![Dependency Status](https://gemnasium.com/jgraichen/acfs.png)](https://gemnasium.com/jgraichen/acfs)
8
8
  [![RubyDoc Documentation](http://b.repl.ca/v1/rubydoc-here-blue.png)](http://rubydoc.info/github/jgraichen/acfs/master/frames)
@@ -55,7 +55,8 @@ module Acfs
55
55
  end
56
56
 
57
57
  def request
58
- request = ::Acfs::Request.new url, method: method, params: params, data: data
58
+ request = ::Acfs::Request.new url, method: method, params: params,
59
+ data: data, operation: self
59
60
  request.on_complete do |response|
60
61
  ::ActiveSupport::Notifications.instrument 'acfs.operation.complete',
61
62
  operation: self,
data/lib/acfs/request.rb CHANGED
@@ -7,7 +7,7 @@ module Acfs
7
7
  #
8
8
  class Request
9
9
  attr_accessor :body, :format
10
- attr_reader :url, :headers, :params, :data, :method
10
+ attr_reader :url, :headers, :params, :data, :method, :operation
11
11
 
12
12
  include Request::Callbacks
13
13
 
@@ -19,6 +19,7 @@ module Acfs
19
19
  @params = options.delete(:params) || {}
20
20
  @method = options.delete(:method) || :get
21
21
  end.to_s
22
+ @operation = options.delete(:operation) || nil
22
23
  on_complete &block if block_given?
23
24
  end
24
25
 
data/lib/acfs/runner.rb CHANGED
@@ -81,7 +81,11 @@ module Acfs
81
81
 
82
82
  def op_request(op)
83
83
  return if Acfs::Stub.enabled? and Acfs::Stub.stubbed(op)
84
- yield prepare op.service.prepare op.request
84
+ req = op.service.prepare op.request
85
+ return unless req.is_a? Acfs::Request
86
+ req = prepare req
87
+ return unless req.is_a? Acfs::Request
88
+ yield req
85
89
  end
86
90
  end
87
91
  end
data/lib/acfs/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Acfs
2
2
  module VERSION
3
3
  MAJOR = 0
4
- MINOR = 37
4
+ MINOR = 38
5
5
  PATCH = 0
6
6
  STAGE = nil
7
7
 
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe ::Acfs::Operation do
4
+ let(:operation) { described_class.new MyUser, :read, params: {id: 0} }
5
+
6
+ context '#request' do
7
+ subject { operation.request }
8
+ its(:operation) { should eq operation }
9
+ end
10
+ end
@@ -69,4 +69,25 @@ describe ::Acfs::Runner do
69
69
  end
70
70
  end
71
71
  end
72
+
73
+ describe '#run' do
74
+ before do
75
+ expect_any_instance_of(UserService).to receive(:prepare).and_return nil
76
+ end
77
+ it 'it should not do requests when a middleware aborted' do
78
+ expect(adapter).to_not receive :run
79
+ runner.run ::Acfs::Operation.new MyUser, :read, params: {id: 0}
80
+ end
81
+ end
82
+
83
+ describe '#enqueue' do
84
+ before do
85
+ expect_any_instance_of(UserService).to receive(:prepare).and_return nil
86
+ end
87
+ it 'it should not do requests when a middleware aborted' do
88
+ expect(adapter).to_not receive :queue
89
+ runner.enqueue ::Acfs::Operation.new MyUser, :read, params: {id: 0}
90
+ runner.start
91
+ end
92
+ end
72
93
  end
metadata CHANGED
@@ -1,97 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acfs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.37.0.1.b295
4
+ version: 0.38.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Graichen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-31 00:00:00.000000000 Z
11
+ date: 2014-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activemodel
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '3.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: actionpack
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '3.1'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.1'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: multi_json
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: typhoeus
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ! '>='
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: 0.6.5
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ! '>='
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.6.5
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rack
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ! '>='
87
+ - - '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ! '>='
94
+ - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
@@ -116,95 +116,96 @@ extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
118
  - CHANGELOG.md
119
- - LICENSE
120
- - README.md
121
119
  - acfs.gemspec
122
- - lib/acfs.rb
120
+ - lib/acfs/service.rb
121
+ - lib/acfs/global.rb
122
+ - lib/acfs/util.rb
123
+ - lib/acfs/resource.rb
123
124
  - lib/acfs/adapter/base.rb
124
125
  - lib/acfs/adapter/typhoeus.rb
125
- - lib/acfs/collection.rb
126
- - lib/acfs/collections/paginatable.rb
127
- - lib/acfs/configuration.rb
128
- - lib/acfs/errors.rb
129
- - lib/acfs/global.rb
130
- - lib/acfs/location.rb
131
- - lib/acfs/middleware/base.rb
126
+ - lib/acfs/stub.rb
127
+ - lib/acfs/middleware/print.rb
128
+ - lib/acfs/middleware/msgpack_encoder.rb
129
+ - lib/acfs/middleware/logger.rb
132
130
  - lib/acfs/middleware/json_decoder.rb
131
+ - lib/acfs/middleware/base.rb
133
132
  - lib/acfs/middleware/json_encoder.rb
134
- - lib/acfs/middleware/logger.rb
135
133
  - lib/acfs/middleware/msgpack_decoder.rb
136
- - lib/acfs/middleware/msgpack_encoder.rb
137
- - lib/acfs/middleware/print.rb
134
+ - lib/acfs/collection.rb
135
+ - lib/acfs/singleton_resource.rb
136
+ - lib/acfs/runner.rb
137
+ - lib/acfs/rspec.rb
138
+ - lib/acfs/configuration.rb
139
+ - lib/acfs/location.rb
138
140
  - lib/acfs/model.rb
139
- - lib/acfs/model/attributes.rb
140
- - lib/acfs/model/attributes/base.rb
141
+ - lib/acfs/response.rb
142
+ - lib/acfs/request/callbacks.rb
143
+ - lib/acfs/errors.rb
144
+ - lib/acfs/operation.rb
145
+ - lib/acfs/request.rb
146
+ - lib/acfs/version.rb
147
+ - lib/acfs/response/status.rb
148
+ - lib/acfs/response/formats.rb
149
+ - lib/acfs/service/middleware.rb
150
+ - lib/acfs/yard.rb
151
+ - lib/acfs/model/query_methods.rb
152
+ - lib/acfs/model/service.rb
141
153
  - lib/acfs/model/attributes/boolean.rb
142
- - lib/acfs/model/attributes/date_time.rb
154
+ - lib/acfs/model/attributes/string.rb
155
+ - lib/acfs/model/attributes/uuid.rb
143
156
  - lib/acfs/model/attributes/float.rb
157
+ - lib/acfs/model/attributes/base.rb
144
158
  - lib/acfs/model/attributes/integer.rb
145
159
  - lib/acfs/model/attributes/list.rb
146
- - lib/acfs/model/attributes/string.rb
147
- - lib/acfs/model/attributes/uuid.rb
148
- - lib/acfs/model/dirty.rb
160
+ - lib/acfs/model/attributes/date_time.rb
149
161
  - lib/acfs/model/initialization.rb
150
- - lib/acfs/model/loadable.rb
162
+ - lib/acfs/model/attributes.rb
151
163
  - lib/acfs/model/locatable.rb
152
- - lib/acfs/model/operational.rb
153
164
  - lib/acfs/model/persistence.rb
154
- - lib/acfs/model/query_methods.rb
155
- - lib/acfs/model/relations.rb
156
- - lib/acfs/model/service.rb
157
165
  - lib/acfs/model/validation.rb
158
- - lib/acfs/operation.rb
159
- - lib/acfs/request.rb
160
- - lib/acfs/request/callbacks.rb
161
- - lib/acfs/resource.rb
162
- - lib/acfs/response.rb
163
- - lib/acfs/response/formats.rb
164
- - lib/acfs/response/status.rb
165
- - lib/acfs/rspec.rb
166
- - lib/acfs/runner.rb
167
- - lib/acfs/service.rb
168
- - lib/acfs/service/middleware.rb
169
- - lib/acfs/singleton_resource.rb
170
- - lib/acfs/stub.rb
171
- - lib/acfs/util.rb
172
- - lib/acfs/version.rb
173
- - lib/acfs/yard.rb
174
- - spec/acfs/adapter/typhoeus_spec.rb
166
+ - lib/acfs/model/loadable.rb
167
+ - lib/acfs/model/dirty.rb
168
+ - lib/acfs/model/relations.rb
169
+ - lib/acfs/model/operational.rb
170
+ - lib/acfs/collections/paginatable.rb
171
+ - lib/acfs.rb
172
+ - README.md
173
+ - LICENSE
175
174
  - spec/acfs/collection_spec.rb
176
- - spec/acfs/configuration_spec.rb
177
175
  - spec/acfs/global_spec.rb
178
- - spec/acfs/middleware/json_decoder_spec.rb
176
+ - spec/acfs/adapter/typhoeus_spec.rb
179
177
  - spec/acfs/middleware/msgpack_decoder_spec.rb
178
+ - spec/acfs/middleware/json_decoder_spec.rb
179
+ - spec/acfs/runner_spec.rb
180
+ - spec/acfs/configuration_spec.rb
181
+ - spec/acfs/service_spec.rb
182
+ - spec/acfs/stub_spec.rb
183
+ - spec/acfs/operation_spec.rb
184
+ - spec/acfs/request/callbacks_spec.rb
185
+ - spec/acfs/response/formats_spec.rb
186
+ - spec/acfs/response/status_spec.rb
187
+ - spec/acfs/service/middleware_spec.rb
188
+ - spec/acfs/singleton_resource_spec.rb
189
+ - spec/acfs/request_spec.rb
190
+ - spec/acfs/model/locatable_spec.rb
191
+ - spec/acfs/model/attributes/float_spec.rb
180
192
  - spec/acfs/model/attributes/boolean_spec.rb
193
+ - spec/acfs/model/attributes/uuid_spec.rb
181
194
  - spec/acfs/model/attributes/date_time_spec.rb
182
- - spec/acfs/model/attributes/float_spec.rb
183
195
  - spec/acfs/model/attributes/list_spec.rb
184
- - spec/acfs/model/attributes/uuid_spec.rb
185
- - spec/acfs/model/attributes_spec.rb
186
- - spec/acfs/model/dirty_spec.rb
196
+ - spec/acfs/model/persistance_spec.rb
187
197
  - spec/acfs/model/initialization_spec.rb
188
198
  - spec/acfs/model/loadable_spec.rb
189
- - spec/acfs/model/locatable_spec.rb
190
- - spec/acfs/model/persistance_spec.rb
191
- - spec/acfs/model/query_methods_spec.rb
192
199
  - spec/acfs/model/validation_spec.rb
193
- - spec/acfs/request/callbacks_spec.rb
194
- - spec/acfs/request_spec.rb
195
- - spec/acfs/response/formats_spec.rb
196
- - spec/acfs/response/status_spec.rb
197
- - spec/acfs/runner_spec.rb
198
- - spec/acfs/service/middleware_spec.rb
199
- - spec/acfs/service_spec.rb
200
- - spec/acfs/singleton_resource_spec.rb
201
- - spec/acfs/stub_spec.rb
202
- - spec/acfs_spec.rb
203
- - spec/fixtures/config.yml
204
- - spec/spec_helper.rb
205
- - spec/support/response.rb
200
+ - spec/acfs/model/attributes_spec.rb
201
+ - spec/acfs/model/query_methods_spec.rb
202
+ - spec/acfs/model/dirty_spec.rb
206
203
  - spec/support/service.rb
207
204
  - spec/support/shared/find_callbacks.rb
205
+ - spec/support/response.rb
206
+ - spec/spec_helper.rb
207
+ - spec/fixtures/config.yml
208
+ - spec/acfs_spec.rb
208
209
  homepage: https://github.com/jgraichen/acfs
209
210
  licenses:
210
211
  - MIT
@@ -215,52 +216,54 @@ require_paths:
215
216
  - lib
216
217
  required_ruby_version: !ruby/object:Gem::Requirement
217
218
  requirements:
218
- - - ! '>='
219
+ - - '>='
219
220
  - !ruby/object:Gem::Version
220
221
  version: '0'
221
222
  required_rubygems_version: !ruby/object:Gem::Requirement
222
223
  requirements:
223
- - - ! '>'
224
+ - - '>='
224
225
  - !ruby/object:Gem::Version
225
- version: 1.3.1
226
+ version: '0'
226
227
  requirements: []
227
228
  rubyforge_project:
228
- rubygems_version: 2.2.2
229
+ rubygems_version: 2.0.14
229
230
  signing_key:
230
231
  specification_version: 4
231
232
  summary: An abstract API base client for service oriented application.
232
233
  test_files:
233
- - spec/acfs/adapter/typhoeus_spec.rb
234
234
  - spec/acfs/collection_spec.rb
235
- - spec/acfs/configuration_spec.rb
236
235
  - spec/acfs/global_spec.rb
237
- - spec/acfs/middleware/json_decoder_spec.rb
236
+ - spec/acfs/adapter/typhoeus_spec.rb
238
237
  - spec/acfs/middleware/msgpack_decoder_spec.rb
238
+ - spec/acfs/middleware/json_decoder_spec.rb
239
+ - spec/acfs/runner_spec.rb
240
+ - spec/acfs/configuration_spec.rb
241
+ - spec/acfs/service_spec.rb
242
+ - spec/acfs/stub_spec.rb
243
+ - spec/acfs/operation_spec.rb
244
+ - spec/acfs/request/callbacks_spec.rb
245
+ - spec/acfs/response/formats_spec.rb
246
+ - spec/acfs/response/status_spec.rb
247
+ - spec/acfs/service/middleware_spec.rb
248
+ - spec/acfs/singleton_resource_spec.rb
249
+ - spec/acfs/request_spec.rb
250
+ - spec/acfs/model/locatable_spec.rb
251
+ - spec/acfs/model/attributes/float_spec.rb
239
252
  - spec/acfs/model/attributes/boolean_spec.rb
253
+ - spec/acfs/model/attributes/uuid_spec.rb
240
254
  - spec/acfs/model/attributes/date_time_spec.rb
241
- - spec/acfs/model/attributes/float_spec.rb
242
255
  - spec/acfs/model/attributes/list_spec.rb
243
- - spec/acfs/model/attributes/uuid_spec.rb
244
- - spec/acfs/model/attributes_spec.rb
245
- - spec/acfs/model/dirty_spec.rb
256
+ - spec/acfs/model/persistance_spec.rb
246
257
  - spec/acfs/model/initialization_spec.rb
247
258
  - spec/acfs/model/loadable_spec.rb
248
- - spec/acfs/model/locatable_spec.rb
249
- - spec/acfs/model/persistance_spec.rb
250
- - spec/acfs/model/query_methods_spec.rb
251
259
  - spec/acfs/model/validation_spec.rb
252
- - spec/acfs/request/callbacks_spec.rb
253
- - spec/acfs/request_spec.rb
254
- - spec/acfs/response/formats_spec.rb
255
- - spec/acfs/response/status_spec.rb
256
- - spec/acfs/runner_spec.rb
257
- - spec/acfs/service/middleware_spec.rb
258
- - spec/acfs/service_spec.rb
259
- - spec/acfs/singleton_resource_spec.rb
260
- - spec/acfs/stub_spec.rb
261
- - spec/acfs_spec.rb
262
- - spec/fixtures/config.yml
263
- - spec/spec_helper.rb
264
- - spec/support/response.rb
260
+ - spec/acfs/model/attributes_spec.rb
261
+ - spec/acfs/model/query_methods_spec.rb
262
+ - spec/acfs/model/dirty_spec.rb
265
263
  - spec/support/service.rb
266
264
  - spec/support/shared/find_callbacks.rb
265
+ - spec/support/response.rb
266
+ - spec/spec_helper.rb
267
+ - spec/fixtures/config.yml
268
+ - spec/acfs_spec.rb
269
+ has_rdoc: