whenever 1.0.0 → 1.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc5ff14e6e9d357583f5e20d31fafbcf2dfe3aea8ac756cf9103f51504674e9a
4
- data.tar.gz: 446e8398b741a1a9a7ee262b3542efb107d1453259083fef03ea50726227d7dd
3
+ metadata.gz: 55cafb2edffbfeec94032659d8af2086785d5c864c7e979395197ba02e6612d4
4
+ data.tar.gz: 88ad009fb54d433ac00fd86f24c8ca0a5cbe05f7cd7774a8b4fac1ebfb90c4b9
5
5
  SHA512:
6
- metadata.gz: 41f396515f594a4726bd9048783653b0b203e0beb4ea65f6b95faf508061d0fd064bec0a31bbcf6dad6a23f68ec4f3364ae6e8f160eb0539ec6073a6c4960242
7
- data.tar.gz: 4fbe2b52fc350ee272d7d03638369b8a6443c1ed6e122be511b9ccf07881c1e559d63587153259343febc89db40aa45bc4ca45cf83af885fd618fd5668ddd1d2
6
+ metadata.gz: a81a8c3345588bf311b35bb9b6a6d158dd3fcff181f5a67c423a12db336ccc21c802d1f9498ecd079ebe2006479c971abc7a9129a89c965f63a88a46e1aee78d
7
+ data.tar.gz: 35622000e04945eab6965f0b5b87a2f2e914753628cf8ccbcf1e9cf99cbf0182125c283ad593f34a1dfa9372c225d208239fd9cec3a1d507a9a34f711f8da99f
@@ -0,0 +1,10 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "bundler"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "monthly"
7
+ - package-ecosystem: "github-actions"
8
+ directory: "/"
9
+ schedule:
10
+ interval: "monthly"
@@ -0,0 +1,84 @@
1
+ name: Ruby CI
2
+ on:
3
+ pull_request:
4
+ push:
5
+ branches: [ main ]
6
+ jobs:
7
+ test:
8
+ runs-on: ${{ matrix.os }}
9
+ strategy:
10
+ fail-fast: false
11
+ matrix:
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']
14
+ # CRuby < 2.6 does not support macos-arm64, so test those on amd64 instead
15
+ exclude:
16
+ - os: macos-latest
17
+ ruby-version: '2.4'
18
+ - os: macos-latest
19
+ ruby-version: '2.5'
20
+ include:
21
+ - os: macos-13
22
+ ruby-version: '2.4'
23
+ - os: macos-13
24
+ ruby-version: '2.5'
25
+ steps:
26
+ - uses: actions/checkout@v6
27
+ name: Set up Ruby ${{ matrix.ruby-version }}
28
+ - uses: ruby/setup-ruby@v1
29
+ env:
30
+ JRUBY_OPTS: "--debug"
31
+ with:
32
+ ruby-version: ${{ matrix.ruby-version }}
33
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
34
+ - name: Run tests
35
+ run: bundle exec rake test
36
+ env:
37
+ JRUBY_OPTS: "--debug"
38
+
39
+ # Test with activesupport
40
+ test-activesupport:
41
+ runs-on: ubuntu-latest
42
+ strategy:
43
+ fail-fast: false
44
+ matrix:
45
+ ruby-version: ['2.7', '3.0', '3.0', '3.2', '3.3', '3.4']
46
+ rails-version: ['6.0', '6.1', '7.0', '7.1', '7.2', '8.0', '8.1']
47
+ include:
48
+ - ruby-version: 2.7
49
+ rails-version: '5.0'
50
+ - ruby-version: 2.7
51
+ rails-version: '5.1'
52
+ - ruby-version: 2.7
53
+ rails-version: '5.2'
54
+ exclude:
55
+ # rails 8.1: support ruby 3.2+
56
+ - ruby-version: 2.7
57
+ rails-version: '8.1'
58
+ - ruby-version: 3.0
59
+ rails-version: '8.1'
60
+ - ruby-version: 3.1
61
+ rails-version: '8.1'
62
+ # rails 8.0: support ruby 3.2+
63
+ - ruby-version: 2.7
64
+ rails-version: '8.0'
65
+ - ruby-version: 3.0
66
+ rails-version: '8.0'
67
+ - ruby-version: 3.1
68
+ rails-version: '8.0'
69
+ # rails 7.2: support ruby 3.1+
70
+ - ruby-version: 2.7
71
+ rails-version: '7.2'
72
+ - ruby-version: 3.0
73
+ rails-version: '7.2'
74
+ env:
75
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/activesupport${{ matrix.rails-version }}.gemfile
76
+ steps:
77
+ - uses: actions/checkout@v6
78
+ name: Set up Ruby ${{ matrix.ruby-version }}
79
+ - uses: ruby/setup-ruby@v1
80
+ with:
81
+ ruby-version: ${{ matrix.ruby-version }}
82
+ bundler-cache: true
83
+ - name: Run tests
84
+ run: bundle exec rake test
data/.gitignore CHANGED
@@ -1,6 +1,15 @@
1
+ .bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ tmp/
9
+
10
+ /Gemfile.lock
11
+ gemfiles/*.lock
12
+ .ruby-version
13
+
1
14
  .DS_Store
2
- pkg
3
- doc
4
15
  .*.sw[a-z]
5
- Gemfile.lock
6
- gemfiles/*.lock
data/Appraisals CHANGED
@@ -1,19 +1,69 @@
1
- appraise 'activesupport4.1' do
2
- gem "activesupport", "~> 4.1.0"
1
+ if RUBY_VERSION < "3.0"
2
+ appraise 'activesupport5.0' do
3
+ gem "activesupport", "~> 5.0.0"
4
+ end
5
+
6
+ appraise 'activesupport5.1' do
7
+ gem "activesupport", "~> 5.1.0"
8
+ end
9
+
10
+ appraise 'activesupport5.2' do
11
+ gem "activesupport", "~> 5.2.0"
12
+ end
13
+ end
14
+
15
+ appraise 'activesupport6.0' do
16
+ gem "activesupport", "~> 6.0.0"
17
+
18
+ # ruby 3.3+
19
+ gem "base64"
20
+ gem "bigdecimal"
21
+ gem "mutex_m"
22
+ # ruby 3.4+
23
+ gem "benchmark"
24
+ gem "logger"
25
+
26
+ # Fix https://github.com/rails/rails/issues/54260
27
+ gem 'concurrent-ruby', "1.3.4"
3
28
  end
4
29
 
5
- appraise 'activesupport4.2' do
6
- gem "activesupport", "~> 4.2.0"
30
+ appraise 'activesupport6.1' do
31
+ gem "activesupport", "~> 6.1.0"
32
+
33
+ # ruby 3.3+
34
+ gem "base64"
35
+ gem "bigdecimal"
36
+ gem "mutex_m"
37
+ # ruby 3.4+
38
+ gem "benchmark"
39
+ gem "logger"
40
+
41
+ # Fix https://github.com/rails/rails/issues/54260
42
+ gem 'concurrent-ruby', "1.3.4"
7
43
  end
8
44
 
9
- appraise 'activesupport5.0' do
10
- gem "activesupport", "~> 5.0.0"
45
+ if RUBY_VERSION >= "2.7"
46
+ appraise 'activesupport7.0' do
47
+ gem "activesupport", "~> 7.0.0"
48
+ end
11
49
  end
12
50
 
13
- appraise 'activesupport5.1' do
14
- gem "activesupport", "~> 5.1.0"
51
+ if RUBY_VERSION >= "3.1"
52
+ appraise 'activesupport7.1' do
53
+ gem "activesupport", "~> 7.1.0"
54
+ end
15
55
  end
16
56
 
17
- appraise 'activesupport5.2' do
18
- gem "activesupport", "~> 5.2.0beta2"
57
+ if RUBY_VERSION >= "3.2"
58
+ appraise 'activesupport7.2' do
59
+ gem "activesupport", "~> 7.2.0"
60
+ end
61
+
62
+ appraise 'activesupport8.0' do
63
+ gem "activesupport", "~> 8.0.0"
64
+ end
65
+
66
+ appraise 'activesupport8.1' do
67
+ gem "activesupport", "~> 8.1.0"
68
+ end
19
69
  end
data/CHANGELOG.md CHANGED
@@ -1,11 +1,62 @@
1
1
  ### unreleased
2
2
 
3
+
4
+ ### 1.1.1 / Dec 8, 2025
5
+
6
+ * job_list `.respond_to?` updated to an instance method https://github.com/javan/whenever/pull/830
7
+
8
+ * Update README.md https://github.com/javan/whenever/pull/789
9
+
10
+ * CI: Bump actions/checkout from 5 to 6 https://github.com/javan/whenever/pull/869
11
+
12
+ * CI: Add tests using ActiveSupport to CI https://github.com/javan/whenever/pull/868
13
+
14
+ * Require MFA for gem releases https://github.com/javan/whenever/pull/867
15
+
16
+ ### 1.1.0 / Nov 21, 2025
17
+
18
+ * Splat whenever_roles when passing to roles https://github.com/javan/whenever/pull/777
19
+
20
+ * Update README.md https://github.com/javan/whenever/pull/785
21
+
22
+ * Clarify in README that tasks are run in parallel https://github.com/javan/whenever/pull/787
23
+
24
+ * Add note in README that cron is generated with the current user. [Raquel Queiroz] https://github.com/javan/whenever/pull/788
25
+
26
+ * Clarify options and warn about overwriting https://github.com/javan/whenever/pull/791
27
+
28
+ * Set the environment for cron jobs based off the currently set RAILS_ENV env variable. If RAILS_ENV is not set it defaults to production https://github.com/javan/whenever/pull/832
29
+
30
+ * [CHORE] DX: easify getting started contributing https://github.com/javan/whenever/pull/846
31
+
32
+ * CI: Replace travis-ci by Github-Actions https://github.com/javan/whenever/pull/847
33
+
34
+ * Added capability for updating cron without cmd https://github.com/javan/whenever/pull/515
35
+
36
+ * CI: Add Ruby 2.7-3.4 to the CI matrix https://github.com/javan/whenever/pull/858
37
+
38
+ * CI: Add dependabot config for bundler / github-actions https://github.com/javan/whenever/pull/862
39
+
40
+ * Handle crontab output to prevent SIGPIPE when running on CentOS Stream 10 https://github.com/javan/whenever/pull/861
41
+
42
+ * CI: Bump actions/checkout from 4 to 5 https://github.com/javan/whenever/pull/863
43
+
44
+ * Fix typo In test https://github.com/javan/whenever/pull/851
45
+
46
+ * Add changelog_uri to metadata to easily link from rubygems.org https://github.com/javan/whenever/pull/786
47
+
48
+ * Update gemspec format to match Bundler v3.x gemspec template https://github.com/javan/whenever/pull/864
49
+
50
+ * Add to require `whenever/version` https://github.com/javan/whenever/pull/865
51
+
3
52
  ### 1.0.0 / Jun 13, 2019
4
53
 
5
54
  * First stable release per SemVer.
6
55
 
7
56
  * Removes support for versions of Ruby which are no longer supported by the Ruby project.
8
57
 
58
+ * Bugfix: Splat `whenever_roles` when passing to `roles` to allow definition of multiple whenever roles [samuelokrent](https://github.com/javan/whenever/pull/777)
59
+
9
60
  ### 0.11.0 / April 23, 2019
10
61
 
11
62
  * Add support for mapping Range objects to cron range syntax [Tim Craft](https://github.com/javan/whenever/pull/725)
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,38 @@
1
+ ## How to contribute to Whenever
2
+
3
+ #### **Did you find a bug?**
4
+
5
+ * **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/your/whenever/issues).
6
+
7
+ * If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/your/whenever/issues/new). Be sure to include a **title and clear description**, as much relevant information as possible, and a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring.
8
+
9
+ #### **Did you write a patch that fixes a bug?**
10
+
11
+ * Open a new GitHub pull request with the patch.
12
+
13
+ * Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.
14
+
15
+
16
+ #### **Do you have questions about the source code?**
17
+
18
+ * Ask any question about how to use Whenever in the [whenever issues](https://github.com/javan/whenever/issues).
19
+
20
+ #### **Do you want to contribute to the Whenever documentation?**
21
+
22
+ Whenever is a volunteer effort. We encourage you to pitch in!
23
+
24
+ Thanks! :heart: :heart: :heart:
25
+
26
+ Whenever Team
27
+
28
+ ---
29
+ ## Setup
30
+
31
+ ```bash
32
+ $ bundle install
33
+ ```
34
+ ## Run tests
35
+
36
+ ```bash
37
+ $ make test
38
+ ```
data/Gemfile CHANGED
@@ -1,4 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "https://rubygems.org"
2
4
 
3
5
  # Specify your gem's dependencies in whenever.gemspec
4
6
  gemspec
7
+
8
+ gem "rake"
9
+ gem "mocha"
10
+ gem "minitest"
11
+ gem "appraisal"
data/Makefile ADDED
@@ -0,0 +1,5 @@
1
+ .DEFAULT_GOAL := test
2
+
3
+ test:
4
+ bundle exec rake test
5
+ .PHONY: test
data/README.md CHANGED
@@ -16,19 +16,21 @@ gem 'whenever', require: false
16
16
 
17
17
  ```sh
18
18
  $ cd /apps/my-great-project
19
- $ wheneverize .
19
+ $ bundle exec wheneverize .
20
20
  ```
21
21
 
22
22
  This will create an initial `config/schedule.rb` file for you (as long as the config folder is already present in your project).
23
23
 
24
24
  ### The `whenever` command
25
25
 
26
+ The `whenever` command will simply show you your `schedule.rb` file converted to cron syntax. It does not read or write your crontab file.
27
+
26
28
  ```sh
27
29
  $ cd /apps/my-great-project
28
- $ whenever
30
+ $ bundle exec whenever
29
31
  ```
30
32
 
31
- This will simply show you your `schedule.rb` file converted to cron syntax. It does not read or write your crontab file; you'll need to do this in order for your jobs to execute:
33
+ To write your crontab file for your jobs, execute this command:
32
34
 
33
35
  ```sh
34
36
  $ whenever --update-crontab
@@ -41,6 +43,8 @@ $ whenever --load-file config/my_schedule.rb # set the schedule file
41
43
  $ whenever --crontab-command 'sudo crontab' # override the crontab command
42
44
  ```
43
45
 
46
+ > Note: If you run the whenever --update-crontab without passing the --user attribute, cron will be generated by the current user. This mean tasks that needs other user permission will fail.
47
+
44
48
  You can list installed cron jobs using `crontab -l`.
45
49
 
46
50
  Run `whenever --help` for a complete list of options for selecting the schedule to use, setting variables in the schedule, etc.
@@ -49,6 +53,7 @@ Run `whenever --help` for a complete list of options for selecting the schedule
49
53
 
50
54
  ```ruby
51
55
  every 3.hours do # 1.minute 1.day 1.week 1.month 1.year is also supported
56
+ # the following tasks are run in parallel (not in sequence)
52
57
  runner "MyModel.some_process"
53
58
  rake "my:rake:task"
54
59
  command "/usr/bin/my_great_command"
@@ -101,9 +106,9 @@ The default job types that ship with Whenever are defined like so:
101
106
 
102
107
  ```ruby
103
108
  job_type :command, ":task :output"
104
- job_type :rake, "cd :path && :environment_variable=:environment bundle exec rake :task --silent :output"
105
- job_type :runner, "cd :path && bin/rails runner -e :environment ':task' :output"
106
- job_type :script, "cd :path && :environment_variable=:environment bundle exec script/:task :output"
109
+ job_type :rake, "cd :path && :environment_variable=:environment :bundle_command rake :task --silent :output"
110
+ job_type :script, "cd :path && :environment_variable=:environment :bundle_command script/:task :output"
111
+ job_type :runner, "cd :path && :bundle_command :runner_command -e :environment ':task' :output"
107
112
  ```
108
113
 
109
114
  Pre-Rails 3 apps and apps that don't use Bundler will redefine the `rake` and `runner` jobs respectively to function correctly.
@@ -185,7 +190,7 @@ In your "config/deploy.rb" file:
185
190
  require "whenever/capistrano"
186
191
  ```
187
192
 
188
- Take a look at the recipe for options you can set. <https://github.com/javan/whenever/blob/master/lib/whenever/capistrano/v2/recipes.rb>
193
+ Take a look at the recipe for options you can set. <https://github.com/javan/whenever/blob/main/lib/whenever/capistrano/v2/recipes.rb>
189
194
  For example, if you're using bundler do this:
190
195
 
191
196
  ```ruby
@@ -225,7 +230,7 @@ In your "Capfile" file:
225
230
  require "whenever/capistrano"
226
231
  ```
227
232
 
228
- Take a look at the [load:defaults task](https://github.com/javan/whenever/blob/master/lib/whenever/capistrano/v3/tasks/whenever.rake) (bottom of file) for options you can set. For example, to namespace the crontab entries by application and stage do this in your "config/deploy.rb" file:
233
+ Take a look at the [load:defaults task](https://github.com/javan/whenever/blob/main/lib/whenever/capistrano/v3/tasks/whenever.rake) (bottom of file) for options you can set. For example, to namespace the crontab entries by application and stage do this in your "config/deploy.rb" file:
229
234
 
230
235
  ```ruby
231
236
  set :whenever_identifier, ->{ "#{fetch(:application)}_#{fetch(:stage)}" }
@@ -322,8 +327,4 @@ It's a little bit dated now, but remains a good introduction.
322
327
 
323
328
  ----
324
329
 
325
- [![Build Status](https://secure.travis-ci.org/javan/whenever.svg)](http://travis-ci.org/javan/whenever)
326
-
327
- ----
328
-
329
330
  Copyright &copy; 2017 Javan Makhmali
data/bin/whenever CHANGED
@@ -2,21 +2,26 @@
2
2
 
3
3
  require 'optparse'
4
4
  require 'whenever'
5
- require 'whenever/version'
6
5
 
7
6
  options = {}
8
7
 
9
8
  OptionParser.new do |opts|
10
9
  opts.banner = "Usage: whenever [options]"
11
- opts.on('-i', '--update-crontab [identifier]', 'Default: full path to schedule.rb file') do |identifier|
10
+ opts.on('-i', '--update-crontab [schedule]',
11
+ 'Install the schedule to crontab.',
12
+ ' Default: full path to schedule.rb file') do |identifier|
12
13
  options[:update] = true
13
14
  options[:identifier] = identifier if identifier
14
15
  end
15
- opts.on('-w', '--write-crontab [identifier]', 'Default: full path to schedule.rb file') do |identifier|
16
+ opts.on('-w', '--write-crontab [schedule]',
17
+ 'Clear current crontab, and overwrite it with only the given schedule.',
18
+ ' Default: full path to schedule.rb file') do |identifier|
16
19
  options[:write] = true
17
20
  options[:identifier] = identifier if identifier
18
21
  end
19
- opts.on('-c', '--clear-crontab [identifier]') do |identifier|
22
+ opts.on('-c', '--clear-crontab [schedule]',
23
+ 'Uninstall the schedule from crontab.',
24
+ ' Default: full path to schedule.rb file') do |identifier|
20
25
  options[:clear] = true
21
26
  options[:identifier] = identifier if identifier
22
27
  end
@@ -1,7 +1,11 @@
1
1
  # This file was generated by Appraisal
2
2
 
3
- source "http://rubygems.org"
3
+ source "https://rubygems.org"
4
4
 
5
+ gem "rake"
6
+ gem "mocha"
7
+ gem "minitest"
8
+ gem "appraisal"
5
9
  gem "activesupport", "~> 5.0.0"
6
10
 
7
11
  gemspec path: "../"
@@ -1,7 +1,11 @@
1
1
  # This file was generated by Appraisal
2
2
 
3
- source "http://rubygems.org"
3
+ source "https://rubygems.org"
4
4
 
5
+ gem "rake"
6
+ gem "mocha"
7
+ gem "minitest"
8
+ gem "appraisal"
5
9
  gem "activesupport", "~> 5.1.0"
6
10
 
7
11
  gemspec path: "../"
@@ -1,7 +1,11 @@
1
1
  # This file was generated by Appraisal
2
2
 
3
- source "http://rubygems.org"
3
+ source "https://rubygems.org"
4
4
 
5
- gem "activesupport", "~> 5.2.0beta2"
5
+ gem "rake"
6
+ gem "mocha"
7
+ gem "minitest"
8
+ gem "appraisal"
9
+ gem "activesupport", "~> 5.2.0"
6
10
 
7
11
  gemspec path: "../"
@@ -0,0 +1,17 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake"
6
+ gem "mocha"
7
+ gem "minitest"
8
+ gem "appraisal"
9
+ gem "activesupport", "~> 6.0.0"
10
+ gem "base64"
11
+ gem "bigdecimal"
12
+ gem "mutex_m"
13
+ gem "benchmark"
14
+ gem "logger"
15
+ gem "concurrent-ruby", "1.3.4"
16
+
17
+ gemspec path: "../"
@@ -0,0 +1,17 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake"
6
+ gem "mocha"
7
+ gem "minitest"
8
+ gem "appraisal"
9
+ gem "activesupport", "~> 6.1.0"
10
+ gem "base64"
11
+ gem "bigdecimal"
12
+ gem "mutex_m"
13
+ gem "benchmark"
14
+ gem "logger"
15
+ gem "concurrent-ruby", "1.3.4"
16
+
17
+ gemspec path: "../"
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake"
6
+ gem "mocha"
7
+ gem "minitest"
8
+ gem "appraisal"
9
+ gem "activesupport", "~> 7.0.0"
10
+
11
+ gemspec path: "../"
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake"
6
+ gem "mocha"
7
+ gem "minitest"
8
+ gem "appraisal"
9
+ gem "activesupport", "~> 7.1.0"
10
+
11
+ gemspec path: "../"
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake"
6
+ gem "mocha"
7
+ gem "minitest"
8
+ gem "appraisal"
9
+ gem "activesupport", "~> 7.2.0"
10
+
11
+ gemspec path: "../"
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake"
6
+ gem "mocha"
7
+ gem "minitest"
8
+ gem "appraisal"
9
+ gem "activesupport", "~> 8.0.0"
10
+
11
+ gemspec path: "../"
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake"
6
+ gem "mocha"
7
+ gem "minitest"
8
+ gem "appraisal"
9
+ gem "activesupport", "~> 8.1.0"
10
+
11
+ gemspec path: "../"
@@ -2,7 +2,7 @@ namespace :whenever do
2
2
  def setup_whenever_task(*args, &block)
3
3
  args = Array(fetch(:whenever_command)) + args
4
4
 
5
- on roles fetch(:whenever_roles) do |host|
5
+ on roles *fetch(:whenever_roles) do |host|
6
6
  args_for_host = block_given? ? args + Array(yield(host)) : args
7
7
  within fetch(:whenever_path) do
8
8
  with fetch(:whenever_command_environment_variables) do
@@ -13,20 +13,21 @@ module Whenever
13
13
  @options[:file] ||= 'config/schedule.rb'
14
14
  @options[:cut] ||= 0
15
15
  @options[:identifier] ||= default_identifier
16
+ @options[:console] = true if @options[:console].nil?
16
17
 
17
18
  if !File.exist?(@options[:file]) && @options[:clear].nil?
18
19
  warn("[fail] Can't find file: #{@options[:file]}")
19
- exit(1)
20
+ return_or_exit(false)
20
21
  end
21
22
 
22
23
  if [@options[:update], @options[:write], @options[:clear]].compact.length > 1
23
24
  warn("[fail] Can only update, write or clear. Choose one.")
24
- exit(1)
25
+ return_or_exit(false)
25
26
  end
26
27
 
27
28
  unless @options[:cut].to_s =~ /[0-9]*/
