services 5.1.0 → 5.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +10 -4
- data/lib/services/base.rb +3 -2
- data/lib/services/modules/uniqueness_checker.rb +1 -1
- data/lib/services/version.rb +1 -1
- data/spec/services/modules/uniqueness_checker_spec.rb +1 -1
- data/spec/support/helpers.rb +1 -1
- data/spec/support/test_services.rb +12 -4
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 198aaab5dbd57283d7ceda11637e42851b9b2d4a
|
4
|
+
data.tar.gz: 2041ea64c62716706eb62e61e331fa4db9afda41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38dd5e81a6465ccb59b7344fa856e97b589ffab67d2a5ad528835968af73e96b5f07712d4737580075e88b63f58d650193644d1acc160fb35ee4344f31e79d07
|
7
|
+
data.tar.gz: 479ffc18a349655cb744eb2d3d6210399285fcb70f11dc8c5162011536b9f5df99c400ddd2a9594125097e790a301e9ad67fdda0d0303593b19fb36095447fd4
|
data/.travis.yml
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
language: ruby
|
2
|
+
sudo: false
|
2
3
|
rvm:
|
3
|
-
- 2.2.
|
4
|
-
- 2.3.
|
5
|
-
- 2.4.
|
4
|
+
- 2.2.7
|
5
|
+
- 2.3.4
|
6
|
+
- 2.4.1
|
6
7
|
services:
|
7
8
|
- redis-server
|
8
9
|
before_install:
|
@@ -13,4 +14,9 @@ gemfile:
|
|
13
14
|
- gemfiles/rails_4.1.gemfile
|
14
15
|
- gemfiles/rails_4.2.gemfile
|
15
16
|
- gemfiles/rails_5.0.gemfile
|
16
|
-
|
17
|
+
matrix:
|
18
|
+
exclude:
|
19
|
+
- rvm: 2.4.0
|
20
|
+
gemfile: gemfiles/rails_4.0.gemfile
|
21
|
+
- rvm: 2.4.0
|
22
|
+
gemfile: gemfiles/rails_4.1.gemfile
|
data/lib/services/base.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'active_record'
|
1
2
|
require 'securerandom'
|
2
3
|
require 'action_dispatch'
|
3
4
|
require 'digest'
|
@@ -33,9 +34,9 @@ module Services
|
|
33
34
|
|
34
35
|
def _split_ids_and_objects(ids_or_objects, klass)
|
35
36
|
ids_or_objects = Array(ids_or_objects)
|
36
|
-
ids, objects = ids_or_objects.grep(
|
37
|
+
ids, objects = ids_or_objects.grep(Integer), ids_or_objects.grep(klass)
|
37
38
|
if ids.size + objects.size < ids_or_objects.size
|
38
|
-
raise "All params must be either #{klass.to_s.pluralize} or
|
39
|
+
raise "All params must be either #{klass.to_s.pluralize} or Integers: #{ids_or_objects.map { |id_or_object| [id_or_object.class, id_or_object.inspect].join(' - ')}}"
|
39
40
|
end
|
40
41
|
[ids, objects]
|
41
42
|
end
|
data/lib/services/version.rb
CHANGED
@@ -57,7 +57,7 @@ shared_examples 'checking the uniqueness properly' do
|
|
57
57
|
fail_args.each do |fail_arg_group|
|
58
58
|
service = service_class.new
|
59
59
|
expect(service).to_not receive(:do_work)
|
60
|
-
expect(service_class).to receive(:call_in).with(an_instance_of(
|
60
|
+
expect(service_class).to receive(:call_in).with(an_instance_of(Integer), *fail_arg_group, 'reschedule', false)
|
61
61
|
expect { service.call(*fail_arg_group, 'reschedule', false) }.to_not raise_error
|
62
62
|
end
|
63
63
|
end
|
data/spec/support/helpers.rb
CHANGED
@@ -3,7 +3,7 @@ require 'sidekiq/api'
|
|
3
3
|
ExpectedDataNotFoundError = Class.new(StandardError)
|
4
4
|
|
5
5
|
def wait_for(&block)
|
6
|
-
|
6
|
+
60.tries on: ExpectedDataNotFoundError, delay: 0.1 do
|
7
7
|
block.call or raise ExpectedDataNotFoundError
|
8
8
|
end
|
9
9
|
end
|
@@ -116,7 +116,9 @@ class UniqueService < Services::Base
|
|
116
116
|
def call(on_error, sleep)
|
117
117
|
check_uniqueness on_error: on_error
|
118
118
|
do_work
|
119
|
-
|
119
|
+
# Sleep 6 seconds, this needs to be at least the time
|
120
|
+
# between Sidekiq's "heartbeats", which occur every 5 seconds.
|
121
|
+
sleep 6 if sleep
|
120
122
|
end
|
121
123
|
def do_work; end
|
122
124
|
end
|
@@ -125,7 +127,9 @@ class UniqueWithCustomArgsService < Services::Base
|
|
125
127
|
def call(uniqueness_arg1, uniqueness_arg2, ignore_arg, on_error, sleep)
|
126
128
|
check_uniqueness uniqueness_arg1, uniqueness_arg2, on_error: on_error
|
127
129
|
do_work
|
128
|
-
|
130
|
+
# Sleep 6 seconds, this needs to be at least the time
|
131
|
+
# between Sidekiq's "heartbeats", which occur every 5 seconds.
|
132
|
+
sleep 6 if sleep
|
129
133
|
end
|
130
134
|
def do_work; end
|
131
135
|
end
|
@@ -136,7 +140,9 @@ class UniqueMultipleService < Services::Base
|
|
136
140
|
check_uniqueness arg, on_error: on_error
|
137
141
|
end
|
138
142
|
do_work
|
139
|
-
|
143
|
+
# Sleep 6 seconds, this needs to be at least the time
|
144
|
+
# between Sidekiq's "heartbeats", which occur every 5 seconds.
|
145
|
+
sleep 6 if sleep
|
140
146
|
end
|
141
147
|
def do_work; end
|
142
148
|
end
|
@@ -144,7 +150,9 @@ end
|
|
144
150
|
class NonUniqueService < Services::Base
|
145
151
|
def call(on_error, sleep)
|
146
152
|
do_work
|
147
|
-
|
153
|
+
# Sleep 6 seconds, this needs to be at least the time
|
154
|
+
# between Sidekiq's "heartbeats", which occur every 5 seconds.
|
155
|
+
sleep 6 if sleep
|
148
156
|
end
|
149
157
|
def do_work; end
|
150
158
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: services
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.1.
|
4
|
+
version: 5.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manuel Meurer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -247,7 +247,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
247
247
|
version: '0'
|
248
248
|
requirements: []
|
249
249
|
rubyforge_project:
|
250
|
-
rubygems_version: 2.6.
|
250
|
+
rubygems_version: 2.6.11
|
251
251
|
signing_key:
|
252
252
|
specification_version: 4
|
253
253
|
summary: A nifty service layer for your Rails app
|
@@ -268,4 +268,3 @@ test_files:
|
|
268
268
|
- spec/support/redis-server
|
269
269
|
- spec/support/shared.rb
|
270
270
|
- spec/support/test_services.rb
|
271
|
-
has_rdoc:
|