whenever 1.1.2 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +4 -2
- data/CHANGELOG.md +15 -3
- data/README.md +8 -0
- data/lib/whenever/job.rb +3 -1
- data/lib/whenever/job_list.rb +16 -3
- data/lib/whenever/job_sequence.rb +36 -0
- data/lib/whenever/version.rb +1 -1
- data/lib/whenever.rb +1 -0
- data/whenever.gemspec +1 -2
- metadata +4 -31
- data/test/functional/command_line_test.rb +0 -458
- data/test/functional/output_at_test.rb +0 -246
- data/test/functional/output_default_defined_jobs_test.rb +0 -310
- data/test/functional/output_defined_job_test.rb +0 -113
- data/test/functional/output_description_test.rb +0 -25
- data/test/functional/output_env_test.rb +0 -29
- data/test/functional/output_jobs_for_roles_test.rb +0 -65
- data/test/functional/output_jobs_with_mailto_test.rb +0 -168
- data/test/functional/output_redirection_test.rb +0 -248
- data/test/test_case.rb +0 -32
- data/test/test_helper.rb +0 -51
- data/test/unit/capistrano_support_test.rb +0 -147
- data/test/unit/cron_test.rb +0 -418
- data/test/unit/executable_test.rb +0 -142
- data/test/unit/job_test.rb +0 -114
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9797821aa7a21784824362ac3e7c4281cbbbf70ab36921f40670f15a73912be5
|
|
4
|
+
data.tar.gz: b78b898fda4aa8817c97447b584fea0e55de9351f2726ccbf88f834250262bdc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3be670ce4d4eefb9ac290d8d48f6b8c755a763bf1ba00c22350f7fb138ea47046998ce799b426a79f5342da11ac854b7ace890d72bb998c9689c588039b75540
|
|
7
|
+
data.tar.gz: a061b6512241f9d45d5be373889f7423185abcb70431c5daa429af75249cc199f5f4db1ed0cc66c414d89b659640ab1ef58dc7fb1363f952febb59a020c83ee3
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -3,6 +3,8 @@ on:
|
|
|
3
3
|
pull_request:
|
|
4
4
|
push:
|
|
5
5
|
branches: [ main ]
|
|
6
|
+
permissions:
|
|
7
|
+
contents: read
|
|
6
8
|
jobs:
|
|
7
9
|
test:
|
|
8
10
|
runs-on: ${{ matrix.os }}
|
|
@@ -23,7 +25,7 @@ jobs:
|
|
|
23
25
|
- os: macos-15-intel
|
|
24
26
|
ruby-version: '2.5'
|
|
25
27
|
steps:
|
|
26
|
-
- uses: actions/checkout@
|
|
28
|
+
- uses: actions/checkout@v7
|
|
27
29
|
name: Set up Ruby ${{ matrix.ruby-version }}
|
|
28
30
|
- uses: ruby/setup-ruby@v1
|
|
29
31
|
env:
|
|
@@ -74,7 +76,7 @@ jobs:
|
|
|
74
76
|
env:
|
|
75
77
|
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/activesupport${{ matrix.rails-version }}.gemfile
|
|
76
78
|
steps:
|
|
77
|
-
- uses: actions/checkout@
|
|
79
|
+
- uses: actions/checkout@v7
|
|
78
80
|
name: Set up Ruby ${{ matrix.ruby-version }}
|
|
79
81
|
- uses: ruby/setup-ruby@v1
|
|
80
82
|
with:
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
### unreleased
|
|
2
2
|
|
|
3
|
+
### 1.1.4 / October 21, 2026
|
|
4
|
+
|
|
5
|
+
* Don't ship tests in the gem https://github.com/javan/whenever/pull/877
|
|
6
|
+
|
|
7
|
+
### 1.1.3 / September 15, 2026
|
|
8
|
+
|
|
9
|
+
* Add support for sequential job definitions https://github.com/javan/whenever/pull/854
|
|
10
|
+
|
|
11
|
+
* CI: Bump actions/checkout from 6 to 7 https://github.com/javan/whenever/pull/876
|
|
12
|
+
|
|
13
|
+
* CI: Restrict GitHub Actions workflow permissions to contents: read https://github.com/javan/whenever/pull/875
|
|
14
|
+
|
|
3
15
|
|
|
4
16
|
### 1.1.2 / January 18, 2026
|
|
5
17
|
|
|
@@ -11,7 +23,7 @@
|
|
|
11
23
|
|
|
12
24
|
* CI: Use macos-15-intel instead of macos-13 for Ruby 2.4 and 2.5 https://github.com/javan/whenever/pull/871
|
|
13
25
|
|
|
14
|
-
### 1.1.1 /
|
|
26
|
+
### 1.1.1 / December 8, 2025
|
|
15
27
|
|
|
16
28
|
* job_list `.respond_to?` updated to an instance method https://github.com/javan/whenever/pull/830
|
|
17
29
|
|
|
@@ -23,7 +35,7 @@
|
|
|
23
35
|
|
|
24
36
|
* Require MFA for gem releases https://github.com/javan/whenever/pull/867
|
|
25
37
|
|
|
26
|
-
### 1.1.0 /
|
|
38
|
+
### 1.1.0 / November 21, 2025
|
|
27
39
|
|
|
28
40
|
* Splat whenever_roles when passing to roles https://github.com/javan/whenever/pull/777
|
|
29
41
|
|
|
@@ -161,7 +173,7 @@
|
|
|
161
173
|
* Process params in job templates. [Austin Ziegler]
|
|
162
174
|
|
|
163
175
|
|
|
164
|
-
### 0.8.4 / July 22,
|
|
176
|
+
### 0.8.4 / July 22, 2013
|
|
165
177
|
|
|
166
178
|
* Don't require schedule file when clearing. [Javan Makhmali]
|
|
167
179
|
|
data/README.md
CHANGED
|
@@ -59,6 +59,14 @@ every 3.hours do # 1.minute 1.day 1.week 1.month 1.year is also supported
|
|
|
59
59
|
command "/usr/bin/my_great_command"
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
+
every 3.hours, sequential: true do
|
|
63
|
+
# Jobs in this block that don't set their own sequence will default to run in the same sequence (not in parallel)
|
|
64
|
+
runner "MyModel.some_process", halt_sequence_on_failure: true # If this job fails, subsequent jobs will not run (defaults to false)
|
|
65
|
+
rake "my:rake:task"
|
|
66
|
+
command "/usr/bin/my_great_command", sequence: nil # This job runs in parallel with other jobs that are not part of a sequence
|
|
67
|
+
runner "MyModel.task_to_run_at_four_thirty_in_the_morning", sequence: 'other' # This job runs sequentially with other jobs in the sequence called 'other'
|
|
68
|
+
end
|
|
69
|
+
|
|
62
70
|
every 1.day, at: '4:30 am' do
|
|
63
71
|
runner "MyModel.task_to_run_at_four_thirty_in_the_morning"
|
|
64
72
|
end
|
data/lib/whenever/job.rb
CHANGED
|
@@ -2,7 +2,7 @@ require 'shellwords'
|
|
|
2
2
|
|
|
3
3
|
module Whenever
|
|
4
4
|
class Job
|
|
5
|
-
attr_reader :at, :roles, :mailto, :description
|
|
5
|
+
attr_reader :at, :roles, :mailto, :description, :sequence, :halt_sequence_on_failure
|
|
6
6
|
|
|
7
7
|
def initialize(options = {})
|
|
8
8
|
@options = options
|
|
@@ -10,6 +10,8 @@ module Whenever
|
|
|
10
10
|
@template = options.delete(:template)
|
|
11
11
|
@mailto = options.fetch(:mailto, :default_mailto)
|
|
12
12
|
@job_template = options.delete(:job_template) || ":job"
|
|
13
|
+
@sequence = options.delete(:sequence)
|
|
14
|
+
@halt_sequence_on_failure = options.delete(:halt_sequence_on_failure)
|
|
13
15
|
@roles = Array(options.delete(:roles))
|
|
14
16
|
@description = options.delete(:description)
|
|
15
17
|
@options[:output] = options.has_key?(:output) ? Whenever::Output::Redirection.new(options[:output]).to_s : ''
|
data/lib/whenever/job_list.rb
CHANGED
|
@@ -48,6 +48,12 @@ module Whenever
|
|
|
48
48
|
def every(frequency, options = {})
|
|
49
49
|
@current_time_scope = frequency
|
|
50
50
|
@options = options
|
|
51
|
+
|
|
52
|
+
if @options[:sequential]
|
|
53
|
+
@default_sequence_id ||= 0
|
|
54
|
+
@options[:sequence] ||= "default_sequence_#{@default_sequence_id += 1}"
|
|
55
|
+
end
|
|
56
|
+
|
|
51
57
|
yield
|
|
52
58
|
end
|
|
53
59
|
|
|
@@ -138,10 +144,17 @@ module Whenever
|
|
|
138
144
|
def cron_jobs_of_time(time, jobs)
|
|
139
145
|
shortcut_jobs, regular_jobs = [], []
|
|
140
146
|
|
|
147
|
+
filtered_jobs = jobs.select do |job|
|
|
148
|
+
roles.empty? || roles.any? { |r| job.has_role?(r) }
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
grouped_jobs = filtered_jobs.group_by(&:sequence)
|
|
152
|
+
grouped_jobs.each do |sequence, jobs|
|
|
153
|
+
grouped_jobs[sequence] = JobSequence.new(jobs) if sequence
|
|
154
|
+
end
|
|
155
|
+
jobs = grouped_jobs.values.flatten
|
|
156
|
+
|
|
141
157
|
jobs.each do |job|
|
|
142
|
-
next unless roles.empty? || roles.any? do |r|
|
|
143
|
-
job.has_role?(r)
|
|
144
|
-
end
|
|
145
158
|
Whenever::Output::Cron.output(time, job, :chronic_options => @chronic_options) do |cron|
|
|
146
159
|
cron << "\n\n"
|
|
147
160
|
cron = (job.description.strip + "\n").gsub(/^(.*)$/, '# \1') + cron unless job.description.to_s.empty?
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require 'shellwords'
|
|
2
|
+
|
|
3
|
+
module Whenever
|
|
4
|
+
class JobSequence
|
|
5
|
+
attr_reader :at, :roles, :mailto, :description
|
|
6
|
+
|
|
7
|
+
def initialize(jobs, options = {})
|
|
8
|
+
validate!(jobs)
|
|
9
|
+
|
|
10
|
+
@jobs = jobs
|
|
11
|
+
@options = options
|
|
12
|
+
@at = options.fetch(:at, primary_job.at)
|
|
13
|
+
@mailto = options.fetch(:mailto, primary_job.mailto || :default_mailto)
|
|
14
|
+
@roles = Array(options.delete(:roles), *primary_job.roles)
|
|
15
|
+
@description = options.fetch(:description) { @jobs.map { |job| job.description.to_s.strip }.reject(&:empty?).uniq.join("\n") }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def output
|
|
19
|
+
@jobs.map { |job| [job.output, job.halt_sequence_on_failure ? ' && ' : ' ; '] }.flatten[0..-2].join
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def has_role?(role)
|
|
23
|
+
roles.empty? || roles.include?(role)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def primary_job
|
|
29
|
+
@jobs.first
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def validate!(jobs)
|
|
33
|
+
raise ArgumentError, "Jobs in a sequence don't support different `at` values" if jobs.map(&:at).uniq.count > 1
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
data/lib/whenever/version.rb
CHANGED
data/lib/whenever.rb
CHANGED
data/whenever.gemspec
CHANGED
|
@@ -20,8 +20,7 @@ Gem::Specification.new do |spec|
|
|
|
20
20
|
spec.metadata["changelog_uri"] = "https://github.com/javan/whenever/blob/main/CHANGELOG.md"
|
|
21
21
|
spec.metadata["rubygems_mfa_required"] = "true"
|
|
22
22
|
|
|
23
|
-
spec.files = `git ls-files`.split("\n")
|
|
24
|
-
spec.test_files = `git ls-files -- test/{functional,unit}/*`.split("\n")
|
|
23
|
+
spec.files = `git ls-files`.split("\n").reject { |f| f.start_with?("test/") }
|
|
25
24
|
spec.executables = spec.files.grep(%r{\Abin/}) { |f| File.basename(f) }
|
|
26
25
|
spec.require_paths = ["lib"]
|
|
27
26
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: whenever
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Javan Makhmali
|
|
@@ -65,27 +65,13 @@ files:
|
|
|
65
65
|
- lib/whenever/cron.rb
|
|
66
66
|
- lib/whenever/job.rb
|
|
67
67
|
- lib/whenever/job_list.rb
|
|
68
|
+
- lib/whenever/job_sequence.rb
|
|
68
69
|
- lib/whenever/numeric.rb
|
|
69
70
|
- lib/whenever/numeric_seconds.rb
|
|
70
71
|
- lib/whenever/os.rb
|
|
71
72
|
- lib/whenever/output_redirection.rb
|
|
72
73
|
- lib/whenever/setup.rb
|
|
73
74
|
- lib/whenever/version.rb
|
|
74
|
-
- test/functional/command_line_test.rb
|
|
75
|
-
- test/functional/output_at_test.rb
|
|
76
|
-
- test/functional/output_default_defined_jobs_test.rb
|
|
77
|
-
- test/functional/output_defined_job_test.rb
|
|
78
|
-
- test/functional/output_description_test.rb
|
|
79
|
-
- test/functional/output_env_test.rb
|
|
80
|
-
- test/functional/output_jobs_for_roles_test.rb
|
|
81
|
-
- test/functional/output_jobs_with_mailto_test.rb
|
|
82
|
-
- test/functional/output_redirection_test.rb
|
|
83
|
-
- test/test_case.rb
|
|
84
|
-
- test/test_helper.rb
|
|
85
|
-
- test/unit/capistrano_support_test.rb
|
|
86
|
-
- test/unit/cron_test.rb
|
|
87
|
-
- test/unit/executable_test.rb
|
|
88
|
-
- test/unit/job_test.rb
|
|
89
75
|
- whenever.gemspec
|
|
90
76
|
homepage: https://github.com/javan/whenever
|
|
91
77
|
licenses:
|
|
@@ -109,20 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
109
95
|
- !ruby/object:Gem::Version
|
|
110
96
|
version: '0'
|
|
111
97
|
requirements: []
|
|
112
|
-
rubygems_version: 4.0.
|
|
98
|
+
rubygems_version: 4.0.20
|
|
113
99
|
specification_version: 4
|
|
114
100
|
summary: Cron jobs in ruby.
|
|
115
|
-
test_files:
|
|
116
|
-
- test/functional/command_line_test.rb
|
|
117
|
-
- test/functional/output_at_test.rb
|
|
118
|
-
- test/functional/output_default_defined_jobs_test.rb
|
|
119
|
-
- test/functional/output_defined_job_test.rb
|
|
120
|
-
- test/functional/output_description_test.rb
|
|
121
|
-
- test/functional/output_env_test.rb
|
|
122
|
-
- test/functional/output_jobs_for_roles_test.rb
|
|
123
|
-
- test/functional/output_jobs_with_mailto_test.rb
|
|
124
|
-
- test/functional/output_redirection_test.rb
|
|
125
|
-
- test/unit/capistrano_support_test.rb
|
|
126
|
-
- test/unit/cron_test.rb
|
|
127
|
-
- test/unit/executable_test.rb
|
|
128
|
-
- test/unit/job_test.rb
|
|
101
|
+
test_files: []
|