28
29
  warn("[fail] Can't cut negative lines from the crontab #{options[:cut]}")
29
- exit(1)
30
+ return_or_exit(false)
30
31
  end
31
32
  @options[:cut] = @options[:cut].to_i
32
33
 
@@ -42,7 +43,7 @@ module Whenever
42
43
  puts Whenever.cron(@options)
43
44
  puts "## [message] Above is your schedule file converted to cron syntax; your crontab file was not updated."
44
45
  puts "## [message] Run `whenever --help' for more options."
45
- exit(0)
46
+ return_or_exit(true)
46
47
  end
47
48
  end
48
49
 
@@ -77,6 +78,8 @@ module Whenever
77
78
  IO.popen(command.join(' '), 'r+') do |crontab|
78
79
  crontab.write(contents)
79
80
  crontab.close_write
81
+ stdout = crontab.read
82
+ puts stdout unless stdout == ''
80
83
  end
81
84
 
82
85
  success = $?.exitstatus.zero?
@@ -85,10 +88,10 @@ module Whenever
85
88
  action = 'written' if @options[:write]
86
89
  action = 'updated' if @options[:update]
87
90
  puts "[write] crontab file #{action}"
88
- exit(0)
91
+ return_or_exit(true)
89
92
  else
90
93
  warn "[fail] Couldn't write crontab; try running `whenever' with no options to ensure your schedule file is valid."
