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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dad7bfee465c7ed9ad1586772701aca8adff2912
4
- data.tar.gz: 42588b8e641640855dfbc60c291dd0fc0110025d
3
+ metadata.gz: 198aaab5dbd57283d7ceda11637e42851b9b2d4a
4
+ data.tar.gz: 2041ea64c62716706eb62e61e331fa4db9afda41
5
5
  SHA512:
6
- metadata.gz: 6daa4d30dc27c1f3338e5426b149c22aa5add6b00f095a0f30d248f9e01973cbbba184974cbb7a386cba810bdd81e60210e357229d8a4c28f16f2b339fb3e596
7
- data.tar.gz: 40f96c5d9c5ad7b592e23493f284631acb6e19f8912241bc0ea75060054971a91d96694bd2a80cd61042a0c923ded09865ed039893741bbd02401892bde099d7
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.5
4
- - 2.3.1
5
- - 2.4.0
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
- sudo: false
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(Fixnum), ids_or_objects.grep(klass)
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 Fixnums: #{ids_or_objects.map { |id_or_object| [id_or_object.class, id_or_object.inspect].join(' - ')}}"
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
@@ -80,7 +80,7 @@ module Services
80
80
  arg.map do |array_arg|
81
81
  convert_for_rescheduling array_arg
82
82
  end
83
- when Fixnum, String, TrueClass, FalseClass, NilClass
83
+ when Integer, String, TrueClass, FalseClass, NilClass
84
84
  arg
85
85
  when object_class
86
86
  arg.id
@@ -1,3 +1,3 @@
1
1
  module Services
2
- VERSION = '5.1.0'.freeze
2
+ VERSION = '5.1.1'.freeze
3
3
  end
@@ -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(Fixnum), *fail_arg_group, 'reschedule', false)
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
@@ -3,7 +3,7 @@ require 'sidekiq/api'
3
3
  ExpectedDataNotFoundError = Class.new(StandardError)
4
4
 
5
5
  def wait_for(&block)
6
- 50.tries on: ExpectedDataNotFoundError, delay: 0.1 do
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
- sleep 0.5 if sleep
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
- sleep 0.5 if sleep
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
- sleep 0.5 if sleep
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
- sleep 0.5 if sleep
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.0
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: 2016-12-27 00:00:00.000000000 Z
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.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: