fleiss 0.2.0 → 0.4.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
  SHA256:
3
- metadata.gz: b76bfb38938511dcf5053855e5a9091ad694c0b1c1fafba3e551b5757aaa1dfe
4
- data.tar.gz: 9ff274eeba83d0e5ffc878c4934a4c03bbc91ede2bd2eb0f7e6c026fdd3dc1bb
3
+ metadata.gz: 3433257ea2a501706212f8876c0c9636a00028a6c9616daf86d66aa36d0dbd9a
4
+ data.tar.gz: d792288414d281a0667fd8100475eb45ec610c3330fce5e0d8434aa3d3ac50fe
5
5
  SHA512:
6
- metadata.gz: b145758e74ac991211a2677409fe31a185a094ee3304d54d2cf41937446c257dba225a01183591743486e3d91725e37ffbec747c01f3a144652693645e08d5f6
7
- data.tar.gz: 55909e4fbf2652fe613767eca254d585ac89e07ff8d2e40c5b6e502e266a8fda6dd4f02b32c4dc1cf880cfc33f83e8433fed30e255978531bb2f3ef621bd2a83
6
+ metadata.gz: 0fbf7922526ece6336986a26e69bfcf84263d3183ab39bb296f82ae1b08994af912d52f7d06ab16dee5f31c1100643814e220aa2052b6ca408b459ad8efb4a8d
7
+ data.tar.gz: a23fe3139ea3f1f891847343333e476de1edc1bf35b24279122b734f2867a15b66d5da9cfa77c37820e511a97c40a240bc4e3c7ae77c721020591119f8c3652f
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  .rubocop-*
2
2
  pkg/
3
+ spec/tmp
@@ -1,5 +1,12 @@
1
- inherit_from:
2
- - https://bitbucket.org/bsm/misc/raw/master/rubocop/default.yml
1
+ inherit_gem:
2
+ rubocop-bsm:
3
+ - default.yml
4
+ inherit_mode:
5
+ merge:
6
+ - Exclude
7
+
8
+ AllCops:
9
+ TargetRubyVersion: "2.6"
3
10
 
4
11
  Security/Open:
5
12
  Exclude:
@@ -1,8 +1,9 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.5
4
- - 2.4
3
+ - 2.7
4
+ - 2.6
5
5
  before_install:
6
+ - gem install bundler
6
7
  - mysql -e 'CREATE DATABASE fleiss_test;'
7
8
  - psql -c 'CREATE DATABASE fleiss_test;' -U postgres
8
9
  services:
@@ -1,73 +1,94 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fleiss (0.2.0)
5
- activejob (>= 5.0)
6
- activerecord (>= 5.0)
4
+ fleiss (0.4.1)
5
+ activejob (>= 6.0)
6
+ activerecord (>= 6.0)
7
7
  concurrent-ruby
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- activejob (5.2.2)
13
- activesupport (= 5.2.2)
12
+ activejob (6.1.1)
13
+ activesupport (= 6.1.1)
14
14
  globalid (>= 0.3.6)
15
- activemodel (5.2.2)
16
- activesupport (= 5.2.2)
17
- activerecord (5.2.2)
18
- activemodel (= 5.2.2)
19
- activesupport (= 5.2.2)
20
- arel (>= 9.0)
21
- activesupport (5.2.2)
15
+ activemodel (6.1.1)
16
+ activesupport (= 6.1.1)
17
+ activerecord (6.1.1)
18
+ activemodel (= 6.1.1)
19
+ activesupport (= 6.1.1)
20
+ activesupport (6.1.1)
22
21
  concurrent-ruby (~> 1.0, >= 1.0.2)
23
- i18n (>= 0.7, < 2)
24
- minitest (~> 5.1)
25
- tzinfo (~> 1.1)
26
- arel (9.0.0)
27
- ast (2.4.0)
28
- concurrent-ruby (1.1.4)
29
- diff-lcs (1.3)
30
- globalid (0.4.1)
22
+ i18n (>= 1.6, < 2)
23
+ minitest (>= 5.1)
24
+ tzinfo (~> 2.0)
25
+ zeitwerk (~> 2.3)
26
+ ast (2.4.1)
27
+ concurrent-ruby (1.1.8)
28
+ diff-lcs (1.4.4)
29
+ globalid (0.4.2)
31
30
  activesupport (>= 4.2.0)