91
- exit(1)
94
+ return_or_exit(false)
92
95
  end
93
96
  end
94
97
 
@@ -96,10 +99,10 @@ module Whenever
96
99
  # Check for unopened or unclosed identifier blocks
97
100
  if read_crontab =~ Regexp.new("^#{comment_open_regex}\s*$") && (read_crontab =~ Regexp.new("^#{comment_close_regex}\s*$")).nil?
98
101
  warn "[fail] Unclosed indentifier; Your crontab file contains '#{comment_open(false)}', but no '#{comment_close(false)}'"
99
- exit(1)
102
+ return_or_exit(false)
100
103
  elsif (read_crontab =~ Regexp.new("^#{comment_open_regex}\s*$")).nil? && read_crontab =~ Regexp.new("^#{comment_close_regex}\s*$")
101
104
  warn "[fail] Unopened indentifier; Your crontab file contains '#{comment_close(false)}', but no '#{comment_open(false)}'"
102
- exit(1)
105
+ return_or_exit(false)
103
106
  end
104
107
 
105
108
  # If an existing identifier block is found, replace it with the new cron entries
@@ -151,5 +154,18 @@ module Whenever
151
154
  def timestamp_regex
152
155
  " at: \\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2} ([+-]\\d{4}|UTC)"
153
156
  end
