active_rest_client 1.0.4 → 1.0.5

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: 168401e841f472c8c7dbb6295e9a7b6f87e10712
4
- data.tar.gz: eb08bff09d6e74f4c3f1dc3a6933113e726cd620
3
+ metadata.gz: dd23c05a32d0575c6e4ff7d2334b7264ca1ee1db
4
+ data.tar.gz: 4abca247cd1cc050a34f9f50edc60c82408fde93
5
5
  SHA512:
6
- metadata.gz: ca279962a442b496caa49d6dff757966bde80df37d7ef9d24e721a64f547a98c5200e4e0e8bf24136255ac7103797831b38c5b83f9da3897fddf739b004d72a8
7
- data.tar.gz: 4deb89b8022c5da47c761df1a3853bb16b77949676b1f090cf87150ab0d8389c8b4297a3f22cd61ced2d1c1033add4e271cda532ac629c319158db0b28201013
6
+ metadata.gz: e98ae059859804960a1a7030ef3662536787a4dda830318f4c35f5470198ae85f3d3f17857dd0a4d9d4291e71923f1f8f4a9ef25ef7ad613216d8a7b672cfc09
7
+ data.tar.gz: cb70cc5f0ce3a0138f8d6767f1aa0a15b46eecaf75a473e9acd48de5f175c25388e8f7e9802d8a6e697fc3cc017437342c00e8381b34af7e1f08819cf63bb022
@@ -114,11 +114,6 @@ module ActiveRestClient
114
114
  elsif cached.etag.to_s != "" #present? isn't working for some reason
115
115
  ActiveRestClient::Logger.debug " \033[1;4;32m#{ActiveRestClient::NAME}\033[0m #{@instrumentation_name} - Etag cached copy found with etag #{cached.etag}"
116
116
  etag = cached.etag
117
- response = do_request(etag)
118
- if response.status == 304
119
- ActiveRestClient::Logger.debug " \033[1;4;32m#{ActiveRestClient::NAME}\033[0m #{@instrumentation_name} - Etag copy is the same as the server"
120
- return handle_cached_response(cached)
121
- end
122
117
  end
123
118
  end
124
119
  response = if proxy
@@ -131,7 +126,7 @@ module ActiveRestClient
131
126
  if object_is_class? && @object.record_response?
132
127
  @object.record_response(self.url, response)
133
128
  end
134
- result = handle_response(response)
129
+ result = handle_response(response, cached)
135
130
  original_object_class.write_cached_response(self, response, result)
136
131
  result
137
132
  end
@@ -272,10 +267,16 @@ module ActiveRestClient
272
267
  end
273
268
  end
274
269
 
275
- def handle_response(response)
270
+ def handle_response(response, cached = nil)
276
271
  @response = response
277
272
  status = @response.status || 200
278
273
 
274
+ if cached && response.status == 304
275
+ ActiveRestClient::Logger.debug " \033[1;4;32m#{ActiveRestClient::NAME}\033[0m #{@instrumentation_name}" +
276
+ ' - Etag copy is the same as the server'
277
+ return handle_cached_response(cached)
278
+ end
279
+
279
280
  if (200..399).include?(status)
280
281
  if @method[:options][:plain]
281
282
  return @response = response.body
@@ -1,3 +1,3 @@
1
1
  module ActiveRestClient
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  end
@@ -30,7 +30,7 @@ describe ActiveRestClient::Caching do
30
30
 
31
31
  ActiveRestClient::Base.perform_caching = true
32
32
  expect(ActiveRestClient::Base.perform_caching).to be_true
33
- expect(EmptyExample.perform_caching).to be_true
33
+ expect(CachingExample3.perform_caching).to be_true
34
34
 
35
35
  ActiveRestClient::Base._reset_caching!
36
36
  end
@@ -116,6 +116,24 @@ describe ActiveRestClient::Caching do
116
116
  expect(ret.first_name).to eq("Johnny")
117
117
  end
118
118
 
119
+ it 'queries the server when the cache has expired' do
120
+ cached_response = ActiveRestClient::CachedResponse.new(
121
+ status: 200,
122
+ result: @cached_object,
123
+ etag: @etag
124
+ )
125
+ allow_any_instance_of(CachingExampleCacheStore5).to receive(:read).and_return(Marshal.dump(cached_response))
126
+ new_name = 'Pete'
127
+ response_body = Person.new(first_name: new_name).to_json
128
+ response = double(status: 200, headers: {}, body: response_body)
129
+ allow_any_instance_of(ActiveRestClient::Connection).to(
130
+ receive(:get).with('/', hash_including('If-None-Match' => @etag)).and_return(response))
131
+
132
+ result = Person.all
133
+
134
+ expect(result.first_name).to eq new_name
135
+ end
136
+
119
137
  it "should read from the cache store, and not call the server if there's a hard expiry" do