32
- i18n (1.3.0)
31
+ i18n (1.8.7)
33
32
  concurrent-ruby (~> 1.0)
34
- jaro_winkler (1.5.1)
35
- minitest (5.11.3)
36
- mysql2 (0.5.2)
37
- parallel (1.12.1)
38
- parser (2.5.3.0)
39
- ast (~> 2.4.0)
40
- pg (1.1.3)
41
- powerpack (0.1.2)
33
+ minitest (5.14.3)
34
+ mysql2 (0.5.3)
35
+ parallel (1.20.1)
36
+ parser (3.0.0.0)
37
+ ast (~> 2.4.1)
38
+ pg (1.2.3)
39
+ rack (2.2.3)
42
40
  rainbow (3.0.0)
43
- rake (12.3.2)
44
- rspec (3.8.0)
45
- rspec-core (~> 3.8.0)
46
- rspec-expectations (~> 3.8.0)
47
- rspec-mocks (~> 3.8.0)
48
- rspec-core (3.8.0)
49
- rspec-support (~> 3.8.0)
50
- rspec-expectations (3.8.2)
41
+ rake (13.0.3)
42
+ regexp_parser (2.0.3)
43
+ rexml (3.2.4)
44
+ rspec (3.10.0)
45
+ rspec-core (~> 3.10.0)
46
+ rspec-expectations (~> 3.10.0)
47
+ rspec-mocks (~> 3.10.0)
48
+ rspec-core (3.10.1)
49
+ rspec-support (~> 3.10.0)
50
+ rspec-expectations (3.10.1)
51
51
  diff-lcs (>= 1.2.0, < 2.0)
52
- rspec-support (~> 3.8.0)
53
- rspec-mocks (3.8.0)
52
+ rspec-support (~> 3.10.0)
53
+ rspec-mocks (3.10.1)
54
54
  diff-lcs (>= 1.2.0, < 2.0)
55
- rspec-support (~> 3.8.0)
56
- rspec-support (3.8.0)
57
- rubocop (0.61.1)
58
- jaro_winkler (~> 1.5.1)
55
+ rspec-support (~> 3.10.0)
56
+ rspec-support (3.10.1)
57
+ rubocop (1.8.1)
59
58
  parallel (~> 1.10)
60
- parser (>= 2.5, != 2.5.1.1)
61
- powerpack (~> 0.1)
59
+ parser (>= 3.0.0.0)
62
60
  rainbow (>= 2.2.2, < 4.0)
61
+ regexp_parser (>= 1.8, < 3.0)
62
+ rexml
63
+ rubocop-ast (>= 1.2.0, < 2.0)
63
64
  ruby-progressbar (~> 1.7)
64
- unicode-display_width (~> 1.4.0)
65
- ruby-progressbar (1.10.0)
66
- sqlite3 (1.3.13)
67
- thread_safe (0.3.6)
68
- tzinfo (1.2.5)
69
- thread_safe (~> 0.1)
70
- unicode-display_width (1.4.0)
65
+ unicode-display_width (>= 1.4.0, < 3.0)
66
+ rubocop-ast (1.4.0)
67
+ parser (>= 2.7.1.5)
68
+ rubocop-bsm (0.5.4)
69
+ rubocop (~> 1.0)
70
+ rubocop-performance
71
+ rubocop-rails
72
+ rubocop-rake
73
+ rubocop-rspec
74
+ rubocop-performance (1.9.2)
75
+ rubocop (>= 0.90.0, < 2.0)
76
+ rubocop-ast (>= 0.4.0)
77
+ rubocop-rails (2.9.1)
78
+ activesupport (>= 4.2.0)
79
+ rack (>= 1.1)
80
+ rubocop (>= 0.90.0, < 2.0)
81
+ rubocop-rake (0.5.1)
82
+ rubocop
83
+ rubocop-rspec (2.1.0)
84
+ rubocop (~> 1.0)
85
+ rubocop-ast (>= 1.1.0)
86
+ ruby-progressbar (1.11.0)
87
+ sqlite3 (1.4.2)
88
+ tzinfo (2.0.4)
89
+ concurrent-ruby (~> 1.0)
90
+ unicode-display_width (2.0.0)
91
+ zeitwerk (2.4.2)
71
92
 