157
+
158
+ private
159
+
160
+ def return_or_exit success
161
+ result = 1
162
+ result = 0 if success
163
+ if @options[:console]
164
+ exit(result)
165
+ else
166
+ result
167
+ end
168
+ end
169
+
154
170
  end
155
171
  end
@@ -37,7 +37,7 @@ module Whenever
37
37
  @set_variables.has_key?(name) ? @set_variables[name] : super
38
38
  end
39
39
 
40
- def self.respond_to?(name, include_private = false)
40
+ def respond_to?(name, include_private = false)
41
41
  @set_variables.has_key?(name) || super
42
42
  end
43
43
 
@@ -1,7 +1,8 @@
1
1
  # Environment variable defaults to RAILS_ENV
2
2
  set :environment_variable, "RAILS_ENV"
3
- # Environment defaults to production
4
- set :environment, "production"
3
+ # Environment defaults to the value of RAILS_ENV in the current environment if
4
+ # it's set or production otherwise
5
+ set :environment, ENV.fetch("RAILS_ENV", "production")
5
6
  # Path defaults to the directory `whenever` was run from
6
7
  set :path, Whenever.path
7
8
 
@@ -1,3 +1,3 @@
1
1
  module Whenever
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.1'
3
3
  end
data/lib/whenever.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require "whenever/version"
1
2
  require 'whenever/numeric'
