sidekiq-cron 1.9.0 → 1.9.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: b26393b7aa972d9a769d851269600f51c61feff8c3d2b5cbe611eed0e21b704d
4
- data.tar.gz: 1822ffdf4ebe54db931394f38acf3eca8552953396d8fc1848aa3ec89d1164d1
3
+ metadata.gz: 4d751ce0280b4d30f1f43a1e0ed973166c2f398d7ac976e6fea267e66e999bb8
4
+ data.tar.gz: 352b64238d89eb4eedb0e9c046f9d54f6f298c376804de1066cbdad3481c43af
5
5
  SHA512:
6
- metadata.gz: 8fe8be5571ecb428191894a7d433fd6b2f8098607ad4de23f7cfe030b71895eed66cc8a218bf53684b235a5422b4895a676963f7bc02ab1deb06fae4982a34db
7
- data.tar.gz: b75e0b6928d263590ba7a97beca37205bd50123d0118ee49312a106573bf1a7b640f75c8ef1f76198a3da94fe19a6c9c9fa4bd3d357898590f251732d9a34d43
6
+ metadata.gz: ee7843b8dd62b31954de3db17c4cef76229050d2c4590bde276c77d6ad2c96bbb523620631ad41574d4b976ace4da6425130b1aa5c4a20986c4d42fdcdde1ef4
7
+ data.tar.gz: 95e74c836bdae7eb10fe1fe540fdc91ecb730c3a73bc1dd7e578d9324cf448e32054e9ad1b487036119076e966b0df1011978aa34b9215a334d996759d4bb684
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## 1.9.1
6
+
7
+ - Always enqueue via Active Job interface when defined in cron job config (https://github.com/sidekiq-cron/sidekiq-cron/pull/381)
8
+ - Fix schedule.yml YAML load errors on Ruby 3.1 (https://github.com/sidekiq-cron/sidekiq-cron/pull/386)
9
+ - Require Fugit v1.8 to refactor internals (https://github.com/sidekiq-cron/sidekiq-cron/pull/385)
10
+
5
11
  ## 1.9.0
6
12
 
7
13
  - Sidekiq v7 support (https://github.com/sidekiq-cron/sidekiq-cron/pull/369)
@@ -56,7 +56,7 @@ module Sidekiq
56
56
 
57
57
  jid =
58
58
  if klass_const
59
- if defined?(ActiveJob::Base) && klass_const < ActiveJob::Base
59
+ if is_active_job?(klass_const)
60
60
  enqueue_active_job(klass_const).try :provider_job_id
61
61
  else
62
62
  enqueue_sidekiq_worker(klass_const)
@@ -74,8 +74,8 @@ module Sidekiq
74
74
  Sidekiq.logger.debug { "enqueued #{@name}: #{@message}" }
75
75
  end
76
76
 
77
- def is_active_job?
78
- @active_job || defined?(ActiveJob::Base) && Sidekiq::Cron::Support.constantize(@klass.to_s) < ActiveJob::Base
77
+ def is_active_job?(klass = nil)
78
+ @active_job || defined?(ActiveJob::Base) && (klass || Sidekiq::Cron::Support.constantize(@klass.to_s)) < ActiveJob::Base
79
79
  rescue NameError
80
80
  false
81
81
  end
@@ -428,15 +428,7 @@ module Sidekiq
428
428
  errors << "'cron' must be set"
429
429
  else
430
430
  begin
431
- c = Fugit.do_parse(@cron)
432
-
433
- # Since `Fugit.do_parse` might yield a Fugit::Duration or an EtOrbi::EoTime
434
- # https://github.com/floraison/fugit#fugitparses
435
- if c.is_a?(Fugit::Cron)
436
- @parsed_cron = c
437
- else
438
- errors << "'cron' -> #{@cron.inspect} -> not a cron but a #{c.class}"
439
- end
431
+ @parsed_cron = Fugit.do_parse_cronish(@cron)
440
432
  rescue => e
441
433
  errors << "'cron' -> #{@cron.inspect} -> #{e.class}: #{e.message}"
442
434
  end
@@ -565,19 +557,7 @@ module Sidekiq
565
557
  private
566
558
 
567
559
  def parsed_cron
568
- @parsed_cron ||= begin
569
- c = Fugit.parse(@cron)
570
-
571
- # Since `Fugit.parse` might yield a Fugit::Duration or an EtOrbi::EoTime
572
- # https://github.com/floraison/fugit#fugitparses
573
- if c.is_a?(Fugit::Cron)
574
- c
575
- else
576
- errors << "'cron' -> #{@cron.inspect} -> not a cron but a #{c.class}"
577
- end
578
- rescue => e
579
- errors << "'cron' -> #{@cron.inspect} -> #{e.class}: #{e.message}"
580
- end
560
+ @parsed_cron ||= Fugit.parse_cronish(@cron)
581
561
  end
582
562
 
583
563
  def not_enqueued_after?(time)
@@ -8,7 +8,7 @@ if Sidekiq.server?
8
8
 
9
9
  if File.exist?(schedule_file)
10
10
  config.on(:startup) do
11
- schedule = YAML.load(ERB.new(IO.read(schedule_file)).result)
11
+ schedule = Sidekiq::Cron::Support.load_yaml(ERB.new(IO.read(schedule_file)).result)
12
12
  if schedule.kind_of?(Hash)
13
13
  Sidekiq::Cron::Job.load_from_hash schedule
14
14
  elsif schedule.kind_of?(Array)
@@ -32,6 +32,14 @@ module Sidekiq
32
32
  end
33
33
  end
34
34
  end
35
+
36
+ def self.load_yaml(src)
37
+ if Psych::VERSION > "4.0"
38
+ YAML.safe_load(src, permitted_classes: [Symbol], aliases: true)
39
+ else
40
+ YAML.load(src)
41
+ end
42
+ end
35
43
  end
36
44
  end
37
45
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sidekiq
4
4
  module Cron
5
- VERSION = "1.9.0"
5
+ VERSION = "1.9.1"
6
6
  end
7
7
  end
data/sidekiq-cron.gemspec CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
26
26
 
27
27
  s.required_ruby_version = ">= 2.6"
28
28
 
29
- s.add_dependency("fugit", "~> 1")
29
+ s.add_dependency("fugit", "~> 1.8")
30
30
  s.add_dependency("sidekiq", ">= 4.2.1")
31
31
 
32
32
  s.add_development_dependency("minitest", "~> 5.15")
@@ -1,4 +1,6 @@
1
1
  ---
2
- daily_job:
2
+ default: &default
3
3
  cron: <%= "every day at 5 pm" %>
4
4
  class: <%= "DailyJob" %>
5
+
6
+ daily_job: *default
@@ -581,6 +581,36 @@ describe "Cron Job" do
581
581
  @job.enque!
582
582
  end
583
583
  end
584
+
585
+ describe 'with active_job == true' do
586
+ before do
587
+ @args.merge!(active_job: true)
588
+ end
589
+
590
+ describe 'with active_job job class' do
591
+ before do
592
+ @job = Sidekiq::Cron::Job.new(@args.merge(klass: 'ActiveJobCronTestClass'))
593
+ end
594
+
595
+ it 'enques via active_job interface' do
596
+ @job.expects(:enqueue_active_job)
597
+ .returns(ActiveJobCronTestClass.new)
598
+ @job.enque!
599
+ end
600
+ end
601
+
602
+ describe 'with non sidekiq job class' do
603
+ before do
604
+ @job = Sidekiq::Cron::Job.new(@args.merge(klass: 'CronTestClass'))
605
+ end
606
+
607
+ it 'enques via active_job interface' do
608
+ @job.expects(:enqueue_active_job)
609
+ .returns(ActiveJobCronTestClass.new)
610
+ @job.enque!
611
+ end
612
+ end
613
+ end
584
614
  end
585
615
 
586
616
  describe 'active job with queue_name_prefix' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-cron
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0
4
+ version: 1.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ondrej Bartas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-01 00:00:00.000000000 Z
11
+ date: 2022-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fugit
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1'
19
+ version: '1.8'
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: '1'
26
+ version: '1.8'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sidekiq
29
29
  requirement: !ruby/object:Gem::Requirement