72
93
  PLATFORMS
73
94
  ruby
@@ -79,8 +100,8 @@ DEPENDENCIES
79
100
  pg
80
101
  rake
81
102
  rspec
82
- rubocop
103
+ rubocop-bsm
83
104
  sqlite3
84
105
 
85
106
  BUNDLED WITH
86
- 1.17.2
107
+ 2.1.4
data/bin/fleiss CHANGED
@@ -5,20 +5,20 @@ $LOAD_PATH.push(lib_dir) unless $LOAD_PATH.include?(lib_dir)
5
5
 
6
6
  require 'fleiss/cli'
7
7
 
8
- STDOUT.sync = true
9
- STDERR.sync = true
8
+ $stdout.sync = true
9
+ $stderr.sync = true
10
10
 
11
11
  cli = Fleiss::CLI.instance
12
12
  begin
13
13
  cli.parse!
14
14
  cli.run!
15
15
  rescue ArgumentError => e
16
- STDERR.puts " ! #{e.message}\n"
17
- STDERR.puts
18
- STDERR.puts cli.parser
16
+ warn " ! #{e.message}\n"
17
+ $stderr.puts
18
+ warn cli.parser
19
19
  exit 1
20
20
  rescue StandardError => e
21
- STDERR.puts e.message
22
- STDERR.puts e.backtrace.join("\n")
21
+ warn e.message
22
+ warn e.backtrace.join("\n")
23
23
  exit 1
24
24
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'fleiss'
3
- s.version = '0.2.0'
3
+ s.version = '0.4.1'
4
4
  s.authors = ['Black Square Media Ltd']
5
5
  s.email = ['info@blacksquaremedia.com']
6
6
  s.summary = %(Minimialist background jobs backed by ActiveJob and ActiveRecord.)
@@ -12,10 +12,10 @@ Gem::Specification.new do |s|
12
12
  s.files = `git ls-files -z`.split("\x0").reject {|f| f.match(%r{^spec/}) }
13
13
  s.test_files = `git ls-files -z -- spec/*`.split("\x0")
14
14
  s.require_paths = ['lib']
15
- s.required_ruby_version = '>= 2.2'
15
+ s.required_ruby_version = '>= 2.6'
16
16
 
17
- s.add_dependency 'activejob', '>= 5.0'
18
- s.add_dependency 'activerecord', '>= 5.0'
17
+ s.add_dependency 'activejob', '>= 6.0'
18
+ s.add_dependency 'activerecord', '>= 6.0'
19
19
  s.add_dependency 'concurrent-ruby'
20
20
 
21
21
  s.add_development_dependency 'bundler'
@@ -23,6 +23,6 @@ Gem::Specification.new do |s|
23
23
  s.add_development_dependency 'pg'
24
24
  s.add_development_dependency 'rake'
25
25
  s.add_development_dependency 'rspec'
26
- s.add_development_dependency 'rubocop'
26
+ s.add_development_dependency 'rubocop-bsm'
27
27
  s.add_development_dependency 'sqlite3'
28
28
  end
@@ -6,6 +6,10 @@ module Fleiss
6
6
  DEFAULT_QUEUE = 'default'.freeze
7
7
 
8
8
  def self.backend
9
- self::Backend::ActiveRecord
9
+ @backend ||= self::Backend::ActiveRecord
10
+ end
11
+
12
+ def self.backend=(value)
13
+ @backend = value
10
14
  end
11
15
  end
@@ -8,15 +8,21 @@ module Fleiss
8
8
  scope :in_queue, ->(qs) { where(queue_name: Array.wrap(qs)) }