2
3
  require 'whenever/numeric_seconds'
3
4
  require 'whenever/job_list'
@@ -31,4 +32,11 @@ module Whenever
31
32
  def self.bundler?
32
33
  File.exist?(File.join(path, 'Gemfile'))
33
34
  end
35
+
36
+ def self.update_cron options
37
+ o = { 'update' => true, 'console' => false}
38
+ o.merge! options if options
39
+ Whenever::CommandLine.execute o
40
+ end
41
+
34
42
  end
@@ -398,7 +398,7 @@ class EnvironmentOverwrittenWithoutValueTest < Whenever::TestCase
398
398
  file
399
399
  end
400
400
 
401
- should "output the runner using the original environmnet" do
401
+ should "output the runner using the original environment" do
402
402
  assert_match two_hours + %( cd /silly/path && bundle exec script/runner -e silly 'blahblah'), @output
403
403
  end
404
404
  end
@@ -209,6 +209,20 @@ class OutputDefaultDefinedJobsTest < Whenever::TestCase
209
209
  assert_match two_hours + ' cd /some/other/path && RAILS_ENV=production bundle exec rake blahblah --silent', output
210
210
  end
211
211
 
212
+ test "A rake command that uses the default environment variable when RAILS_ENV is set" do
213
+ ENV.expects(:fetch).with("RAILS_ENV", "production").returns("development")
214
+ output = Whenever.cron \
215
+ <<-file
216
+ set :job_template, nil
217
+ set :path, '/my/path'
218
+ every 2.hours do
219
+ rake "blahblah"
220
+ end
221
+ file
222
+
223
+ assert_match two_hours + ' cd /my/path && RAILS_ENV=development bundle exec rake blahblah --silent', output
224
+ end
225
+
212
226
  test "A rake command that sets the environment variable" do
