whenever 1.1.1 → 1.1.2
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 -4
- data/CHANGELOG.md +10 -0
- data/README.md +20 -0
- data/lib/whenever/job.rb +2 -1
- data/lib/whenever/job_list.rb +2 -1
- data/lib/whenever/version.rb +1 -1
- data/test/functional/output_defined_job_test.rb +28 -0
- data/test/functional/output_description_test.rb +25 -0
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e6e3f0d94253d0ac6d5a7f856afeb690b25f83a551e74581ebcc3cb0320855bc
|
|
4
|
+
data.tar.gz: 8d8ccccb89a2d7e4c5dd8d6744314888c88928a0bf7b6b3ed2bc7e195cae4290
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f7942baf77e31bb83add51eea178e5ff11d724196a23cc45a47668813acb8ce428f1ab27ca806544ee935e67b8d164a6586e0a6bfda8eb33afb2ef0ea33c88d8
|
|
7
|
+
data.tar.gz: 30691f3aa03c58df894d3d516c21fedd9a6a3d23563ebaa9d267977b59a822c37071f4fc3663aae115f008865f426a899ce436badbb6883643aaa24b7e2a146c
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -10,7 +10,7 @@ jobs:
|
|
|
10
10
|
fail-fast: false
|
|
11
11
|
matrix:
|
|
12
12
|
os: [ubuntu-latest, macos-latest]
|
|
13
|
-
ruby-version: [ '2.4', '2.5', '2.6', '2.7', '3.0', '3.0', '3.2', '3.3', '3.4', 'jruby-9', 'jruby-10']
|
|
13
|
+
ruby-version: [ '2.4', '2.5', '2.6', '2.7', '3.0', '3.0', '3.2', '3.3', '3.4', '4.0', 'jruby-9', 'jruby-10']
|
|
14
14
|
# CRuby < 2.6 does not support macos-arm64, so test those on amd64 instead
|
|
15
15
|
exclude:
|
|
16
16
|
- os: macos-latest
|
|
@@ -18,9 +18,9 @@ jobs:
|
|
|
18
18
|
- os: macos-latest
|
|
19
19
|
ruby-version: '2.5'
|
|
20
20
|
include:
|
|
21
|
-
- os: macos-
|
|
21
|
+
- os: macos-15-intel
|
|
22
22
|
ruby-version: '2.4'
|
|
23
|
-
- os: macos-
|
|
23
|
+
- os: macos-15-intel
|
|
24
24
|
ruby-version: '2.5'
|
|
25
25
|
steps:
|
|
26
26
|
- uses: actions/checkout@v6
|
|
@@ -42,7 +42,7 @@ jobs:
|
|
|
42
42
|
strategy:
|
|
43
43
|
fail-fast: false
|
|
44
44
|
matrix:
|
|
45
|
-
ruby-version: ['2.7', '3.0', '3.0', '3.2', '3.3', '3.4']
|
|
45
|
+
ruby-version: ['2.7', '3.0', '3.0', '3.2', '3.3', '3.4', '4.0']
|
|
46
46
|
rails-version: ['6.0', '6.1', '7.0', '7.1', '7.2', '8.0', '8.1']
|
|
47
47
|
include:
|
|
48
48
|
- ruby-version: 2.7
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
### unreleased
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
### 1.1.2 / January 18, 2026
|
|
5
|
+
|
|
6
|
+
* Add description as comment in crontab https://github.com/javan/whenever/pull/776
|
|
7
|
+
|
|
8
|
+
* Override global option with group option https://github.com/javan/whenever/pull/822
|
|
9
|
+
|
|
10
|
+
* CI: Add Ruby 4.0 to CI Matrix https://github.com/javan/whenever/pull/872
|
|
11
|
+
|
|
12
|
+
* CI: Use macos-15-intel instead of macos-13 for Ruby 2.4 and 2.5 https://github.com/javan/whenever/pull/871
|
|
13
|
+
|
|
4
14
|
### 1.1.1 / Dec 8, 2025
|
|
5
15
|
|
|
6
16
|
* job_list `.respond_to?` updated to an instance method https://github.com/javan/whenever/pull/830
|
data/README.md
CHANGED
|
@@ -180,6 +180,26 @@ every 3.hours do
|
|
|
180
180
|
end
|
|
181
181
|
```
|
|
182
182
|
|
|
183
|
+
### Adding comments to crontab
|
|
184
|
+
|
|
185
|
+
A description can be added to a job that will be included in the crontab as a comment above the cron entry.
|
|
186
|
+
|
|
187
|
+
Example: A single line description:
|
|
188
|
+
|
|
189
|
+
```ruby
|
|
190
|
+
every 1.hours, description: "My job description" do
|
|
191
|
+
command "/usr/bin/my_great_command"
|
|
192
|
+
end
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Example: A multi line description:
|
|
196
|
+
|
|
197
|
+
```ruby
|
|
198
|
+
every 1.hours, description: "My job description\nhas multiple lines" do
|
|
199
|
+
command "/usr/bin/my_great_command"
|
|
200
|
+
end
|
|
201
|
+
```
|
|
202
|
+
|
|
183
203
|
### Capistrano integration
|
|
184
204
|
|
|
185
205
|
Use the built-in Capistrano recipe for easy crontab updates with deploys. For Capistrano V3, see the next section.
|
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
|
|
5
|
+
attr_reader :at, :roles, :mailto, :description
|
|
6
6
|
|
|
7
7
|
def initialize(options = {})
|
|
8
8
|
@options = options
|
|
@@ -11,6 +11,7 @@ module Whenever
|
|
|
11
11
|
@mailto = options.fetch(:mailto, :default_mailto)
|
|
12
12
|
@job_template = options.delete(:job_template) || ":job"
|
|
13
13
|
@roles = Array(options.delete(:roles))
|
|
14
|
+
@description = options.delete(:description)
|
|
14
15
|
@options[:output] = options.has_key?(:output) ? Whenever::Output::Redirection.new(options[:output]).to_s : ''
|
|
15
16
|
@options[:environment_variable] ||= "RAILS_ENV"
|
|
16
17
|
@options[:environment] ||= :production
|
data/lib/whenever/job_list.rb
CHANGED
|
@@ -66,7 +66,7 @@ module Whenever
|
|
|
66
66
|
|
|
67
67
|
@jobs[options.fetch(:mailto)] ||= {}
|
|
68
68
|
@jobs[options.fetch(:mailto)][@current_time_scope] ||= []
|
|
69
|
-
@jobs[options.fetch(:mailto)][@current_time_scope] << Whenever::Job.new(@
|
|
69
|
+
@jobs[options.fetch(:mailto)][@current_time_scope] << Whenever::Job.new(@set_variables.merge(@options).merge(options))
|
|
70
70
|
end
|
|
71
71
|
end
|
|
72
72
|
end
|
|
@@ -144,6 +144,7 @@ module Whenever
|
|
|
144
144
|
end
|
|
145
145
|
Whenever::Output::Cron.output(time, job, :chronic_options => @chronic_options) do |cron|
|
|
146
146
|
cron << "\n\n"
|
|
147
|
+
cron = (job.description.strip + "\n").gsub(/^(.*)$/, '# \1') + cron unless job.description.to_s.empty?
|
|
147
148
|
|
|
148
149
|
if cron[0,1] == "@"
|
|
149
150
|
shortcut_jobs << cron
|
data/lib/whenever/version.rb
CHANGED
|
@@ -55,6 +55,34 @@ class OutputDefinedJobTest < Whenever::TestCase
|
|
|
55
55
|
assert_match(/^.+ .+ .+ .+ before during after local$/, output)
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
+
test "defined job with a :task and an option where the option is set globally and on the group" do
|
|
59
|
+
output = Whenever.cron \
|
|
60
|
+
<<-file
|
|
61
|
+
set :job_template, nil
|
|
62
|
+
job_type :some_job, "before :task after :option1"
|
|
63
|
+
set :option1, 'global'
|
|
64
|
+
every 2.hours, :option1 => 'group' do
|
|
65
|
+
some_job "during"
|
|
66
|
+
end
|
|
67
|
+
file
|
|
68
|
+
|
|
69
|
+
assert_match(/^.+ .+ .+ .+ before during after group$/, output)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
test "defined job with a :task and an option where the option is set globally, on the group, and locally" do
|
|
73
|
+
output = Whenever.cron \
|
|
74
|
+
<<-file
|
|
75
|
+
set :job_template, nil
|
|
76
|
+
job_type :some_job, "before :task after :option1"
|
|
77
|
+
set :option1, 'global'
|
|
78
|
+
every 2.hours, :option1 => 'group' do
|
|
79
|
+
some_job "during", :option1 => 'local'
|
|
80
|
+
end
|
|
81
|
+
file
|
|
82
|
+
|
|
83
|
+
assert_match(/^.+ .+ .+ .+ before during after local$/, output)
|
|
84
|
+
end
|
|
85
|
+
|
|
58
86
|
test "defined job with a :task and an option that is not set" do
|
|
59
87
|
output = Whenever.cron \
|
|
60
88
|
<<-file
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class OutputDescriptionTest < Whenever::TestCase
|
|
4
|
+
test "single line description" do
|
|
5
|
+
output = Whenever.cron \
|
|
6
|
+
<<-file
|
|
7
|
+
every "weekday", :description => "A description" do
|
|
8
|
+
command "blahblah"
|
|
9
|
+
end
|
|
10
|
+
file
|
|
11
|
+
|
|
12
|
+
assert_match "# A description\n0 0 * * 1-5 /bin/bash -l -c 'blahblah'\n\n", output
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
test "multi line description" do
|
|
16
|
+
output = Whenever.cron \
|
|
17
|
+
<<-file
|
|
18
|
+
every "weekday", :description => "A description\nhas mulitple lines" do
|
|
19
|
+
command "blahblah"
|
|
20
|
+
end
|
|
21
|
+
file
|
|
22
|
+
|
|
23
|
+
assert_match "# A description\n# has mulitple lines\n0 0 * * 1-5 /bin/bash -l -c 'blahblah'\n\n", output
|
|
24
|
+
end
|
|
25
|
+
end
|
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.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Javan Makhmali
|
|
@@ -75,6 +75,7 @@ files:
|
|
|
75
75
|
- test/functional/output_at_test.rb
|
|
76
76
|
- test/functional/output_default_defined_jobs_test.rb
|
|
77
77
|
- test/functional/output_defined_job_test.rb
|
|
78
|
+
- test/functional/output_description_test.rb
|
|
78
79
|
- test/functional/output_env_test.rb
|
|
79
80
|
- test/functional/output_jobs_for_roles_test.rb
|
|
80
81
|
- test/functional/output_jobs_with_mailto_test.rb
|
|
@@ -108,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
108
109
|
- !ruby/object:Gem::Version
|
|
109
110
|
version: '0'
|
|
110
111
|
requirements: []
|
|
111
|
-
rubygems_version:
|
|
112
|
+
rubygems_version: 4.0.3
|
|
112
113
|
specification_version: 4
|
|
113
114
|
summary: Cron jobs in ruby.
|
|
114
115
|
test_files:
|
|
@@ -116,6 +117,7 @@ test_files:
|
|
|
116
117
|
- test/functional/output_at_test.rb
|
|
117
118
|
- test/functional/output_default_defined_jobs_test.rb
|
|
118
119
|
- test/functional/output_defined_job_test.rb
|
|
120
|
+
- test/functional/output_description_test.rb
|
|
119
121
|
- test/functional/output_env_test.rb
|
|
120
122
|
- test/functional/output_jobs_for_roles_test.rb
|
|
121
123
|
- test/functional/output_jobs_with_mailto_test.rb
|