whenever 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +9 -0
- data/LICENSE +1 -1
- data/README.md +4 -12
- data/lib/whenever/capistrano/v3/tasks/whenever.rake +20 -21
- data/lib/whenever/job.rb +3 -6
- data/lib/whenever/setup.rb +7 -16
- data/lib/whenever/tasks/whenever.rake +20 -21
- data/lib/whenever/version.rb +1 -1
- data/test/unit/job_test.rb +4 -5
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0615f43fa1b0a98f86c01020d35ae339a2767917
|
4
|
+
data.tar.gz: cb5c35a7f4703864be41ef4d5692092a190a8cd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3aefffaf5046d3501ff117d470281dad9eb079b11a979e2b810adf707f69d5dbdaffc2aac56aaed8b3125637742506e5e29129af5fc0163463e6eab42bacb416
|
7
|
+
data.tar.gz: f1e06eb27177312e775da44615de0fd79a9cb8ba331f7d525cb82c28d158a0731edf5981660339a4651712667dfd9dba4dc16e04bcb2be2b90a5826dc1dbed71
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
### 0.9.1 / March 2, 2014
|
2
|
+
|
3
|
+
* Pass `--roles` option to `whenever` in Capistrano 3 tasks. [betesh, Javan Makhmali]
|
4
|
+
|
5
|
+
* Allow setting `:whenever_command` for Capistrano 3. [Javan Makhmali]
|
6
|
+
|
7
|
+
* Allow `:whenever` command to be mapped in SSHKit. [Javan Makhmali]
|
8
|
+
|
9
|
+
|
1
10
|
### 0.9.0 / December 17, 2013
|
2
11
|
|
3
12
|
* Capistrano V3 support. [Philip Hallstrom]
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -106,7 +106,7 @@ In your "config/deploy.rb" file:
|
|
106
106
|
require "whenever/capistrano"
|
107
107
|
```
|
108
108
|
|
109
|
-
Take a look at the recipe for options you can set. <
|
109
|
+
Take a look at the recipe for options you can set. <https://github.com/javan/whenever/blob/master/lib/whenever/capistrano/v2/recipes.rb>
|
110
110
|
For example, if you're using bundler do this:
|
111
111
|
|
112
112
|
```ruby
|
@@ -139,14 +139,6 @@ In your "Capfile" file:
|
|
139
139
|
require "whenever/capistrano"
|
140
140
|
```
|
141
141
|
|
142
|
-
If you're using bundler do this. **DO NOT** set ':whenever_command' to 'bundle exec whenever'. It will **NOT** work.
|
143
|
-
Be default, 'bundle exec whenever' will be called. If you need something different and the command contains a space
|
144
|
-
you will need to map it via the following method. This is an issue with SSHKit.
|
145
|
-
|
146
|
-
```ruby
|
147
|
-
SSHKit.config.command_map[:whenever] = "bundle exec whenever"
|
148
|
-
```
|
149
|
-
|
150
142
|
Take a look at the load:defaults (bottom of file) task for options you can set. <http://github.com/javan/whenever/blob/master/lib/whenever/tasks/whenever.rake>. For example, to namespace the crontab entries by application and stage do this.
|
151
143
|
|
152
144
|
```ruby
|
@@ -215,7 +207,7 @@ If your production environment uses RVM (Ruby Version Manager) you will run into
|
|
215
207
|
|
216
208
|
`rvm_trust_rvmrcs_flag=1`
|
217
209
|
|
218
|
-
This tells rvm to trust all rvmrc files
|
210
|
+
This tells rvm to trust all rvmrc files.
|
219
211
|
|
220
212
|
### The `whenever` command
|
221
213
|
|
@@ -243,8 +235,8 @@ It's a little bit dated now, but remains a good introduction.
|
|
243
235
|
|
244
236
|
----
|
245
237
|
|
246
|
-
Compatible with Ruby 1.8.7-2.
|
238
|
+
Compatible with Ruby 1.8.7-2.1.0, JRuby, and Rubinius. [![Build Status](https://secure.travis-ci.org/javan/whenever.png)](http://travis-ci.org/javan/whenever)
|
247
239
|
|
248
240
|
----
|
249
241
|
|
250
|
-
Copyright ©
|
242
|
+
Copyright © 2014 Javan Makhmali
|
@@ -1,40 +1,39 @@
|
|
1
1
|
namespace :whenever do
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
def setup_whenever_task(*args, &block)
|
3
|
+
SSHKit.config.command_map[:whenever] = fetch(:whenever_command)
|
4
|
+
|
5
|
+
on roles fetch(:whenever_roles) do |host|
|
6
|
+
args = args + Array(yield(host)) if block_given?
|
5
7
|
within release_path do
|
6
|
-
|
7
|
-
execute
|
8
|
-
else
|
9
|
-
execute :bundle, :exec, :whenever, fetch(:whenever_update_flags)
|
8
|
+
with fetch(:whenever_command_environment_variables) do
|
9
|
+
execute :whenever, *args
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
14
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
|
+
|
15
23
|
desc "Clear application's crontab entries using Whenever"
|
16
24
|
task :clear_crontab do
|
17
|
-
|
18
|
-
within release_path do
|
19
|
-
if fetch(:whenever_command)
|
20
|
-
execute %{#{fetch(:whenever_command)} #{fetch(:whenever_clear_flags)}}
|
21
|
-
else
|
22
|
-
execute :bundle, :exec, :whenever, fetch(:whenever_clear_flags)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
25
|
+
setup_whenever_task(fetch(:whenever_clear_flags))
|
26
26
|
end
|
27
27
|
|
28
|
-
after
|
29
|
-
after
|
30
|
-
|
28
|
+
after "deploy:updated", "whenever:update_crontab"
|
29
|
+
after "deploy:reverted", "whenever:update_crontab"
|
31
30
|
end
|
32
31
|
|
33
32
|
namespace :load do
|
34
33
|
task :defaults do
|
35
34
|
set :whenever_roles, ->{ :db }
|
36
|
-
set :
|
37
|
-
set :
|
35
|
+
set :whenever_command, ->{ "bundle exec whenever" }
|
36
|
+
set :whenever_command_environment_variables, ->{ {} }
|
38
37
|
set :whenever_identifier, ->{ fetch :application }
|
39
38
|
set :whenever_environment, ->{ fetch :rails_env, "production" }
|
40
39
|
set :whenever_variables, ->{ "environment=#{fetch :whenever_environment}" }
|
data/lib/whenever/job.rb
CHANGED
@@ -17,11 +17,8 @@ module Whenever
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def output
|
20
|
-
job = process_template(@template, @options)
|
21
|
-
out = process_template(@job_template, @options.merge(:job => job))
|
22
|
-
if out =~ /\n/
|
23
|
-
raise ArgumentError, "Task contains newline"
|
24
|
-
end
|
20
|
+
job = process_template(@template, @options)
|
21
|
+
out = process_template(@job_template, @options.merge(:job => job))
|
25
22
|
out.gsub(/%/, '\%')
|
26
23
|
end
|
27
24
|
|
@@ -43,7 +40,7 @@ module Whenever
|
|
43
40
|
else
|
44
41
|
option
|
45
42
|
end
|
46
|
-
end
|
43
|
+
end.squish
|
47
44
|
end
|
48
45
|
|
49
46
|
def escape_single_quotes(str)
|
data/lib/whenever/setup.rb
CHANGED
@@ -9,20 +9,7 @@ set :path, Whenever.path
|
|
9
9
|
# http://blog.scoutapp.com/articles/2010/09/07/rvm-and-cron-in-production
|
10
10
|
set :job_template, "/bin/bash -l -c ':job'"
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
# Run rake through bundler if possible
|
15
|
-
if Whenever.bundler?
|
16
|
-
job_type :rake, "cd :path && :environment_variable=:environment bundle exec rake :task --silent :output"
|
17
|
-
job_type :script, "cd :path && :environment_variable=:environment bundle exec script/:task :output"
|
18
|
-
else
|
19
|
-
job_type :rake, "cd :path && :environment_variable=:environment rake :task --silent :output"
|
20
|
-
job_type :script, "cd :path && :environment_variable=:environment script/:task :output"
|
21
|
-
end
|
22
|
-
|
23
|
-
# Create a runner job that's appropriate for the Rails version
|
24
|
-
def runner_for_app
|
25
|
-
case
|
12
|
+
set :runner_command, case
|
26
13
|
when Whenever.bin_rails?
|
27
14
|
"bin/rails runner"
|
28
15
|
when Whenever.script_rails?
|
@@ -30,6 +17,10 @@ def runner_for_app
|
|
30
17
|
else
|
31
18
|
"script/runner"
|
32
19
|
end
|
33
|
-
end
|
34
20
|
|
35
|
-
|
21
|
+
set :bundle_command, Whenever.bundler? ? "bundle exec" : ""
|
22
|
+
|
23
|
+
job_type :command, ":task :output"
|
24
|
+
job_type :rake, "cd :path && :environment_variable=:environment :bundle_command rake :task --silent :output"
|
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"
|
@@ -1,40 +1,39 @@
|
|
1
1
|
namespace :whenever do
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
def setup_whenever_task(*args, &block)
|
3
|
+
SSHKit.config.command_map[:whenever] = fetch(:whenever_command)
|
4
|
+
|
5
|
+
on roles fetch(:whenever_roles) do |host|
|
6
|
+
args = args + Array(yield(host)) if block_given?
|
5
7
|
within release_path do
|
6
|
-
|
7
|
-
execute
|
8
|
-
else
|
9
|
-
execute :bundle, :exec, :whenever, fetch(:whenever_update_flags)
|
8
|
+
with fetch(:whenever_command_environment_variables) do
|
9
|
+
execute :whenever, *args
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
14
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
|
+
|
15
23
|
desc "Clear application's crontab entries using Whenever"
|
16
24
|
task :clear_crontab do
|
17
|
-
|
18
|
-
within release_path do
|
19
|
-
if fetch(:whenever_command)
|
20
|
-
execute %{#{fetch(:whenever_command)} #{fetch(:whenever_clear_flags)}}
|
21
|
-
else
|
22
|
-
execute :bundle, :exec, :whenever, fetch(:whenever_clear_flags)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
25
|
+
setup_whenever_task(fetch(:whenever_clear_flags))
|
26
26
|
end
|
27
27
|
|
28
|
-
after
|
29
|
-
after
|
30
|
-
|
28
|
+
after "deploy:updated", "whenever:update_crontab"
|
29
|
+
after "deploy:reverted", "whenever:update_crontab"
|
31
30
|
end
|
32
31
|
|
33
32
|
namespace :load do
|
34
33
|
task :defaults do
|
35
34
|
set :whenever_roles, ->{ :db }
|
36
|
-
set :
|
37
|
-
set :
|
35
|
+
set :whenever_command, ->{ "bundle exec whenever" }
|
36
|
+
set :whenever_command_environment_variables, ->{ {} }
|
38
37
|
set :whenever_identifier, ->{ fetch :application }
|
39
38
|
set :whenever_environment, ->{ fetch :rails_env, "production" }
|
40
39
|
set :whenever_variables, ->{ "environment=#{fetch :whenever_environment}" }
|
data/lib/whenever/version.rb
CHANGED
data/test/unit/job_test.rb
CHANGED
@@ -54,14 +54,13 @@ class JobTest < Test::Unit::TestCase
|
|
54
54
|
assert_equal %q(before percent preceded by a backslash -> \\\% <- after), job.output
|
55
55
|
end
|
56
56
|
|
57
|
-
should "
|
57
|
+
should "squish spaces and newlines" do
|
58
58
|
job = new_job(
|
59
59
|
:template => "before :foo after",
|
60
|
-
:foo => "newline -> \n <- newline"
|
60
|
+
:foo => "newline -> \n <- newline space -> <- space"
|
61
61
|
)
|
62
|
-
|
63
|
-
|
64
|
-
end
|
62
|
+
|
63
|
+
assert_equal "before newline -> <- newline space -> <- space after", job.output
|
65
64
|
end
|
66
65
|
end
|
67
66
|
|
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.1
|
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: 2014-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chronic
|
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
144
|
version: '0'
|
145
145
|
requirements: []
|
146
146
|
rubyforge_project:
|
147
|
-
rubygems_version: 2.
|
147
|
+
rubygems_version: 2.0.14
|
148
148
|
signing_key:
|
149
149
|
specification_version: 4
|
150
150
|
summary: Cron jobs in ruby.
|