213
227
  output = Whenever.cron \
214
228
  <<-file
data/test/test_case.rb CHANGED
@@ -2,10 +2,10 @@ module Whenever
2
2
  require 'minitest/autorun'
3
3
  begin
4
4
  # 2.0.0
5
- class TestCase < MiniTest::Test; end
5
+ class TestCase < Minitest::Test; end
6
6
  rescue NameError
7
7
  # 1.9.3
8
- class TestCase < MiniTest::Unit::TestCase; end
8
+ class TestCase < Minitest::Unit::TestCase; end
9
9
  end
10
10
 
11
11
 
data/test/test_helper.rb CHANGED
@@ -1,6 +1,10 @@
1
1
  require 'whenever'
2
2
  require 'test_case'
3
- require 'mocha/setup'
3
+ require 'mocha/minitest'
4
+ begin
5
+ require 'active_support/all'
6
+ rescue LoadError
7
+ end
4
8
 
5
9
  module Whenever::TestHelpers
6
10
  protected
data/whenever.gemspec CHANGED
@@ -1,28 +1,29 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "whenever/version"
1
+ # frozen_string_literal: true
4
2
 
5
- Gem::Specification.new do |s|
6
- s.name = "whenever"
7
- s.version = Whenever::VERSION
8
- s.platform = Gem::Platform::RUBY
9
- s.authors = ["Javan Makhmali"]
10
- s.email = ["javan@javan.us"]
11
- s.license = "MIT"
12
- s.homepage = "https://github.com/javan/whenever"
13
- s.summary = %q{Cron jobs in ruby.}
14
- s.description = %q{Clean ruby syntax for writing and deploying cron jobs.}
15
- s.files = `git ls-files`.split("\n")
16
- s.test_files = `git ls-files -- test/{functional,unit}/*`.split("\n")
17
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
- s.require_paths = ["lib"]
19
- s.required_ruby_version = ">= 1.9.3"
3
+ require_relative "lib/whenever/version"
20
4
 
