acfs 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -1
- data/README.md +0 -2
- data/lib/acfs/global.rb +10 -2
- data/lib/acfs/version.rb +1 -1
- data/spec/acfs/global_spec.rb +44 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e970f81dff63a351279207100701f7a9be822272a77e5dfc3bd39d9e418a0db
|
4
|
+
data.tar.gz: 81b752674659595a097b951334bb41fa36f9a96de2f3b7ff0a1a82d3e03f0009
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d8363f66d917672285318eaf1f68f03c3ef28c560373b4e74054f5d5d4da7dd0a443f6b54c9835fafbd290921e2d8316195a3c015970e539baa37fb8bead339
|
7
|
+
data.tar.gz: 73d009dc5601ba4e4cc06efb41a0990a58779726b86ebf4905c2967dba55de406085b83e9a7c3de71b860e748bae1ff39b2a59de91a2699c488ced2d689d9234
|
data/CHANGELOG.md
CHANGED
@@ -14,9 +14,17 @@
|
|
14
14
|
### Breaks
|
15
15
|
|
16
16
|
|
17
|
-
## 1.3.
|
17
|
+
## 1.3.2 - (2019-09-24)
|
18
|
+
|
19
|
+
|
20
|
+
### Fixes
|
21
|
+
* Fix Acfs.on callbacks for empty find_by results (#42)
|
22
|
+
|
23
|
+
|
18
24
|
---
|
19
25
|
|
26
|
+
## 1.3.1 - (2019-07-02)
|
27
|
+
|
20
28
|
### Fixes
|
21
29
|
* Improve URL argument encoding when building resource requests
|
22
30
|
|
data/README.md
CHANGED
@@ -3,8 +3,6 @@
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/acfs.svg)](http://badge.fury.io/rb/acfs)
|
4
4
|
[![Build Status](http://img.shields.io/travis/jgraichen/acfs/master.svg)](https://travis-ci.org/jgraichen/acfs)
|
5
5
|
[![Coverage Status](http://img.shields.io/coveralls/jgraichen/acfs/master.svg)](https://coveralls.io/r/jgraichen/acfs)
|
6
|
-
[![Code Climate](http://img.shields.io/codeclimate/github/jgraichen/acfs.svg)](https://codeclimate.com/github/jgraichen/acfs)
|
7
|
-
[![Dependency Status](http://img.shields.io/gemnasium/jgraichen/acfs.svg)](https://gemnasium.com/jgraichen/acfs)
|
8
6
|
[![RubyDoc Documentation](http://img.shields.io/badge/rubydoc-here-blue.svg)](http://rubydoc.info/github/jgraichen/acfs/master/frames)
|
9
7
|
|
10
8
|
Acfs is a library to develop API client libraries for single services within a larger service oriented application.
|
data/lib/acfs/global.rb
CHANGED
@@ -73,7 +73,7 @@ module Acfs
|
|
73
73
|
end
|
74
74
|
return false if block.nil?
|
75
75
|
|
76
|
-
if resource.loaded?
|
76
|
+
if resource.nil? || resource.loaded?
|
77
77
|
block.call resource
|
78
78
|
else
|
79
79
|
resource.__callbacks__ << block
|
@@ -81,9 +81,17 @@ module Acfs
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def on(*resources)
|
84
|
+
# If all resources have already been loaded, we run the callback immediately.
|
85
|
+
if resources.all? {|res| res.nil? || res.loaded? }
|
86
|
+
yield(*resources)
|
87
|
+
return
|
88
|
+
end
|
89
|
+
|
90
|
+
# Otherwise, we add a callback to *each* resource with a guard that ensures
|
91
|
+
# that only the very last resource being loaded executes the callback.
|
84
92
|
resources.each do |resource|
|
85
93
|
add_callback resource do |_|
|
86
|
-
yield(*resources)
|
94
|
+
yield(*resources) if resources.all? {|res| res.nil? || res.loaded? }
|
87
95
|
end
|
88
96
|
end
|
89
97
|
end
|
data/lib/acfs/version.rb
CHANGED
data/spec/acfs/global_spec.rb
CHANGED
@@ -71,6 +71,50 @@ describe ::Acfs::Global do
|
|
71
71
|
end
|
72
72
|
Acfs.run
|
73
73
|
end
|
74
|
+
|
75
|
+
context 'with an empty result for a find_by call' do
|
76
|
+
before do
|
77
|
+
stub_request(:get, %r{http://users.example.org/users})
|
78
|
+
.with(query: {id: '2'})
|
79
|
+
.to_return(
|
80
|
+
status: 200,
|
81
|
+
body: '{}',
|
82
|
+
headers: {'Content-Type' => 'application/json'}
|
83
|
+
)
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'invokes once both requests are finished' do
|
87
|
+
user1 = MyUser.find 1
|
88
|
+
user2 = MyUser.find_by id: 2
|
89
|
+
|
90
|
+
expect do |cb|
|
91
|
+
Acfs.on(user1, user2, &cb)
|
92
|
+
Acfs.run
|
93
|
+
end.to yield_with_args(user1, be_nil)
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'invokes once remaining requests are finished' do
|
97
|
+
user1 = MyUser.find 1
|
98
|
+
Acfs.run # Finish the first request
|
99
|
+
|
100
|
+
user2 = MyUser.find_by id: 2
|
101
|
+
|
102
|
+
expect do |cb|
|
103
|
+
Acfs.on(user1, user2, &cb)
|
104
|
+
Acfs.run
|
105
|
+
end.to yield_with_args(user1, be_nil)
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'invokes immediately when all requests have already been finished' do
|
109
|
+
user1 = MyUser.find 1
|
110
|
+
user2 = MyUser.find_by id: 2
|
111
|
+
Acfs.run
|
112
|
+
|
113
|
+
expect do |cb|
|
114
|
+
Acfs.on(user1, user2, &cb)
|
115
|
+
end.to yield_with_args(user1, be_nil)
|
116
|
+
end
|
117
|
+
end
|
74
118
|
end
|
75
119
|
|
76
120
|
describe '#runner' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acfs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Graichen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -228,8 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
228
228
|
- !ruby/object:Gem::Version
|
229
229
|
version: '0'
|
230
230
|
requirements: []
|
231
|
-
|
232
|
-
rubygems_version: 2.7.7
|
231
|
+
rubygems_version: 3.0.6
|
233
232
|
signing_key:
|
234
233
|
specification_version: 4
|
235
234
|
summary: An abstract API base client for service oriented application.
|