9
9
  scope :finished, -> { where.not(finished_at: nil) }
10
10
  scope :not_finished, -> { where(finished_at: nil) }
11
- scope :not_expired, ->(now=Time.zone.now) { where(arel_table[:expires_at].eq(nil).or(arel_table[:expires_at].gt(now))) }
11
+ scope :not_expired, lambda {|now = Time.zone.now|
12
+ where(arel_table[:expires_at].eq(nil).or(arel_table[:expires_at].gt(now)))
13
+ }
12
14
  scope :started, -> { where(arel_table[:started_at].not_eq(nil)) }
13
15
  scope :not_started, -> { where(arel_table[:started_at].eq(nil)) }
14
- scope :scheduled, ->(now=Time.zone.now) { where(arel_table[:scheduled_at].gt(now)) }
16
+ scope :scheduled, ->(now = Time.zone.now) { where(arel_table[:scheduled_at].gt(now)) }
15
17
  end
16
18
 
17
19
  module ClassMethods
20
+ def wrap_perform(&block)
21
+ connection_pool.with_connection(&block)
22
+ end
23
+
18
24
  # @return [ActiveRecord::Relation] pending scope
19
- def pending(now=Time.zone.now)
25
+ def pending(now = Time.zone.now)
20
26
  not_finished
21
27
  .not_expired(now)
22
28
  .not_started
@@ -98,9 +104,12 @@ module Fleiss
98
104
  private
99
105
 
100
106
  def with_isolation(&block)
101
- return yield unless self.class.connection.supports_transaction_isolation?
102
-
103
- self.class.transaction(isolation: :repeatable_read, &block)
107
+ conn = self.class.connection
108
+ if conn.supports_transaction_isolation? && conn.adapter_name != 'SQLite'
109
+ self.class.transaction(isolation: :repeatable_read, &block)
110
+ else
111
+ yield
112
+ end
104
113
  end
105
114
  end
106
115
  end
@@ -3,7 +3,7 @@ require 'fleiss/backend/active_record'
3
3
  module Fleiss
4
4
  module Backend
5
5
  class ActiveRecord
6
- class Migration < ::ActiveRecord::Migration[5.0]
6
+ class Migration < ::ActiveRecord::Migration[6.0]
7
7
  def change
8
8
  create_table :fleiss_jobs do |t|
9
9
  t.string :queue_name, limit: 50, null: false
@@ -22,7 +22,7 @@ module Fleiss
22
22
  @opts = DEFAULT_OPTIONS.dup
23
23
  end
24
24
 
25
- def parse!(argv=ARGV)
25
+ def parse!(argv = ARGV)
26
26
  parser.parse!(argv)
27
27
 
28
28
  # Check config file
@@ -0,0 +1,22 @@
1
+ require 'fleiss'
2
+ require 'concurrent/executor/simple_executor_service'
3
+
4
+ class Fleiss::Executor < Concurrent::SimpleExecutorService
5
+ attr_reader :max_size
6
+
7
+ def post(&block)
8
+ super unless capacity.zero?
9
+ end
10
+
11
+ def capacity
12
+ val = @max_size - @count.value
13
+ val.positive? ? val : 0
14
+ end
15
+
16
+ private
17
+
18
+ def ns_initialize(opts = {})
19
+ super()
20
+ @max_size = opts.fetch(:max_size, 1).to_i
21
+ end
22
+ end
@@ -1,6 +1,5 @@
1
1
  require 'fleiss'
2
- require 'concurrent/executor/fixed_thread_pool'
3
- require 'concurrent/atomic/atomic_fixnum'
2
+ require 'fleiss/executor'
4
3
  require 'securerandom'
5
4
 
6
5
  class Fleiss::Worker
@@ -20,13 +19,13 @@ class Fleiss::Worker
20
19
  def initialize(queues: [Fleiss::DEFAULT_QUEUE], concurrency: 10, wait_time: 1)
21
20
  @uuid = SecureRandom.uuid
22
21
  @queues = Array(queues)