21
- s.add_dependency "chronic", ">= 0.6.3"
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "whenever"
7
+ spec.version = Whenever::VERSION
8
+ spec.platform = Gem::Platform::RUBY
9
+ spec.authors = ["Javan Makhmali"]
10
+ spec.email = ["javan@javan.us"]
22
11
 
23
- s.add_development_dependency "bundler"
24
- s.add_development_dependency "rake"
25
- s.add_development_dependency "mocha", ">= 0.9.5"
26
- s.add_development_dependency "minitest"
27
- s.add_development_dependency "appraisal"
12
+ spec.summary = %q{Cron jobs in ruby.}
13
+ spec.description = %q{Clean ruby syntax for writing and deploying cron jobs.}
14
+ spec.homepage = "https://github.com/javan/whenever"
15
+ spec.license = "MIT"
16
+ spec.required_ruby_version = ">= 1.9.3"
17
+
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = "https://github.com/javan/whenever"
20
+ spec.metadata["changelog_uri"] = "https://github.com/javan/whenever/blob/main/CHANGELOG.md"
21
+ spec.metadata["rubygems_mfa_required"] = "true"
22
+
23
+ spec.files = `git ls-files`.split("\n")
24
+ spec.test_files = `git ls-files -- test/{functional,unit}/*`.split("\n")
25
+ spec.executables = spec.files.grep(%r{\Abin/}) { |f| File.basename(f) }
26
+ spec.require_paths = ["lib"]
27
+
28
+ spec.add_dependency "chronic", ">= 0.6.3"
28
29
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whenever
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javan Makhmali
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2019-06-13 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: chronic
@@ -24,76 +23,6 @@ dependencies:
24
23
  - - ">="