120
138
  cached_response = ActiveRestClient::CachedResponse.new(
121
139
  status:200,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_rest_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Which Ltd
@@ -9,202 +9,202 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-09-01 00:00:00.000000000 Z
12
+ date: 2015-01-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ~>
19
19
  - !ruby/object:Gem::Version
20
20
  version: '1.3'
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - "~>"
25
+ - - ~>
26
26
  - !ruby/object:Gem::Version
27
27
  version: '1.3'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rake
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ">="
32
+ - - '>='
33
33
  - !ruby/object:Gem::Version
34
34
  version: '0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ">="
39
+ - - '>='
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rspec
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - "~>"
46
+ - - ~>
47
47
  - !ruby/object:Gem::Version
48
48
  version: '2'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - "~>"
53
+ - - ~>
54
54
  - !ruby/object:Gem::Version
55
55
  version: '2'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: webmock
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - ">="
60
+ - - '>='
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - ">="
67
+ - - '>='
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rspec_junit_formatter
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - ">="
74
+ - - '>='
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - ">="
81
+ - - '>='
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: simplecov
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - ">="
88
+ - - '>='
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - ">="
95
+ - - '>='
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: simplecov-rcov
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
- - - ">="
102
+ - - '>='
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - ">="
109
+ - - '>='
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: guard-rspec
114
114
  requirement: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - ">="
116
+ - - '>='
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0'
119
119
  type: :development
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
- - - ">="
123
+ - - '>='
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: terminal-notifier-guard
128
128
  requirement: !ruby/object:Gem::Requirement
129
129
  requirements:
130
- - - ">="
130
+ - - '>='
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0'
133
133
  type: :development
134
134
  prerelease: false
135
135
  version_requirements: !ruby/object:Gem::Requirement
136
136
  requirements:
137
- - - ">="
137
+ - - '>='
138
138
  - !ruby/object:Gem::Version
139
139
  version: '0'
140
140
  - !ruby/object:Gem::Dependency
141
141
  name: coveralls
142
142
  requirement: !ruby/object:Gem::Requirement
143
143
  requirements:
144
- - - ">="
144
+ - - '>='
145
145
  - !ruby/object:Gem::Version
146
146
  version: '0'
147
147
  type: :development
148
148
  prerelease: false
149
149
  version_requirements: !ruby/object:Gem::Requirement
150
150
  requirements:
151
- - - ">="
151
+ - - '>='
152
152
  - !ruby/object:Gem::Version
153
153
  version: '0'
154
154
  - !ruby/object:Gem::Dependency
155
155
  name: multi_json
156
156
  requirement: !ruby/object:Gem::Requirement
157
157
  requirements:
158
- - - ">="
158
+ - - '>='
159
159
  - !ruby/object:Gem::Version
160
160
  version: '0'
161
161
  type: :runtime
162
162
  prerelease: false
163
163
  version_requirements: !ruby/object:Gem::Requirement
164
164
  requirements:
165
- - - ">="
165
+ - - '>='
166
166
  - !ruby/object:Gem::Version
167
167
  version: '0'
168
168
  - !ruby/object:Gem::Dependency
169
169
  name: activesupport
170
170
  requirement: !ruby/object:Gem::Requirement
171
171
  requirements:
172
- - - ">="
172
+ - - '>='
173
173
  - !ruby/object:Gem::Version
174
174
  version: '0'
175
175
  type: :runtime
176
176
  prerelease: false
177
177
  version_requirements: !ruby/object:Gem::Requirement
178
178
  requirements:
179
- - - ">="
179
+ - - '>='
180
180
  - !ruby/object:Gem::Version
181
181
  version: '0'
182
182
  - !ruby/object:Gem::Dependency
183
183
  name: faraday
184
184
  requirement: !ruby/object:Gem::Requirement
185
185
  requirements:
186
- - - ">="
186
+ - - '>='
187
187
  - !ruby/object:Gem::Version
188
188
  version: '0'
189
189
  type: :runtime
190
190
  prerelease: false
191
191
  version_requirements: !ruby/object:Gem::Requirement
192
192
  requirements:
193
- - - ">="
193
+ - - '>='
194
194
  - !ruby/object:Gem::Version
195
195
  version: '0'
196
196
  - !ruby/object:Gem::Dependency
197
197
  name: patron
198
198
  requirement: !ruby/object:Gem::Requirement
199
199
  requirements:
200
- - - ">="
200
+ - - '>='
201
201
  - !ruby/object:Gem::Version
202
202
  version: 0.4.9
203
203
  type: :development
204
204
  prerelease: false
205
205
  version_requirements: !ruby/object:Gem::Requirement
206
206
  requirements:
207
- - - ">="
207
+ - - '>='
208
208
  - !ruby/object:Gem::Version
209
209
  version: 0.4.9
210
210
  description: Accessing REST services in an ActiveRecord style
@@ -215,10 +215,10 @@ executables: []
215
215
  extensions: []
216
216
  extra_rdoc_files: []
217
217
  files:
218
- - ".gitignore"
219
- - ".rspec"
220
- - ".simplecov"
221
- - ".travis.yml"
218
+ - .gitignore
219
+ - .rspec
220
+ - .simplecov
221
+ - .travis.yml
222
222
  - CONTRIBUTING.md
223
223
  - Gemfile
224
224
  - Guardfile
@@ -275,17 +275,17 @@ require_paths:
275
275
  - lib
276
276
  required_ruby_version: !ruby/object:Gem::Requirement
277
277
  requirements:
278
- - - ">="
278
+ - - '>='
279
279
  - !ruby/object:Gem::Version
280
280
  version: '0'
281
281
  required_rubygems_version: !ruby/object:Gem::Requirement
282
282
  requirements:
283
- - - ">="
283
+ - - '>='
284
284
  - !ruby/object:Gem::Version
285
285
  version: '0'
286
286
  requirements: []
287
287
  rubyforge_project:
288
- rubygems_version: 2.2.2
288
+ rubygems_version: 2.0.14
289
289
  signing_key:
290
290
  specification_version: 4
291
291
  summary: This gem is for accessing REST services in an ActiveRecord style. ActiveResource
@@ -311,3 +311,4 @@ test_files:
311
311
  - spec/lib/result_iterator_spec.rb
312
312
  - spec/lib/validation_spec.rb
313
313
  - spec/spec_helper.rb
314
+ has_rdoc: