whenever 0.9.4 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +11 -5
- data/CHANGELOG.md +23 -0
- data/LICENSE +1 -1
- data/README.md +28 -12
- data/Rakefile +3 -10
- data/bin/wheneverize +4 -4
- data/gemfiles/activesupport4.1.gemfile +5 -0
- data/gemfiles/activesupport4.2.gemfile +5 -0
- data/lib/whenever.rb +5 -3
- data/lib/whenever/capistrano/v2/recipes.rb +1 -1
- data/lib/whenever/capistrano/v3/tasks/whenever.rake +4 -2
- data/lib/whenever/command_line.rb +3 -2
- data/lib/whenever/cron.rb +3 -2
- data/lib/whenever/job_list.rb +3 -14
- data/lib/whenever/numeric.rb +13 -0
- data/lib/whenever/numeric_seconds.rb +0 -6
- data/lib/whenever/os.rb +7 -0
- data/lib/whenever/setup.rb +1 -1
- data/lib/whenever/tasks/whenever.rake +1 -0
- data/lib/whenever/version.rb +1 -1
- data/test/functional/command_line_test.rb +13 -13
- data/test/functional/output_at_test.rb +4 -4
- data/test/functional/output_default_defined_jobs_test.rb +37 -10
- data/test/functional/output_defined_job_test.rb +5 -5
- data/test/functional/output_redirection_test.rb +23 -23
- data/test/test_case.rb +7 -14
- data/test/test_helper.rb +2 -2
- data/test/unit/cron_test.rb +20 -2
- data/whenever.gemspec +4 -1
- metadata +37 -5
- data/lib/whenever/tasks/whenever.rake +0 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90a239b0bdc14e0d2f4bd9a8c843d57a35ce5c29
|
4
|
+
data.tar.gz: 457745a241466428c7494fa0c935afbd1352b66b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 216ead8ef6df7db0003c1b5b56d0de0bdebd148a5e64d77d10945af9e2a5109302f94f0422cacd4170228936dcc24fa23681e55feeec983f69b299d588cd612b
|
7
|
+
data.tar.gz: 43a7f84ad7b6f4bcc770d68ebbe02587eb69b42963a58389a9d36fac0bcfe10a8ab9b8611384739fad5eb2415d9f8437f183ce1460b9f3dae8669cd3f05e1272
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,12 +1,18 @@
|
|
1
1
|
language: ruby
|
2
2
|
script: bundle exec rake
|
3
|
+
|
4
|
+
before_install:
|
5
|
+
- gem install bundler
|
6
|
+
|
3
7
|
rvm:
|
4
|
-
- 1.8.7
|
5
|
-
- 1.9.2
|
6
8
|
- 1.9.3
|
7
9
|
- 2.0.0
|
8
10
|
- 2.1.0
|
9
|
-
-
|
11
|
+
- 2.2.0
|
12
|
+
- 2.3.0
|
10
13
|
- jruby
|
11
|
-
|
12
|
-
|
14
|
+
|
15
|
+
gemfile:
|
16
|
+
- Gemfile
|
17
|
+
- gemfiles/activesupport4.1.gemfile
|
18
|
+
- gemfiles/activesupport4.2.gemfile
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
+
### develop
|
2
|
+
|
3
|
+
### 0.9.5 / June 12, 2016
|
4
|
+
|
5
|
+
* Improve documentation [Ben Langfeld, Spencer Fry]
|
6
|
+
|
7
|
+
* Properly support Solaris / SmartOS [Steven Williamson]
|
8
|
+
|
9
|
+
* Drop support for Ruby < 1.9.3. Test newer Ruby versions. [Javan Makhmali, Bartłomiej Kozal]
|
10
|
+
|
11
|
+
* Suport Ruby 2.3.0 and Rails 4 [Vincent Boisard]
|
12
|
+
|
13
|
+
* Set `RAILS_ENV` correctly in schedule when writing crontab from Capistrano [Ben Langfeld, Lorenzo Manacorda]
|
14
|
+
|
15
|
+
* Minor refactoring, avoidance of Ruby warnings, etc [Ben Langfeld, DV Dasari]
|
16
|
+
|
17
|
+
* Correctly pass through date expressions (e.g. `1.day`) inside job definitions [Rafael Sales]
|
18
|
+
|
19
|
+
* Prevent writing invalid cron strings [Danny Fallon, Ben Langfeld]
|
20
|
+
|
21
|
+
* Execute runner with `bundle exec` to ensure presence of app dependencies [Judith Roth]
|
22
|
+
|
23
|
+
|
1
24
|
### 0.9.4 / October 24, 2014
|
2
25
|
|
3
26
|
* Fix duplicated command line arguments when deploying to multiple servers with Cap 3. [betesh]
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -21,6 +21,23 @@ $ wheneverize .
|
|
21
21
|
|
22
22
|
This will create an initial `config/schedule.rb` file for you.
|
23
23
|
|
24
|
+
### The `whenever` command
|
25
|
+
|
26
|
+
```sh
|
27
|
+
$ cd /apps/my-great-project
|
28
|
+
$ whenever
|
29
|
+
```
|
30
|
+
|
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:
|
32
|
+
|
33
|
+
```sh
|
34
|
+
$ whenever --update-crontab
|
35
|
+
```
|
36
|
+
|
37
|
+
You can list installed cron jobs using `crontab -l`.
|
38
|
+
|
39
|
+
Run `whenever --help` for a complete list of options for selecting the schedule to use, setting variables in the schedule, selecting a user as which to install the crontab, etc.
|
40
|
+
|
24
41
|
### Example schedule.rb file
|
25
42
|
|
26
43
|
```ruby
|
@@ -74,7 +91,7 @@ The default job types that ship with Whenever are defined like so:
|
|
74
91
|
```ruby
|
75
92
|
job_type :command, ":task :output"
|
76
93
|
job_type :rake, "cd :path && :environment_variable=:environment bundle exec rake :task --silent :output"
|
77
|
-
job_type :runner, "cd :path &&
|
94
|
+
job_type :runner, "cd :path && bin/rails runner -e :environment ':task' :output"
|
78
95
|
job_type :script, "cd :path && :environment_variable=:environment bundle exec script/:task :output"
|
79
96
|
```
|
80
97
|
|
@@ -139,14 +156,14 @@ In your "Capfile" file:
|
|
139
156
|
require "whenever/capistrano"
|
140
157
|
```
|
141
158
|
|
142
|
-
Take a look at the load:defaults (
|
143
|
-
|
144
|
-
In your in "config/deploy.rb" file:
|
159
|
+
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:
|
145
160
|
|
146
161
|
```ruby
|
147
162
|
set :whenever_identifier, ->{ "#{fetch(:application)}_#{fetch(:stage)}" }
|
148
163
|
```
|
149
164
|
|
165
|
+
The Capistrano integration by default expects the `:application` variable to be set in order to scope jobs in the crontab.
|
166
|
+
|
150
167
|
### Capistrano roles
|
151
168
|
|
152
169
|
The first thing to know about the new roles support is that it is entirely
|
@@ -211,14 +228,13 @@ If your production environment uses RVM (Ruby Version Manager) you will run into
|
|
211
228
|
|
212
229
|
This tells rvm to trust all rvmrc files.
|
213
230
|
|
214
|
-
###
|
231
|
+
### Heroku?
|
215
232
|
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
```
|
233
|
+
No. Heroku does not support cron, instead providing [Heroku Scheduler](https://devcenter.heroku.com/articles/scheduler). If you deploy to Heroku, you should use that rather than Whenever.
|
234
|
+
|
235
|
+
### Testing
|
220
236
|
|
221
|
-
|
237
|
+
[whenever-test](https://github.com/heartbits/whenever-test) is an extension to Whenever for testing a Whenever schedule.
|
222
238
|
|
223
239
|
### Credit
|
224
240
|
|
@@ -237,8 +253,8 @@ It's a little bit dated now, but remains a good introduction.
|
|
237
253
|
|
238
254
|
----
|
239
255
|
|
240
|
-
|
256
|
+
[![Build Status](https://secure.travis-ci.org/javan/whenever.png)](http://travis-ci.org/javan/whenever)
|
241
257
|
|
242
258
|
----
|
243
259
|
|
244
|
-
Copyright ©
|
260
|
+
Copyright © 2016 Javan Makhmali
|
data/Rakefile
CHANGED
@@ -1,17 +1,10 @@
|
|
1
|
-
|
2
|
-
require 'bundler'
|
3
|
-
rescue LoadError => e
|
4
|
-
warn("warning: Could not load bundler: #{e}")
|
5
|
-
warn(" Some rake tasks will not be defined")
|
6
|
-
else
|
7
|
-
Bundler::GemHelper.install_tasks
|
8
|
-
end
|
9
|
-
|
1
|
+
require 'bundler/gem_tasks'
|
10
2
|
require 'rake/testtask'
|
3
|
+
|
11
4
|
Rake::TestTask.new(:test) do |test|
|
12
5
|
test.libs << 'lib' << 'test'
|
13
6
|
test.pattern = 'test/{functional,unit}/**/*_test.rb'
|
14
7
|
test.verbose = true
|
15
8
|
end
|
16
9
|
|
17
|
-
task :default => :test
|
10
|
+
task :default => :test
|
data/bin/wheneverize
CHANGED
@@ -18,7 +18,7 @@ OptionParser.new do |opts|
|
|
18
18
|
end
|
19
19
|
|
20
20
|
unless ARGV.empty?
|
21
|
-
if !File.
|
21
|
+
if !File.exist?(ARGV.first)
|
22
22
|
abort "`#{ARGV.first}' does not exist."
|
23
23
|
elsif !File.directory?(ARGV.first)
|
24
24
|
abort "`#{ARGV.first}' is not a directory."
|
@@ -54,11 +54,11 @@ file = 'config/schedule.rb'
|
|
54
54
|
base = ARGV.empty? ? '.' : ARGV.shift
|
55
55
|
|
56
56
|
file = File.join(base, file)
|
57
|
-
if File.
|
57
|
+
if File.exist?(file)
|
58
58
|
warn "[skip] `#{file}' already exists"
|
59
|
-
elsif File.
|
59
|
+
elsif File.exist?(file.downcase)
|
60
60
|
warn "[skip] `#{file.downcase}' exists, which could conflict with `#{file}'"
|
61
|
-
elsif !File.
|
61
|
+
elsif !File.exist?(File.dirname(file))
|
62
62
|
warn "[skip] directory `#{File.dirname(file)}' does not exist"
|
63
63
|
else
|
64
64
|
puts "[add] writing `#{file}'"
|
data/lib/whenever.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
+
require 'whenever/numeric'
|
1
2
|
require 'whenever/numeric_seconds'
|
2
3
|
require 'whenever/job_list'
|
3
4
|
require 'whenever/job'
|
4
5
|
require 'whenever/command_line'
|
5
6
|
require 'whenever/cron'
|
6
7
|
require 'whenever/output_redirection'
|
8
|
+
require 'whenever/os'
|
7
9
|
|
8
10
|
module Whenever
|
9
11
|
def self.cron(options)
|
@@ -19,14 +21,14 @@ module Whenever
|
|
19
21
|
end
|
20
22
|
|
21
23
|
def self.bin_rails?
|
22
|
-
File.
|
24
|
+
File.exist?(File.join(path, 'bin', 'rails'))
|
23
25
|
end
|
24
26
|
|
25
27
|
def self.script_rails?
|
26
|
-
File.
|
28
|
+
File.exist?(File.join(path, 'script', 'rails'))
|
27
29
|
end
|
28
30
|
|
29
31
|
def self.bundler?
|
30
|
-
File.
|
32
|
+
File.exist?(File.join(path, 'Gemfile'))
|
31
33
|
end
|
32
34
|
end
|
@@ -7,7 +7,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
7
7
|
_cset(:whenever_options) { {:roles => fetch(:whenever_roles)} }
|
8
8
|
_cset(:whenever_command) { "whenever" }
|
9
9
|
_cset(:whenever_identifier) { fetch :application }
|
10
|
-
_cset(:whenever_environment) { fetch :rails_env, "production" }
|
10
|
+
_cset(:whenever_environment) { fetch :rails_env, fetch(:stage, "production") }
|
11
11
|
_cset(:whenever_variables) { "environment=#{fetch :whenever_environment}" }
|
12
12
|
_cset(:whenever_update_flags) { "--update-crontab #{fetch :whenever_identifier} --set #{fetch :whenever_variables}" }
|
13
13
|
_cset(:whenever_clear_flags) { "--clear-crontab #{fetch :whenever_identifier}" }
|
@@ -5,8 +5,10 @@ namespace :whenever do
|
|
5
5
|
on roles fetch(:whenever_roles) do |host|
|
6
6
|
args_for_host = block_given? ? args + Array(yield(host)) : args
|
7
7
|
within release_path do
|
8
|
-
with fetch(:
|
9
|
-
|
8
|
+
with rails_env: fetch(:whenever_environment) do
|
9
|
+
with fetch(:whenever_command_environment_variables) do
|
10
|
+
execute *args_for_host
|
11
|
+
end
|
10
12
|
end
|
11
13
|
end
|
12
14
|
end
|
@@ -13,7 +13,7 @@ module Whenever
|
|
13
13
|
@options[:cut] ||= 0
|
14
14
|
@options[:identifier] ||= default_identifier
|
15
15
|
|
16
|
-
if !File.
|
16
|
+
if !File.exist?(@options[:file]) && @options[:clear].nil?
|
17
17
|
warn("[fail] Can't find file: #{@options[:file]}")
|
18
18
|
exit(1)
|
19
19
|
end
|
@@ -67,7 +67,8 @@ module Whenever
|
|
67
67
|
def write_crontab(contents)
|
68
68
|
command = ['crontab']
|
69
69
|
command << "-u #{@options[:user]}" if @options[:user]
|
70
|
-
|
70
|
+
# Solaris/SmartOS cron does not support the - option to read from stdin.
|
71
|
+
command << "-" unless OS.solaris?
|
71
72
|
|
72
73
|
IO.popen(command.join(' '), 'r+') do |crontab|
|
73
74
|
crontab.write(contents)
|
data/lib/whenever/cron.rb
CHANGED
@@ -4,7 +4,7 @@ module Whenever
|
|
4
4
|
module Output
|
5
5
|
class Cron
|
6
6
|
KEYWORDS = [:reboot, :yearly, :annually, :monthly, :weekly, :daily, :midnight, :hourly]
|
7
|
-
REGEX = /^(@(#{KEYWORDS.join '|'})
|
7
|
+
REGEX = /^(@(#{KEYWORDS.join '|'})|((\*?[\d\/,\-]*)\s*){5})$/
|
8
8
|
|
9
9
|
attr_accessor :time, :task
|
10
10
|
|
@@ -43,8 +43,9 @@ module Whenever
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def time_in_cron_syntax
|
46
|
+
@time = @time.to_i if @time.is_a?(Numeric) # Compatibility with `1.day` format using ruby 2.3 and activesupport
|
46
47
|
case @time
|
47
|
-
when REGEX then @time # raw cron
|
48
|
+
when REGEX then @time # raw cron syntax given
|
48
49
|
when Symbol then parse_symbol
|
49
50
|
when String then parse_as_string
|
50
51
|
else parse_time
|
data/lib/whenever/job_list.rb
CHANGED
@@ -21,8 +21,8 @@ module Whenever
|
|
21
21
|
File.read(options[:file])
|
22
22
|
end
|
23
23
|
|
24
|
-
instance_eval(
|
25
|
-
instance_eval(
|
24
|
+
instance_eval(setup, setup_file)
|
25
|
+
instance_eval(schedule, options[:file] || '<eval>')
|
26
26
|
end
|
27
27
|
|
28
28
|
def set(variable, value)
|
@@ -45,7 +45,7 @@ module Whenever
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def job_type(name, template)
|
48
|
-
|
48
|
+
singleton_class.class_eval do
|
49
49
|
define_method(name) do |task, *args|
|
50
50
|
options = { :task => task, :template => template }
|
51
51
|
options.merge!(args[0]) if args[0].is_a? Hash
|
@@ -67,17 +67,6 @@ module Whenever
|
|
67
67
|
|
68
68
|
private
|
69
69
|
|
70
|
-
# The Object#singleton_class method only became available in MRI 1.9.2, so
|
71
|
-
# we need this to maintain 1.8 compatibility. Once 1.8 support is dropped,
|
72
|
-
# this can be removed
|
73
|
-
def singleton_class_shim
|
74
|
-
if self.respond_to?(:singleton_class)
|
75
|
-
singleton_class
|
76
|
-
else
|
77
|
-
class << self; self; end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
70
|
#
|
82
71
|
# Takes a string like: "variable1=something&variable2=somethingelse"
|
83
72
|
# and breaks it into variable/value pairs. Used for setting variables at runtime from the command line.
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Numeric
|
2
|
+
def respond_to?(method, include_private = false)
|
3
|
+
super || Whenever::NumericSeconds.public_method_defined?(method)
|
4
|
+
end
|
5
|
+
|
6
|
+
def method_missing(method, *args, &block)
|
7
|
+
if Whenever::NumericSeconds.public_method_defined?(method)
|
8
|
+
Whenever::NumericSeconds.new(self).send(method)
|
9
|
+
else
|
10
|
+
super
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -1,17 +1,11 @@
|
|
1
1
|
module Whenever
|
2
2
|
class NumericSeconds
|
3
|
-
PATTERN = /(\d+)\.(seconds?|minutes?|hours?|days?|weeks?|months?|years?)/
|
4
|
-
|
5
3
|
attr_reader :number
|
6
4
|
|
7
5
|
def self.seconds(number, units)
|
8
6
|
new(number).send(units)
|
9
7
|
end
|
10
8
|
|
11
|
-
def self.process_string(string)
|
12
|
-
string.gsub(PATTERN) { Whenever.seconds($1, $2) }
|
13
|
-
end
|
14
|
-
|
15
9
|
def initialize(number)
|
16
10
|
@number = number.to_i
|
17
11
|
end
|
data/lib/whenever/os.rb
ADDED
data/lib/whenever/setup.rb
CHANGED
@@ -23,4 +23,4 @@ set :bundle_command, Whenever.bundler? ? "bundle exec" : ""
|
|
23
23
|
job_type :command, ":task :output"
|
24
24
|
job_type :rake, "cd :path && :environment_variable=:environment :bundle_command rake :task --silent :output"
|
25
25
|
job_type :script, "cd :path && :environment_variable=:environment :bundle_command script/:task :output"
|
26
|
-
job_type :runner, "cd :path && :runner_command -e :environment ':task' :output"
|
26
|
+
job_type :runner, "cd :path && :bundle_command :runner_command -e :environment ':task' :output"
|
@@ -0,0 +1 @@
|
|
1
|
+
../capistrano/v3/tasks/whenever.rake
|
data/lib/whenever/version.rb
CHANGED
@@ -2,7 +2,7 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class CommandLineWriteTest < Whenever::TestCase
|
4
4
|
setup do
|
5
|
-
File.expects(:
|
5
|
+
File.expects(:exist?).with('config/schedule.rb').returns(true)
|
6
6
|
@command = Whenever::CommandLine.new(:write => true, :identifier => 'My identifier')
|
7
7
|
@task = "#{two_hours} /my/command"
|
8
8
|
Whenever.expects(:cron).returns(@task)
|
@@ -26,7 +26,7 @@ end
|
|
26
26
|
|
27
27
|
class CommandLineUpdateTest < Whenever::TestCase
|
28
28
|
setup do
|
29
|
-
File.expects(:
|
29
|
+
File.expects(:exist?).with('config/schedule.rb').returns(true)
|
30
30
|
@command = Whenever::CommandLine.new(:update => true, :identifier => 'My identifier')
|
31
31
|
@task = "#{two_hours} /my/command"
|
32
32
|
Whenever.expects(:cron).returns(@task)
|
@@ -90,7 +90,7 @@ class CommandLineUpdateWithBackslashesTest < Whenever::TestCase
|
|
90
90
|
script/runner -e production 'puts '\\''hello'\\'''
|
91
91
|
# End Whenever generated tasks for: My identifier
|
92
92
|
EXISTING_CRON
|
93
|
-
File.expects(:
|
93
|
+
File.expects(:exist?).with('config/schedule.rb').returns(true)
|
94
94
|
@command = Whenever::CommandLine.new(:update => true, :identifier => 'My identifier')
|
95
95
|
@command.expects(:read_crontab).at_least_once.returns(@existing)
|
96
96
|
@command.expects(:whenever_cron).returns(@existing)
|
@@ -111,7 +111,7 @@ EXISTING_CRON
|
|
111
111
|
# Begin Whenever generated tasks for: Whenever
|
112
112
|
# End Whenever generated tasks for: Whenever
|
113
113
|
NEW_CRON
|
114
|
-
File.expects(:
|
114
|
+
File.expects(:exist?).with('config/schedule.rb').returns(true)
|
115
115
|
@command = Whenever::CommandLine.new(:update => true, :identifier => 'Whenever')
|
116
116
|
@command.expects(:read_crontab).at_least_once.returns(@existing)
|
117
117
|
@command.expects(:whenever_cron).returns(@new)
|
@@ -124,7 +124,7 @@ end
|
|
124
124
|
|
125
125
|
class CommandLineClearTest < Whenever::TestCase
|
126
126
|
setup do
|
127
|
-
File.expects(:
|
127
|
+
File.expects(:exist?).with('config/schedule.rb').returns(true)
|
128
128
|
@command = Whenever::CommandLine.new(:clear => true, :identifier => 'My identifier')
|
129
129
|
@task = "#{two_hours} /my/command"
|
130
130
|
end
|
@@ -161,7 +161,7 @@ end
|
|
161
161
|
|
162
162
|
class CommandLineClearWithNoScheduleTest < Whenever::TestCase
|
163
163
|
setup do
|
164
|
-
File.expects(:
|
164
|
+
File.expects(:exist?).with('config/schedule.rb').returns(false)
|
165
165
|
@command = Whenever::CommandLine.new(:clear => true, :identifier => 'My identifier')
|
166
166
|
end
|
167
167
|
|
@@ -173,7 +173,7 @@ end
|
|
173
173
|
|
174
174
|
class CommandLineUpdateWithNoIdentifierTest < Whenever::TestCase
|
175
175
|
setup do
|
176
|
-
File.expects(:
|
176
|
+
File.expects(:exist?).with('config/schedule.rb').returns(true)
|
177
177
|
Whenever::CommandLine.any_instance.expects(:default_identifier).returns('DEFAULT')
|
178
178
|
@command = Whenever::CommandLine.new(:update => true, :file => @file)
|
179
179
|
end
|
@@ -187,7 +187,7 @@ class CombinedParamsTest < Whenever::TestCase
|
|
187
187
|
setup do
|
188
188
|
Whenever::CommandLine.any_instance.expects(:exit)
|
189
189
|
Whenever::CommandLine.any_instance.expects(:warn)
|
190
|
-
File.expects(:
|
190
|
+
File.expects(:exist?).with('config/schedule.rb').returns(true)
|
191
191
|
end
|
192
192
|
|
193
193
|
should "exit with write and clear" do
|
@@ -217,7 +217,7 @@ class RunnerOverwrittenWithSetOptionTest < Whenever::TestCase
|
|
217
217
|
end
|
218
218
|
|
219
219
|
should "output the runner using the override environment" do
|
220
|
-
assert_match two_hours + %( cd /my/path && script/runner -e serious 'blahblah'), @output
|
220
|
+
assert_match two_hours + %( cd /my/path && bundle exec script/runner -e serious 'blahblah'), @output
|
221
221
|
end
|
222
222
|
end
|
223
223
|
|
@@ -236,7 +236,7 @@ class EnvironmentAndPathOverwrittenWithSetOptionTest < Whenever::TestCase
|
|
236
236
|
end
|
237
237
|
|
238
238
|
should "output the runner using the overridden path and environment" do
|
239
|
-
assert_match two_hours + %( cd /serious/path && script/runner -e serious 'blahblah'), @output
|
239
|
+
assert_match two_hours + %( cd /serious/path && bundle exec script/runner -e serious 'blahblah'), @output
|
240
240
|
end
|
241
241
|
end
|
242
242
|
|
@@ -254,7 +254,7 @@ class EnvironmentAndPathOverwrittenWithSetOptionWithSpacesTest < Whenever::TestC
|
|
254
254
|
end
|
255
255
|
|
256
256
|
should "output the runner using the overridden path and environment" do
|
257
|
-
assert_match two_hours + %( cd /serious/path && script/runner -e serious 'blahblah'), @output
|
257
|
+
assert_match two_hours + %( cd /serious/path && bundle exec script/runner -e serious 'blahblah'), @output
|
258
258
|
end
|
259
259
|
end
|
260
260
|
|
@@ -272,13 +272,13 @@ class EnvironmentOverwrittenWithoutValueTest < Whenever::TestCase
|
|
272
272
|
end
|
273
273
|
|
274
274
|
should "output the runner using the original environmnet" do
|
275
|
-
assert_match two_hours + %( cd /silly/path && script/runner -e silly 'blahblah'), @output
|
275
|
+
assert_match two_hours + %( cd /silly/path && bundle exec script/runner -e silly 'blahblah'), @output
|
276
276
|
end
|
277
277
|
end
|
278
278
|
|
279
279
|
class PreparingOutputTest < Whenever::TestCase
|
280
280
|
setup do
|
281
|
-
File.expects(:
|
281
|
+
File.expects(:exist?).with('config/schedule.rb').returns(true)
|
282
282
|
end
|
283
283
|
|
284
284
|
should "not trim off the top lines of the file" do
|
@@ -69,11 +69,11 @@ class OutputAtTest < Whenever::TestCase
|
|
69
69
|
set :job_template, nil
|
70
70
|
set :path, '/your/path'
|
71
71
|
every "mon,wed,fri", :at => '5:02am, 3:02pm' do
|
72
|
-
runner "
|
72
|
+
runner "Worker.perform_async(1.day.ago)"
|
73
73
|
end
|
74
74
|
file
|
75
75
|
|
76
|
-
assert_match %(2 5,15 * * 1,3,5 cd /your/path && script/runner -e production '
|
76
|
+
assert_match %(2 5,15 * * 1,3,5 cd /your/path && bundle exec script/runner -e production 'Worker.perform_async(1.day.ago)'), output
|
77
77
|
end
|
78
78
|
|
79
79
|
test "various days at a various aligned times using a rake task" do
|
@@ -138,9 +138,9 @@ class OutputAtTest < Whenever::TestCase
|
|
138
138
|
file
|
139
139
|
|
140
140
|
assert_match '@daily cd /your/path && RAILS_ENV=production bundle exec rake blah:blah --silent', output
|
141
|
-
assert_match %(@daily cd /your/path && script/runner -e production 'runner_1'), output
|
141
|
+
assert_match %(@daily cd /your/path && bundle exec script/runner -e production 'runner_1'), output
|
142
142
|
assert_match '@daily command_1', output
|
143
|
-
assert_match %(@daily cd /your/path && script/runner -e production 'runner_2'), output
|
143
|
+
assert_match %(@daily cd /your/path && bundle exec script/runner -e production 'runner_2'), output
|
144
144
|
assert_match '@daily command_2', output
|
145
145
|
end
|
146
146
|
|
@@ -13,7 +13,7 @@ class OutputDefaultDefinedJobsTest < Whenever::TestCase
|
|
13
13
|
end
|
14
14
|
file
|
15
15
|
|
16
|
-
assert_match
|
16
|
+
assert_match(/^.+ .+ .+ .+ blahblah$/, output)
|
17
17
|
end
|
18
18
|
|
19
19
|
test "A plain command with no job template set" do
|
@@ -24,7 +24,7 @@ class OutputDefaultDefinedJobsTest < Whenever::TestCase
|
|
24
24
|
end
|
25
25
|
file
|
26
26
|
|
27
|
-
assert_match
|
27
|
+
assert_match(/^.+ .+ .+ .+ \/bin\/bash -l -c 'blahblah'$/, output)
|
28
28
|
end
|
29
29
|
|
30
30
|
test "A plain command with a job_template using a normal parameter" do
|
@@ -37,7 +37,7 @@ class OutputDefaultDefinedJobsTest < Whenever::TestCase
|
|
37
37
|
end
|
38
38
|
file
|
39
39
|
|
40
|
-
assert_match
|
40
|
+
assert_match(/^.+ .+ .+ .+ \/bin\/bash -l -c 'cd \/tmp \&\& blahblah'$/, output)
|
41
41
|
end
|
42
42
|
|
43
43
|
test "A plain command that overrides the job_template set" do
|
@@ -50,8 +50,8 @@ class OutputDefaultDefinedJobsTest < Whenever::TestCase
|
|
50
50
|
file
|
51
51
|
|
52
52
|
|
53
|
-
assert_match
|
54
|
-
assert_no_match
|
53
|
+
assert_match(/^.+ .+ .+ .+ \/bin\/sh -l -c 'blahblah'$/, output)
|
54
|
+
assert_no_match(/bash/, output)
|
55
55
|
end
|
56
56
|
|
57
57
|
test "A plain command that overrides the job_template set using a parameter" do
|
@@ -65,8 +65,8 @@ class OutputDefaultDefinedJobsTest < Whenever::TestCase
|
|
65
65
|
file
|
66
66
|
|
67
67
|
|
68
|
-
assert_match
|
69
|
-
assert_no_match
|
68
|
+
assert_match(/^.+ .+ .+ .+ \/bin\/sh -l -c 'cd \/tmp && blahblah'$/, output)
|
69
|
+
assert_no_match(/bash/, output)
|
70
70
|
end
|
71
71
|
|
72
72
|
test "A plain command that is conditional on default environent and path" do
|
@@ -81,7 +81,7 @@ class OutputDefaultDefinedJobsTest < Whenever::TestCase
|
|
81
81
|
end
|
82
82
|
file
|
83
83
|
|
84
|
-
assert_match
|
84
|
+
assert_match(/blahblah/, output)
|
85
85
|
end
|
86
86
|
|
87
87
|
# runner
|
@@ -96,7 +96,7 @@ class OutputDefaultDefinedJobsTest < Whenever::TestCase
|
|
96
96
|
end
|
97
97
|
file
|
98
98
|
|
99
|
-
assert_match two_hours + %( cd /my/path && script/runner -e production 'blahblah'), output
|
99
|
+
assert_match two_hours + %( cd /my/path && bundle exec script/runner -e production 'blahblah'), output
|
100
100
|
end
|
101
101
|
|
102
102
|
test "A runner that overrides the path set" do
|
@@ -109,7 +109,21 @@ class OutputDefaultDefinedJobsTest < Whenever::TestCase
|
|
109
109
|
end
|
110
110
|
file
|
111
111
|
|
112
|
-
assert_match two_hours + %( cd /some/other/path && script/runner -e production 'blahblah'), output
|
112
|
+
assert_match two_hours + %( cd /some/other/path && bundle exec script/runner -e production 'blahblah'), output
|
113
|
+
end
|
114
|
+
|
115
|
+
test "A runner for a non-bundler app" do
|
116
|
+
Whenever.expects(:bundler?).returns(false)
|
117
|
+
output = Whenever.cron \
|
118
|
+
<<-file
|
119
|
+
set :job_template, nil
|
120
|
+
set :path, '/my/path'
|
121
|
+
every 2.hours do
|
122
|
+
runner 'blahblah'
|
123
|
+
end
|
124
|
+
file
|
125
|
+
|
126
|
+
assert_match two_hours + %( cd /my/path && script/runner -e production 'blahblah'), output
|
113
127
|
end
|
114
128
|
|
115
129
|
test "A runner for an app with bin/rails" do
|
@@ -155,6 +169,19 @@ class OutputDefaultDefinedJobsTest < Whenever::TestCase
|
|
155
169
|
assert_match two_hours + ' cd /my/path && RAILS_ENV=production bundle exec rake blahblah --silent', output
|
156
170
|
end
|
157
171
|
|
172
|
+
test "A rake command with arguments" do
|
173
|
+
output = Whenever.cron \
|
174
|
+
<<-file
|
175
|
+
set :job_template, nil
|
176
|
+
set :path, '/my/path'
|
177
|
+
every 2.hours do
|
178
|
+
rake "blahblah[foobar]"
|
179
|
+
end
|
180
|
+
file
|
181
|
+
|
182
|
+
assert_match two_hours + ' cd /my/path && RAILS_ENV=production bundle exec rake blahblah[foobar] --silent', output
|
183
|
+
end
|
184
|
+
|
158
185
|
test "A rake for a non-bundler app" do
|
159
186
|
Whenever.expects(:path).at_least_once.returns('/my/path')
|
160
187
|
Whenever.expects(:bundler?).returns(false)
|
@@ -11,7 +11,7 @@ class OutputDefinedJobTest < Whenever::TestCase
|
|
11
11
|
end
|
12
12
|
file
|
13
13
|
|
14
|
-
assert_match
|
14
|
+
assert_match(/^.+ .+ .+ .+ before during after$/, output)
|
15
15
|
end
|
16
16
|
|
17
17
|
test "defined job with a :task and some options" do
|
@@ -24,7 +24,7 @@ class OutputDefinedJobTest < Whenever::TestCase
|
|
24
24
|
end
|
25
25
|
file
|
26
26
|
|
27
|
-
assert_match
|
27
|
+
assert_match(/^.+ .+ .+ .+ before during after happy birthday$/, output)
|
28
28
|
end
|
29
29
|
|
30
30
|
test "defined job with a :task and an option where the option is set globally" do
|
@@ -38,7 +38,7 @@ class OutputDefinedJobTest < Whenever::TestCase
|
|
38
38
|
end
|
39
39
|
file
|
40
40
|
|
41
|
-
assert_match
|
41
|
+
assert_match(/^.+ .+ .+ .+ before during after happy$/, output)
|
42
42
|
end
|
43
43
|
|
44
44
|
test "defined job with a :task and an option where the option is set globally and locally" do
|
@@ -52,7 +52,7 @@ class OutputDefinedJobTest < Whenever::TestCase
|
|
52
52
|
end
|
53
53
|
file
|
54
54
|
|
55
|
-
assert_match
|
55
|
+
assert_match(/^.+ .+ .+ .+ before during after local$/, output)
|
56
56
|
end
|
57
57
|
|
58
58
|
test "defined job with a :task and an option that is not set" do
|
@@ -65,7 +65,7 @@ class OutputDefinedJobTest < Whenever::TestCase
|
|
65
65
|
end
|
66
66
|
file
|
67
67
|
|
68
|
-
assert_match
|
68
|
+
assert_match(/^.+ .+ .+ .+ before during after :option1$/, output)
|
69
69
|
end
|
70
70
|
|
71
71
|
test "defined job that uses a :path where none is explicitly set" do
|
@@ -11,7 +11,7 @@ class OutputRedirectionTest < Whenever::TestCase
|
|
11
11
|
end
|
12
12
|
file
|
13
13
|
|
14
|
-
assert_match
|
14
|
+
assert_match(/^.+ .+ .+ .+ blahblah >> \/dev\/null 2>&1$/, output)
|
15
15
|
end
|
16
16
|
|
17
17
|
|
@@ -25,7 +25,7 @@ class OutputRedirectionTest < Whenever::TestCase
|
|
25
25
|
end
|
26
26
|
file
|
27
27
|
|
28
|
-
assert_match
|
28
|
+
assert_match(/^.+ .+ .+ .+ blahblah >> logfile.log 2>&1$/, output)
|
29
29
|
end
|
30
30
|
|
31
31
|
test "command when the error and standard output is set by the command" do
|
@@ -37,7 +37,7 @@ class OutputRedirectionTest < Whenever::TestCase
|
|
37
37
|
end
|
38
38
|
file
|
39
39
|
|
40
|
-
assert_match
|
40
|
+
assert_match(/^.+ .+ .+ .+ blahblah >> dev_null 2>> dev_err$/, output)
|
41
41
|
end
|
42
42
|
|
43
43
|
test "command when the output is set and the comand overrides it" do
|
@@ -50,8 +50,8 @@ class OutputRedirectionTest < Whenever::TestCase
|
|
50
50
|
end
|
51
51
|
file
|
52
52
|
|
53
|
-
assert_no_match
|
54
|
-
assert_match
|
53
|
+
assert_no_match(/.+ .+ .+ .+ blahblah >> logfile.log 2>&1/, output)
|
54
|
+
assert_match(/^.+ .+ .+ .+ blahblah >> otherlog.log 2>&1$/, output)
|
55
55
|
end
|
56
56
|
|
57
57
|
test "command when the output is set and the comand overrides with standard and error" do
|
@@ -64,8 +64,8 @@ class OutputRedirectionTest < Whenever::TestCase
|
|
64
64
|
end
|
65
65
|
file
|
66
66
|
|
67
|
-
assert_no_match
|
68
|
-
assert_match
|
67
|
+
assert_no_match(/.+ .+ .+ .+ blahblah >> logfile.log 2>&1/, output)
|
68
|
+
assert_match(/^.+ .+ .+ .+ blahblah >> dev_null 2>> dev_err$/, output)
|
69
69
|
end
|
70
70
|
|
71
71
|
test "command when the output is set and the comand rejects it" do
|
@@ -78,8 +78,8 @@ class OutputRedirectionTest < Whenever::TestCase
|
|
78
78
|
end
|
79
79
|
file
|
80
80
|
|
81
|
-
assert_no_match
|
82
|
-
assert_match
|
81
|
+
assert_no_match(/.+ .+ .+ .+ blahblah >> logfile.log 2>&1/, output)
|
82
|
+
assert_match(/^.+ .+ .+ .+ blahblah$/, output)
|
83
83
|
end
|
84
84
|
|
85
85
|
test "command when the output is set and is overridden by the :set option" do
|
@@ -92,8 +92,8 @@ class OutputRedirectionTest < Whenever::TestCase
|
|
92
92
|
end
|
93
93
|
file
|
94
94
|
|
95
|
-
assert_no_match
|
96
|
-
assert_match
|
95
|
+
assert_no_match(/.+ .+ .+ .+ blahblah >> logfile.log 2>&1/, output)
|
96
|
+
assert_match(/^.+ .+ .+ .+ blahblah >> otherlog.log 2>&1/, output)
|
97
97
|
end
|
98
98
|
|
99
99
|
test "command when the error and standard output is set" do
|
@@ -106,7 +106,7 @@ class OutputRedirectionTest < Whenever::TestCase
|
|
106
106
|
end
|
107
107
|
file
|
108
108
|
|
109
|
-
assert_match
|
109
|
+
assert_match(/^.+ .+ .+ .+ blahblah >> dev_null 2>> dev_err$/, output)
|
110
110
|
end
|
111
111
|
|
112
112
|
test "command when error output is set" do
|
@@ -119,7 +119,7 @@ class OutputRedirectionTest < Whenever::TestCase
|
|
119
119
|
end
|
120
120
|
file
|
121
121
|
|
122
|
-
assert_match
|
122
|
+
assert_match(/^.+ .+ .+ .+ blahblah 2>> dev_null$/, output)
|
123
123
|
end
|
124
124
|
|
125
125
|
test "command when the standard output is set" do
|
@@ -132,7 +132,7 @@ class OutputRedirectionTest < Whenever::TestCase
|
|
132
132
|
end
|
133
133
|
file
|
134
134
|
|
135
|
-
assert_match
|
135
|
+
assert_match(/^.+ .+ .+ .+ blahblah >> dev_out$/, output)
|
136
136
|
end
|
137
137
|
|
138
138
|
test "command when error output is set by the command" do
|
@@ -144,7 +144,7 @@ class OutputRedirectionTest < Whenever::TestCase
|
|
144
144
|
end
|
145
145
|
file
|
146
146
|
|
147
|
-
assert_match
|
147
|
+
assert_match(/^.+ .+ .+ .+ blahblah 2>> dev_err$/, output)
|
148
148
|
end
|
149
149
|
|
150
150
|
test "command when standard output is set by the command" do
|
@@ -156,7 +156,7 @@ class OutputRedirectionTest < Whenever::TestCase
|
|
156
156
|
end
|
157
157
|
file
|
158
158
|
|
159
|
-
assert_match
|
159
|
+
assert_match(/^.+ .+ .+ .+ blahblah >> dev_out$/, output)
|
160
160
|
end
|
161
161
|
|
162
162
|
test "command when standard output is set to nil" do
|
@@ -168,7 +168,7 @@ class OutputRedirectionTest < Whenever::TestCase
|
|
168
168
|
end
|
169
169
|
file
|
170
170
|
|
171
|
-
assert_match
|
171
|
+
assert_match(/^.+ .+ .+ .+ blahblah > \/dev\/null$/, output)
|
172
172
|
end
|
173
173
|
|
174
174
|
test "command when standard error is set to nil" do
|
@@ -180,7 +180,7 @@ class OutputRedirectionTest < Whenever::TestCase
|
|
180
180
|
end
|
181
181
|
file
|
182
182
|
|
183
|
-
assert_match
|
183
|
+
assert_match(/^.+ .+ .+ .+ blahblah 2> \/dev\/null$/, output)
|
184
184
|
end
|
185
185
|
|
186
186
|
test "command when standard output and standard error is set to nil" do
|
@@ -192,7 +192,7 @@ class OutputRedirectionTest < Whenever::TestCase
|
|
192
192
|
end
|
193
193
|
file
|
194
194
|
|
195
|
-
assert_match
|
195
|
+
assert_match(/^.+ .+ .+ .+ blahblah > \/dev\/null 2>&1$/, output)
|
196
196
|
end
|
197
197
|
|
198
198
|
test "command when standard output is set and standard error is set to nil" do
|
@@ -204,7 +204,7 @@ class OutputRedirectionTest < Whenever::TestCase
|
|
204
204
|
end
|
205
205
|
file
|
206
206
|
|
207
|
-
assert_match
|
207
|
+
assert_match(/^.+ .+ .+ .+ blahblah >> my.log 2> \/dev\/null$/, output)
|
208
208
|
end
|
209
209
|
|
210
210
|
test "command when standard output is nil and standard error is set" do
|
@@ -216,7 +216,7 @@ class OutputRedirectionTest < Whenever::TestCase
|
|
216
216
|
end
|
217
217
|
file
|
218
218
|
|
219
|
-
assert_match
|
219
|
+
assert_match(/^.+ .+ .+ .+ blahblah >> \/dev\/null 2>> my_error.log$/, output)
|
220
220
|
end
|
221
221
|
|
222
222
|
test "command when the deprecated :cron_log is set" do
|
@@ -229,7 +229,7 @@ class OutputRedirectionTest < Whenever::TestCase
|
|
229
229
|
end
|
230
230
|
file
|
231
231
|
|
232
|
-
assert_match
|
232
|
+
assert_match(/^.+ .+ .+ .+ blahblah >> cron.log 2>&1$/, output)
|
233
233
|
end
|
234
234
|
|
235
235
|
|
@@ -243,6 +243,6 @@ class OutputRedirectionTest < Whenever::TestCase
|
|
243
243
|
end
|
244
244
|
file
|
245
245
|
|
246
|
-
assert_match
|
246
|
+
assert_match(/^.+ .+ .+ .+ blahblah 2>&1 | logger -t whenever_cron$/, output)
|
247
247
|
end
|
248
248
|
end
|
data/test/test_case.rb
CHANGED
@@ -1,21 +1,14 @@
|
|
1
1
|
module Whenever
|
2
|
+
require 'minitest/autorun'
|
2
3
|
begin
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
# 1.9.3
|
9
|
-
class TestCase < MiniTest::Unit::TestCase; end
|
10
|
-
end
|
11
|
-
rescue LoadError
|
12
|
-
# 1.8.7
|
13
|
-
require 'test/unit'
|
14
|
-
class TestCase < Test::Unit::TestCase
|
15
|
-
def default_test; end
|
16
|
-
end
|
4
|
+
# 2.0.0
|
5
|
+
class TestCase < MiniTest::Test; end
|
6
|
+
rescue NameError
|
7
|
+
# 1.9.3
|
8
|
+
class TestCase < MiniTest::Unit::TestCase; end
|
17
9
|
end
|
18
10
|
|
11
|
+
|
19
12
|
class TestCase
|
20
13
|
class << self
|
21
14
|
def setup(&block)
|
data/test/test_helper.rb
CHANGED
@@ -18,13 +18,13 @@ module Whenever::TestHelpers
|
|
18
18
|
|
19
19
|
def assert_days_and_hours_and_minutes_equals(expected, time)
|
20
20
|
cron = parse_time(Whenever.seconds(2, :months), 'some task', time)
|
21
|
-
minutes, hours, days,
|
21
|
+
minutes, hours, days, _ = cron.split(' ')
|
22
22
|
assert_equal expected, [days, hours, minutes]
|
23
23
|
end
|
24
24
|
|
25
25
|
def assert_hours_and_minutes_equals(expected, time)
|
26
26
|
cron = parse_time(Whenever.seconds(2, :days), 'some task', time)
|
27
|
-
minutes, hours,
|
27
|
+
minutes, hours, _ = cron.split(' ')
|
28
28
|
assert_equal expected, [hours, minutes]
|
29
29
|
end
|
30
30
|
|
data/test/unit/cron_test.rb
CHANGED
@@ -11,7 +11,7 @@ class CronTest < Whenever::TestCase
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
# For
|
14
|
+
# For sanity, do some tests on straight cron-syntax strings
|
15
15
|
should "parse correctly" do
|
16
16
|
assert_equal '* * * * *', parse_time(Whenever.seconds(1, :minute))
|
17
17
|
assert_equal '0,5,10,15,20,25,30,35,40,45,50,55 * * * *', parse_time(Whenever.seconds(5, :minutes))
|
@@ -213,9 +213,27 @@ class CronParseShortcutsTest < Whenever::TestCase
|
|
213
213
|
end
|
214
214
|
end
|
215
215
|
|
216
|
+
class CronParseRubyTimeTest < Whenever::TestCase
|
217
|
+
should "process things like `1.day` correctly" do
|
218
|
+
assert_equal "0 0 * * *", parse_time(1.day)
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
216
222
|
class CronParseRawTest < Whenever::TestCase
|
223
|
+
should "raise if cron-syntax string is too long" do
|
224
|
+
assert_raises ArgumentError do
|
225
|
+
parse_time('* * * * * *')
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
should "raise if cron-syntax string is invalid" do
|
230
|
+
assert_raises ArgumentError do
|
231
|
+
parse_time('** * * * *')
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
217
235
|
should "return the same cron sytax" do
|
218
|
-
crons = ['0 0 27-31 * *', '* * * * *', '2/3 1,9,22 11-26 1-6 *',
|
236
|
+
crons = ['0 0 27-31 * *', '* * * * *', '2/3 1,9,22 11-26 1-6 *', '*/5 6-23 * * *',
|
219
237
|
"*\t*\t*\t*\t*",
|
220
238
|
'@reboot', '@yearly', '@annually', '@monthly', '@weekly',
|
221
239
|
'@daily', '@midnight', '@hourly']
|
data/whenever.gemspec
CHANGED
@@ -16,9 +16,12 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.test_files = `git ls-files -- test/{functional,unit}/*`.split("\n")
|
17
17
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
18
|
s.require_paths = ["lib"]
|
19
|
+
s.required_ruby_version = ">= 1.9.3"
|
19
20
|
|
20
21
|
s.add_dependency "chronic", ">= 0.6.3"
|
21
22
|
|
22
|
-
s.add_development_dependency "
|
23
|
+
s.add_development_dependency "bundler"
|
23
24
|
s.add_development_dependency "rake"
|
25
|
+
s.add_development_dependency "mocha", ">= 0.9.5"
|
26
|
+
s.add_development_dependency "minitest"
|
24
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whenever
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Javan Makhmali
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chronic
|
@@ -24,6 +24,34 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
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'
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: mocha
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,7 +67,7 @@ dependencies:
|
|
39
67
|
- !ruby/object:Gem::Version
|
40
68
|
version: 0.9.5
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
70
|
+
name: minitest
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
44
72
|
requirements:
|
45
73
|
- - ">="
|
@@ -70,6 +98,8 @@ files:
|
|
70
98
|
- Rakefile
|
71
99
|
- bin/whenever
|
72
100
|
- bin/wheneverize
|
101
|
+
- gemfiles/activesupport4.1.gemfile
|
102
|
+
- gemfiles/activesupport4.2.gemfile
|
73
103
|
- lib/whenever.rb
|
74
104
|
- lib/whenever/capistrano.rb
|
75
105
|
- lib/whenever/capistrano/v2/hooks.rb
|
@@ -80,7 +110,9 @@ files:
|
|
80
110
|
- lib/whenever/cron.rb
|
81
111
|
- lib/whenever/job.rb
|
82
112
|
- lib/whenever/job_list.rb
|
113
|
+
- lib/whenever/numeric.rb
|
83
114
|
- lib/whenever/numeric_seconds.rb
|
115
|
+
- lib/whenever/os.rb
|
84
116
|
- lib/whenever/output_redirection.rb
|
85
117
|
- lib/whenever/setup.rb
|
86
118
|
- lib/whenever/tasks/whenever.rake
|
@@ -110,7 +142,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
142
|
requirements:
|
111
143
|
- - ">="
|
112
144
|
- !ruby/object:Gem::Version
|
113
|
-
version:
|
145
|
+
version: 1.9.3
|
114
146
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
147
|
requirements:
|
116
148
|
- - ">="
|
@@ -118,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
150
|
version: '0'
|
119
151
|
requirements: []
|
120
152
|
rubyforge_project:
|
121
|
-
rubygems_version: 2.
|
153
|
+
rubygems_version: 2.5.1
|
122
154
|
signing_key:
|
123
155
|
specification_version: 4
|
124
156
|
summary: Cron jobs in ruby.
|
@@ -1,43 +0,0 @@
|
|
1
|
-
namespace :whenever do
|
2
|
-
def setup_whenever_task(*args, &block)
|
3
|
-
args = Array(fetch(:whenever_command)) + args
|
4
|
-
|
5
|
-
on roles fetch(:whenever_roles) do |host|
|
6
|
-
args_for_host = block_given? ? args + Array(yield(host)) : args
|
7
|
-
within release_path do
|
8
|
-
with fetch(:whenever_command_environment_variables) do
|
9
|
-
execute *args_for_host
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
desc "Update application's crontab entries using Whenever"
|
16
|
-
task :update_crontab do
|
17
|
-
setup_whenever_task do |host|
|
18
|
-
roles = host.roles_array.join(",")
|
19
|
-
[fetch(:whenever_update_flags), "--roles=#{roles}"]
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
desc "Clear application's crontab entries using Whenever"
|
24
|
-
task :clear_crontab do
|
25
|
-
setup_whenever_task(fetch(:whenever_clear_flags))
|
26
|
-
end
|
27
|
-
|
28
|
-
after "deploy:updated", "whenever:update_crontab"
|
29
|
-
after "deploy:reverted", "whenever:update_crontab"
|
30
|
-
end
|
31
|
-
|
32
|
-
namespace :load do
|
33
|
-
task :defaults do
|
34
|
-
set :whenever_roles, ->{ :db }
|
35
|
-
set :whenever_command, ->{ [:bundle, :exec, :whenever] }
|
36
|
-
set :whenever_command_environment_variables, ->{ {} }
|
37
|
-
set :whenever_identifier, ->{ fetch :application }
|
38
|
-
set :whenever_environment, ->{ fetch :rails_env, fetch(:stage, "production") }
|
39
|
-
set :whenever_variables, ->{ "environment=#{fetch :whenever_environment}" }
|
40
|
-
set :whenever_update_flags, ->{ "--update-crontab #{fetch :whenever_identifier} --set #{fetch :whenever_variables}" }
|
41
|
-
set :whenever_clear_flags, ->{ "--clear-crontab #{fetch :whenever_identifier}" }
|
42
|
-
end
|
43
|
-
end
|