25
24
  - !ruby/object:Gem::Version
26
25
  version: 0.6.3
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: mocha
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: 0.9.5
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: 0.9.5
69
- - !ruby/object:Gem::Dependency
70
- name: minitest
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: appraisal
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
26
  description: Clean ruby syntax for writing and deploying cron jobs.
98
27
  email:
99
28
  - javan@javan.us
@@ -103,21 +32,29 @@ executables:
103
32
  extensions: []
104
33
  extra_rdoc_files: []
105
34
  files:
35
+ - ".github/dependabot.yml"
36
+ - ".github/workflows/ci.yml"
106
37
  - ".gitignore"
107
- - ".travis.yml"
108
38
  - Appraisals
109
39
  - CHANGELOG.md
40
+ - CONTRIBUTING.md
110
41
  - Gemfile
111
42
  - LICENSE
43
+ - Makefile
112
44
  - README.md
113
45
  - Rakefile
114
46
  - bin/whenever
115
47
  - bin/wheneverize
116
- - gemfiles/activesupport4.1.gemfile
117
- - gemfiles/activesupport4.2.gemfile
118
48
  - gemfiles/activesupport5.0.gemfile
119
49
  - gemfiles/activesupport5.1.gemfile
120
50
  - gemfiles/activesupport5.2.gemfile
51
+ - gemfiles/activesupport6.0.gemfile
52
+ - gemfiles/activesupport6.1.gemfile
53
+ - gemfiles/activesupport7.0.gemfile
54
+ - gemfiles/activesupport7.1.gemfile
55
+ - gemfiles/activesupport7.2.gemfile
56
+ - gemfiles/activesupport8.0.gemfile
57
+ - gemfiles/activesupport8.1.gemfile
121
58
  - lib/whenever.rb
122
59
  - lib/whenever/capistrano.rb
123
60
  - lib/whenever/capistrano/v2/hooks.rb
@@ -152,8 +89,11 @@ files:
152
89
  homepage: https://github.com/javan/whenever
153
90
  licenses:
154
91
  - MIT
155
- metadata: {}
156
- post_install_message:
92
+ metadata:
93
+ homepage_uri: https://github.com/javan/whenever
94
+ source_code_uri: https://github.com/javan/whenever
95
+ changelog_uri: https://github.com/javan/whenever/blob/main/CHANGELOG.md
96
+ rubygems_mfa_required: 'true'
157
97
  rdoc_options: []
158
98
  require_paths:
159
99
  - lib
@@ -168,9 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
108
  - !ruby/object:Gem::Version
169
109
  version: '0'
170
110
  requirements: []
171
- rubyforge_project:
172
- rubygems_version: 2.7.3
173
- signing_key:
111
+ rubygems_version: 3.6.9
174
112
  specification_version: 4
175
113
  summary: Cron jobs in ruby.
176
114
  test_files:
data/.travis.yml DELETED
@@ -1,21 +0,0 @@
1
- language: ruby
2
-
3
- before_install:
4
- - gem install bundler
5
- - unset _JAVA_OPTIONS
6
- rvm:
7
- - 2.4.6
8
- - 2.5.5
9
- - 2.6.3
10
- - jruby-9.2.6.0
11
-
12
- gemfile:
13
- - gemfiles/activesupport4.1.gemfile
14
- - gemfiles/activesupport4.2.gemfile
15
- - gemfiles/activesupport5.0.gemfile
16
- - gemfiles/activesupport5.1.gemfile
17
- - gemfiles/activesupport5.2.gemfile
18
-
19
- env:
20
- global:
21
- - JRUBY_OPTS=--debug
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "activesupport", "~> 4.1.0"
6
-
7
- gemspec path: "../"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "activesupport", "~> 4.2.0"
6
-
7
- gemspec path: "../"