23
- @pool = Concurrent::FixedThreadPool.new(concurrency, fallback_policy: :discard)
22
+ @pool = Fleiss::Executor.new(max_size: concurrency)
24
23
  @wait_time = wait_time
25
24
  end
26
25
 
27
26
  # Run starts the worker
28
27
  def run
29
- log(:info) { "Worker #{uuid} starting - queues: #{queues.inspect}, concurrency: #{@pool.max_length}" }
28
+ log(:info) { "Worker #{uuid} starting - queues: #{queues.inspect}, concurrency: #{@pool.max_size}" }
30
29
  loop do
31
30
  run_cycle
32
31
  sleep @wait_time
@@ -50,19 +49,21 @@ class Fleiss::Worker
50
49
  end
51
50
 
52
51
  def run_cycle
53
- return if @pool.shuttingdown?
52
+ return unless @pool.running?
54
53
 
55
- capacity = @pool.max_length - @pool.scheduled_task_count + @pool.completed_task_count
56
- return unless capacity.positive?
54
+ limit = @pool.capacity
55
+ return unless limit.positive?
57
56
 
58
57
  batch = Fleiss.backend
59
58
  .in_queue(queues)
60
59
  .pending
61
- .limit(capacity)
60
+ .limit(limit)
62
61
  .to_a
63
62
 
64
63
  batch.each do |job|
65
- @pool.post { perform(job) }
64
+ @pool.post do
65
+ Fleiss.backend.wrap_perform { perform(job) }
66
+ end
66
67
  end
67
68
  rescue StandardError => e
68
69
  handle_exception e, 'running cycle'
@@ -5,7 +5,7 @@ RSpec.describe Fleiss::Backend::ActiveRecord do
5
5
  described_class.find(job.provider_job_id)
6
6
  end
7
7
 
8
- it 'should persist jobs' do
8
+ it 'persists jobs' do
9
9
  job = TestJob.perform_later
10
10
  rec = retrieve(job)
11
11
 
@@ -28,25 +28,25 @@ RSpec.describe Fleiss::Backend::ActiveRecord do
28
28
  )
29
29
  end
30
30
 
31
- it 'should enqueue with delay' do
31
+ it 'enqueues with delay' do
32
32
  job = TestJob.set(wait: 1.day).perform_later
33
33
  rec = retrieve(job)
34
34
  expect(rec.scheduled_at).to be_within(2.seconds).of(1.day.from_now)
35
35
  end
36
36
 
37
- it 'should enqueue with priority' do
37
+ it 'enqueues with priority' do
38
38
  job = TestJob.set(priority: 8).perform_later
39
39
  rec = retrieve(job)
40
40
  expect(rec.priority).to eq(8)
41
41
  end
42
42
 
43
- it 'should expose active job ID' do
43
+ it 'exposes active job ID' do
44
44
  job = TestJob.perform_later
45
45
  rec = retrieve(job)
46
46
  expect(rec.job_id.size).to eq(36)
47
47
  end
48
48
 
49
- it 'should scope pending' do
49
+ it 'scopes pending' do
50
50
  j1 = TestJob.perform_later
51
51
  expect(retrieve(j1).start('owner')).to be_truthy
52
52
  expect(retrieve(j1).finish('owner')).to be_truthy
@@ -58,7 +58,7 @@ RSpec.describe Fleiss::Backend::ActiveRecord do
58
58
  expect(described_class.pending.ids).to eq [j4.provider_job_id, j2.provider_job_id]
59
59
  end
60
60
 
61
- it 'should scope in_progress' do
61
+ it 'scopes in_progress' do
62
62
  _j1 = TestJob.perform_later
63
63
  j2 = TestJob.perform_later
64
64
  expect(retrieve(j2).start('owner')).to be_truthy
@@ -72,14 +72,14 @@ RSpec.describe Fleiss::Backend::ActiveRecord do
72
72
  expect(described_class.in_progress('owner').ids).to eq [j2.provider_job_id]
73
73
  end
74
74
 
75
- it 'should scope by queue' do
75
+ it 'scopes by queue' do
76
76
  j1 = TestJob.perform_later
77
77
  j2 = TestJob.set(queue: 'other').perform_later
78
78
  expect(described_class.in_queue('test-queue').ids).to eq [j1.provider_job_id]
79
79
  expect(described_class.in_queue('other').ids).to eq [j2.provider_job_id]
80
80
  end
81
81
 
82
- it 'should start' do
82
+ it 'starts' do
83
83
  job = TestJob.perform_later
84
84
  rec = retrieve(job)
85
85
  expect(rec.start('owner')).to be_truthy
@@ -88,7 +88,7 @@ RSpec.describe Fleiss::Backend::ActiveRecord do
88
88
  expect(rec.started_at).to be_within(2.seconds).of(Time.zone.now)
89
89
  end
90
90
 
91
- it 'should lock atomically' do
91
+ it 'locks atomically' do
92
92
  24.times do
93
93
  TestJob.perform_later
94
94
  end
@@ -100,7 +100,7 @@ RSpec.describe Fleiss::Backend::ActiveRecord do
100
100
  expect(counts.sum).to eq(24)
101
101
  end
102
102
 
103
- it 'should finish' do
103
+ it 'finishes' do
104
104
  job = TestJob.perform_later
105
105
  rec = retrieve(job)
106
106
  expect(rec.finish('owner')).to be_falsey
@@ -112,7 +112,7 @@ RSpec.describe Fleiss::Backend::ActiveRecord do
112
112
  expect(rec.finished_at).to be_within(2.seconds).of(Time.zone.now)
113
113
  end
114
114
 
115
- it 'should reschedule' do
115
+ it 'reschedules' do
116
116
  job = TestJob.perform_later
117
117
  rec = retrieve(job)
118
118
  expect(rec.reschedule('owner')).to be_falsey
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+ require 'fleiss/executor'
3
+
4
+ RSpec.describe Fleiss::Executor do
5
+ subject { described_class.new max_size: 2 }
6
+
7
+ after { subject.kill }
8
+
9
+ it 'checks capacity' do
10
+ expect(described_class.new.capacity).to eq(1)
11
+
12
+ expect(subject.capacity).to eq(2)
13
+ subject.post { sleep(1) }
14
+ expect(subject.capacity).to eq(1)
15
+ subject.post { sleep(1) }
16
+ expect(subject.capacity).to eq(0)
17
+ end
18
+
19
+ it 'discards execution when capacity is reached' do
20
+ n = Concurrent::AtomicFixnum.new(0)
21
+ 10.times do
22
+ 10.times { subject.post { n.increment } }
23
+ sleep(0.001)
24
+ end
25
+ subject.shutdown
26
+ subject.wait_for_termination(1)
27
+ expect(n.value).to be_within(10).of(20)
28
+ end
29
+ end
@@ -25,7 +25,7 @@ RSpec.describe Fleiss::Worker do
25
25
  expect(yield).to be_truthy
26
26
  end
27
27
 
28
- it 'should run' do
28
+ it 'runs' do
29
29
  # seed 24 jobs
30
30
  24.times {|n| TestJob.perform_later(n) }
31
31
  wait_for { Fleiss.backend.not_finished.count.positive? }
@@ -39,7 +39,7 @@ RSpec.describe Fleiss::Worker do
39
39
  expect(TestJob.performed).to match_array(0..23)
40
40
  end
41
41
 
42
- it 'should handle failing jobs' do
42
+ it 'handles failing jobs' do
43
43
  TestJob.perform_later('raise')
44
44
  wait_for { Fleiss.backend.not_finished.count.zero? }
45
45
  expect(Fleiss.backend.finished.count).to eq(1)
@@ -1,11 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  RSpec.describe Fleiss do
4
- it 'should have a backend' do
4
+ it 'has a backend' do
5
5
  expect(described_class.backend).to eq(Fleiss::Backend::ActiveRecord)
6
6
  end
7
7
 
8
- it 'should enqueue' do
8
+ it 'enqueues' do
9
9
  expect do
10
10
  TestJob.set(wait: 1.week).perform_later
11
11
  end.to change { described_class.backend.count }.by(1)
@@ -5,15 +5,19 @@ require 'fleiss'
5
5
  require 'fleiss/backend/active_record/migration'
6
6
  require 'active_job'
7
7
  require 'active_job/queue_adapters/fleiss_adapter'
8
- require 'tempfile'
8
+ require 'fileutils'
9
9
 
10
10
  ActiveJob::Base.queue_adapter = :fleiss
11
11
  ActiveJob::Base.logger = Logger.new(nil)
12
12
 
13
13
  Time.zone_default = Time.find_zone!('UTC')
14
14
 
15
- database_url = ENV['DATABASE_URL'] || "sqlite3://#{Tempfile.new(['fleiss-test', '.sqlite3']).path}"
16
- ActiveRecord::Base.configurations['test'] = { 'url' => database_url, 'pool' => 20 }
15
+ tmpdir = File.expand_path('./tmp', __dir__)
16
+ FileUtils.rm_rf tmpdir
17
+ FileUtils.mkdir_p tmpdir
18
+
19
+ database_url = ENV['DATABASE_URL'] || "sqlite3://#{tmpdir}/fleiss-test.sqlite3"
20
+ ActiveRecord::Base.configurations = { 'test' => { 'url' => database_url, 'pool' => 20 } }
17
21
 
18
22
  ActiveRecord::Base.establish_connection :test
19
23
  ActiveRecord::Base.connection.drop_table('fleiss_jobs', if_exists: true)
@@ -32,7 +36,7 @@ class TestJob < ActiveJob::Base
32
36
  72.hours
33
37
  end
34
38
 
35
- def perform(msg=nil)
39
+ def perform(msg = nil)
36
40
  raise 'Failing' if msg == 'raise'
37
41
 
38
42
  self.class.performed.push(msg)
@@ -40,7 +44,7 @@ class TestJob < ActiveJob::Base
40
44
  end
41
45
 
42
46
  RSpec.configure do |c|
43
- c.after :each do
47
+ c.after do
44
48
  TestJob.performed.clear
45
49
  Fleiss.backend.delete_all
46
50
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fleiss
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Black Square Media Ltd
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-20 00:00:00.000000000 Z
11
+ date: 2021-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5.0'
19
+ version: '6.0'
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
- version: '5.0'
26
+ version: '6.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '5.0'
33
+ version: '6.0'
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
- version: '5.0'
40
+ version: '6.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: concurrent-ruby
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -123,7 +123,7 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: rubocop
126
+ name: rubocop-bsm
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="
@@ -176,8 +176,10 @@ files:
176
176
  - lib/fleiss/backend/active_record/concern.rb
177
177
  - lib/fleiss/backend/active_record/migration.rb
178
178
  - lib/fleiss/cli.rb
179
+ - lib/fleiss/executor.rb
179
180
  - lib/fleiss/worker.rb
180
181
  - spec/fleiss/backend/active_record_spec.rb
182
+ - spec/fleiss/executor_spec.rb
181
183
  - spec/fleiss/worker_spec.rb
182
184
  - spec/fleiss_spec.rb
183
185
  - spec/spec_helper.rb
@@ -193,20 +195,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
193
195
  requirements:
194
196
  - - ">="
195
197
  - !ruby/object:Gem::Version
196
- version: '2.2'
198
+ version: '2.6'
197
199
  required_rubygems_version: !ruby/object:Gem::Requirement
198
200
  requirements:
199
201
  - - ">="
200
202
  - !ruby/object:Gem::Version
201
203
  version: '0'
202
204
  requirements: []
203
- rubyforge_project:
204
- rubygems_version: 2.7.7
205
+ rubygems_version: 3.1.4
205
206
  signing_key:
206
207
  specification_version: 4
207
208
  summary: Minimialist background jobs backed by ActiveJob and ActiveRecord.
208
209
  test_files:
209
210
  - spec/fleiss/backend/active_record_spec.rb
211
+ - spec/fleiss/executor_spec.rb
210
212
  - spec/fleiss/worker_spec.rb
211
213
  - spec/fleiss_spec.rb
212
214
  - spec/spec_helper.rb