super-clean-box 0.0.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.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/super-clean-box.gemspec +12 -0
  3. data/whenever-1.1.2/Appraisals +69 -0
  4. data/whenever-1.1.2/CHANGELOG.md +434 -0
  5. data/whenever-1.1.2/CONTRIBUTING.md +38 -0
  6. data/whenever-1.1.2/Gemfile +11 -0
  7. data/whenever-1.1.2/LICENSE +22 -0
  8. data/whenever-1.1.2/Makefile +5 -0
  9. data/whenever-1.1.2/README.md +350 -0
  10. data/whenever-1.1.2/Rakefile +10 -0
  11. data/whenever-1.1.2/bin/whenever +49 -0
  12. data/whenever-1.1.2/bin/wheneverize +71 -0
  13. data/whenever-1.1.2/gemfiles/activesupport5.0.gemfile +11 -0
  14. data/whenever-1.1.2/gemfiles/activesupport5.1.gemfile +11 -0
  15. data/whenever-1.1.2/gemfiles/activesupport5.2.gemfile +11 -0
  16. data/whenever-1.1.2/gemfiles/activesupport6.0.gemfile +17 -0
  17. data/whenever-1.1.2/gemfiles/activesupport6.1.gemfile +17 -0
  18. data/whenever-1.1.2/gemfiles/activesupport7.0.gemfile +11 -0
  19. data/whenever-1.1.2/gemfiles/activesupport7.1.gemfile +11 -0
  20. data/whenever-1.1.2/gemfiles/activesupport7.2.gemfile +11 -0
  21. data/whenever-1.1.2/gemfiles/activesupport8.0.gemfile +11 -0
  22. data/whenever-1.1.2/gemfiles/activesupport8.1.gemfile +11 -0
  23. data/whenever-1.1.2/lib/whenever/capistrano/v2/hooks.rb +8 -0
  24. data/whenever-1.1.2/lib/whenever/capistrano/v2/recipes.rb +49 -0
  25. data/whenever-1.1.2/lib/whenever/capistrano/v2/support.rb +53 -0
  26. data/whenever-1.1.2/lib/whenever/capistrano/v3/tasks/whenever.rake +56 -0
  27. data/whenever-1.1.2/lib/whenever/capistrano.rb +7 -0
  28. data/whenever-1.1.2/lib/whenever/command_line.rb +171 -0
  29. data/whenever-1.1.2/lib/whenever/cron.rb +181 -0
  30. data/whenever-1.1.2/lib/whenever/job.rb +56 -0
  31. data/whenever-1.1.2/lib/whenever/job_list.rb +186 -0
  32. data/whenever-1.1.2/lib/whenever/numeric.rb +13 -0
  33. data/whenever-1.1.2/lib/whenever/numeric_seconds.rb +48 -0
  34. data/whenever-1.1.2/lib/whenever/os.rb +7 -0
  35. data/whenever-1.1.2/lib/whenever/output_redirection.rb +57 -0
  36. data/whenever-1.1.2/lib/whenever/setup.rb +31 -0
  37. data/whenever-1.1.2/lib/whenever/version.rb +3 -0
  38. data/whenever-1.1.2/lib/whenever.rb +42 -0
  39. data/whenever-1.1.2/test/functional/command_line_test.rb +458 -0
  40. data/whenever-1.1.2/test/functional/output_at_test.rb +246 -0
  41. data/whenever-1.1.2/test/functional/output_default_defined_jobs_test.rb +310 -0
  42. data/whenever-1.1.2/test/functional/output_defined_job_test.rb +113 -0
  43. data/whenever-1.1.2/test/functional/output_description_test.rb +25 -0
  44. data/whenever-1.1.2/test/functional/output_env_test.rb +29 -0
  45. data/whenever-1.1.2/test/functional/output_jobs_for_roles_test.rb +65 -0
  46. data/whenever-1.1.2/test/functional/output_jobs_with_mailto_test.rb +168 -0
  47. data/whenever-1.1.2/test/functional/output_redirection_test.rb +248 -0
  48. data/whenever-1.1.2/test/test_case.rb +32 -0
  49. data/whenever-1.1.2/test/test_helper.rb +51 -0
  50. data/whenever-1.1.2/test/unit/capistrano_support_test.rb +147 -0
  51. data/whenever-1.1.2/test/unit/cron_test.rb +418 -0
  52. data/whenever-1.1.2/test/unit/executable_test.rb +142 -0
  53. data/whenever-1.1.2/test/unit/job_test.rb +114 -0
  54. data/whenever-1.1.2/whenever.gemspec +29 -0
  55. metadata +94 -0
@@ -0,0 +1,310 @@
1
+ require 'test_helper'
2
+
3
+ class OutputDefaultDefinedJobsTest < Whenever::TestCase
4
+
5
+ # command
6
+
7
+ test "A plain command with the job template set to nil" do
8
+ output = Whenever.cron \
9
+ <<-file
10
+ set :job_template, nil
11
+ every 2.hours do
12
+ command "blahblah"
13
+ end
14
+ file
15
+
16
+ assert_match(/^.+ .+ .+ .+ blahblah$/, output)
17
+ end
18
+
19
+ test "A plain command with no job template set" do
20
+ output = Whenever.cron \
21
+ <<-file
22
+ every 2.hours do
23
+ command "blahblah"
24
+ end
25
+ file
26
+
27
+ assert_match(/^.+ .+ .+ .+ \/bin\/bash -l -c 'blahblah'$/, output)
28
+ end
29
+
30
+ test "A plain command with a job_template using a normal parameter" do
31
+ output = Whenever.cron \
32
+ <<-file
33
+ set :job_template, "/bin/bash -l -c 'cd :path && :job'"
34
+ every 2.hours do
35
+ set :path, "/tmp"
36
+ command "blahblah"
37
+ end
38
+ file
39
+
40
+ assert_match(/^.+ .+ .+ .+ \/bin\/bash -l -c 'cd \/tmp \&\& blahblah'$/, output)
41
+ end
42
+
43
+ test "A plain command that overrides the job_template set" do
44
+ output = Whenever.cron \
45
+ <<-file
46
+ set :job_template, "/bin/bash -l -c ':job'"
47
+ every 2.hours do
48
+ command "blahblah", :job_template => "/bin/sh -l -c ':job'"
49
+ end
50
+ file
51
+
52
+
53
+ assert_match(/^.+ .+ .+ .+ \/bin\/sh -l -c 'blahblah'$/, output)
54
+ assert_no_match(/bash/, output)
55
+ end
56
+
57
+ test "A plain command that overrides the job_template set using a parameter" do
58
+ output = Whenever.cron \
59
+ <<-file
60
+ set :job_template, "/bin/bash -l -c 'cd :path && :job'"
61
+ every 2.hours do
62
+ set :path, "/tmp"
63
+ command "blahblah", :job_template => "/bin/sh -l -c 'cd :path && :job'"
64
+ end
65
+ file
66
+
67
+
68
+ assert_match(/^.+ .+ .+ .+ \/bin\/sh -l -c 'cd \/tmp && blahblah'$/, output)
69
+ assert_no_match(/bash/, output)
70
+ end
71
+
72
+ test "A plain command that is conditional on default environent and path" do
73
+ Whenever.expects(:path).at_least_once.returns('/what/you/want')
74
+ output = Whenever.cron \
75
+ <<-file
76
+ set :job_template, nil
77
+ if environment == 'production' && path == '/what/you/want'
78
+ every 2.hours do
79
+ command "blahblah"
80
+ end
81
+ end
82
+ file
83
+
84
+ assert_match(/blahblah/, output)
85
+ end
86
+
87
+ # runner
88
+
89
+ test "A runner with path set" do
90
+ output = Whenever.cron \
91
+ <<-file
92
+ set :job_template, nil
93
+ set :path, '/my/path'
94
+ every 2.hours do
95
+ runner 'blahblah'
96
+ end
97
+ file
98
+
99
+ assert_match two_hours + %( cd /my/path && bundle exec script/runner -e production 'blahblah'), output
100
+ end
101
+
102
+ test "A runner that overrides the path set" do
103
+ output = Whenever.cron \
104
+ <<-file
105
+ set :job_template, nil
106
+ set :path, '/my/path'
107
+ every 2.hours do
108
+ runner "blahblah", :path => '/some/other/path'
109
+ end
110
+ file
111
+
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
127
+ end
128
+
129
+ test "A runner for an app with bin/rails" do
130
+ Whenever.expects(:path).at_least_once.returns('/my/path')
131
+ Whenever.expects(:bin_rails?).returns(true)
132
+ output = Whenever.cron \
133
+ <<-file
134
+ set :job_template, nil
135
+ every 2.hours do
136
+ runner 'blahblah'
137
+ end
138
+ file
139
+
140
+ assert_match two_hours + %( cd /my/path && bin/rails runner -e production 'blahblah'), output
141
+ end
142
+
143
+ test "A runner for an app with script/rails" do
144
+ Whenever.expects(:path).at_least_once.returns('/my/path')
145
+ Whenever.expects(:script_rails?).returns(true)
146
+ output = Whenever.cron \
147
+ <<-file
148
+ set :job_template, nil
149
+ every 2.hours do
150
+ runner 'blahblah'
151
+ end
152
+ file
153
+
154
+ assert_match two_hours + %( cd /my/path && script/rails runner -e production 'blahblah'), output
155
+ end
156
+
157
+ # rake
158
+
159
+ test "A rake command with path set" do
160
+ output = Whenever.cron \
161
+ <<-file
162
+ set :job_template, nil
163
+ set :path, '/my/path'
164
+ every 2.hours do
165
+ rake "blahblah"
166
+ end
167
+ file
168
+
169
+ assert_match two_hours + ' cd /my/path && RAILS_ENV=production bundle exec rake blahblah --silent', output
170
+ end
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
+
185
+ test "A rake for a non-bundler app" do
186
+ Whenever.expects(:path).at_least_once.returns('/my/path')
187
+ Whenever.expects(:bundler?).returns(false)
188
+ output = Whenever.cron \
189
+ <<-file
190
+ set :job_template, nil
191
+ every 2.hours do
192
+ rake 'blahblah'
193
+ end
194
+ file
195
+
196
+ assert_match two_hours + ' cd /my/path && RAILS_ENV=production rake blahblah --silent', output
197
+ end
198
+
199
+ test "A rake command that overrides the path set" do
200
+ output = Whenever.cron \
201
+ <<-file
202
+ set :job_template, nil
203
+ set :path, '/my/path'
204
+ every 2.hours do
205
+ rake "blahblah", :path => '/some/other/path'
206
+ end
207
+ file
208
+
209
+ assert_match two_hours + ' cd /some/other/path && RAILS_ENV=production bundle exec rake blahblah --silent', output
210
+ end
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
+
226
+ test "A rake command that sets the environment variable" do
227
+ output = Whenever.cron \
228
+ <<-file
229
+ set :job_template, nil
230
+ set :path, '/my/path'
231
+ set :environment_variable, 'RAKE_ENV'
232
+ every 2.hours do
233
+ rake "blahblah"
234
+ end
235
+ file
236
+
237
+ assert_match two_hours + ' cd /my/path && RAKE_ENV=production bundle exec rake blahblah --silent', output
238
+ end
239
+
240
+ test "A rake command that overrides the environment variable" do
241
+ output = Whenever.cron \
242
+ <<-file
243
+ set :job_template, nil
244
+ set :path, '/my/path'
245
+ set :environment_variable, 'RAKE_ENV'
246
+ every 2.hours do
247
+ rake "blahblah", :environment_variable => 'SOME_ENV'
248
+ end
249
+ file
250
+
251
+ assert_match two_hours + ' cd /my/path && SOME_ENV=production bundle exec rake blahblah --silent', output
252
+ end
253
+
254
+ # script
255
+
256
+ test "A script command with path set" do
257
+ output = Whenever.cron \
258
+ <<-file
259
+ set :job_template, nil
260
+ set :path, '/my/path'
261
+ every 2.hours do
262
+ script "blahblah"
263
+ end
264
+ file
265
+
266
+ assert_match two_hours + ' cd /my/path && RAILS_ENV=production bundle exec script/blahblah', output
267
+ end
268
+
269
+ test "A script command for a non-bundler app" do
270
+ Whenever.expects(:path).at_least_once.returns('/my/path')
271
+ Whenever.expects(:bundler?).returns(false)
272
+ output = Whenever.cron \
273
+ <<-file
274
+ set :job_template, nil
275
+ every 2.hours do
276
+ script 'blahblah'
277
+ end
278
+ file
279
+
280
+ assert_match two_hours + ' cd /my/path && RAILS_ENV=production script/blahblah', output
281
+ end
282
+
283
+ test "A script command that uses output" do
284
+ output = Whenever.cron \
285
+ <<-file
286
+ set :job_template, nil
287
+ set :output, '/log/file'
288
+ set :path, '/my/path'
289
+ every 2.hours do
290
+ script "blahblah", :path => '/some/other/path'
291
+ end
292
+ file
293
+
294
+ assert_match two_hours + ' cd /some/other/path && RAILS_ENV=production bundle exec script/blahblah >> /log/file 2>&1', output
295
+ end
296
+
297
+ test "A script command that uses an environment variable" do
298
+ output = Whenever.cron \
299
+ <<-file
300
+ set :job_template, nil
301
+ set :environment_variable, 'RAKE_ENV'
302
+ set :path, '/my/path'
303
+ every 2.hours do
304
+ script "blahblah"
305
+ end
306
+ file
307
+
308
+ assert_match two_hours + ' cd /my/path && RAKE_ENV=production bundle exec script/blahblah', output
309
+ end
310
+ end
@@ -0,0 +1,113 @@
1
+ require 'test_helper'
2
+
3
+ class OutputDefinedJobTest < Whenever::TestCase
4
+ test "defined job with a :task" do
5
+ output = Whenever.cron \
6
+ <<-file
7
+ set :job_template, nil
8
+ job_type :some_job, "before :task after"
9
+ every 2.hours do
10
+ some_job "during"
11
+ end
12
+ file
13
+
14
+ assert_match(/^.+ .+ .+ .+ before during after$/, output)
15
+ end
16
+
17
+ test "defined job with a :task and some options" do
18
+ output = Whenever.cron \
19
+ <<-file
20
+ set :job_template, nil
21
+ job_type :some_job, "before :task after :option1 :option2"
22
+ every 2.hours do
23
+ some_job "during", :option1 => 'happy', :option2 => 'birthday'
24
+ end
25
+ file
26
+
27
+ assert_match(/^.+ .+ .+ .+ before during after happy birthday$/, output)
28
+ end
29
+
30
+ test "defined job with a :task and an option where the option is set globally" do
31
+ output = Whenever.cron \
32
+ <<-file
33
+ set :job_template, nil
34
+ job_type :some_job, "before :task after :option1"
35
+ set :option1, 'happy'
36
+ every 2.hours do
37
+ some_job "during"
38
+ end
39
+ file
40
+
41
+ assert_match(/^.+ .+ .+ .+ before during after happy$/, output)
42
+ end
43
+
44
+ test "defined job with a :task and an option where the option is set globally and locally" do
45
+ output = Whenever.cron \
46
+ <<-file
47
+ set :job_template, nil
48
+ job_type :some_job, "before :task after :option1"
49
+ set :option1, 'global'
50
+ every 2.hours do
51
+ some_job "during", :option1 => 'local'
52
+ end
53
+ file
54
+
55
+ assert_match(/^.+ .+ .+ .+ before during after local$/, output)
56
+ end
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
+
86
+ test "defined job with a :task and an option that is not set" do
87
+ output = Whenever.cron \
88
+ <<-file
89
+ set :job_template, nil
90
+ job_type :some_job, "before :task after :option1"
91
+ every 2.hours do
92
+ some_job "during", :option2 => 'happy'
93
+ end
94
+ file
95
+
96
+ assert_match(/^.+ .+ .+ .+ before during after :option1$/, output)
97
+ end
98
+
99
+ test "defined job that uses a :path where none is explicitly set" do
100
+ Whenever.stubs(:path).returns('/my/path')
101
+
102
+ output = Whenever.cron \
103
+ <<-file
104
+ set :job_template, nil
105
+ job_type :some_job, "cd :path && :task"
106
+ every 2.hours do
107
+ some_job 'blahblah'
108
+ end
109
+ file
110
+
111
+ assert_match two_hours + %( cd /my/path && blahblah), output
112
+ end
113
+ end
@@ -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
@@ -0,0 +1,29 @@
1
+ require 'test_helper'
2
+
3
+ class OutputEnvTest < Whenever::TestCase
4
+ setup do
5
+ @output = Whenever.cron \
6
+ <<-file
7
+ env :MYVAR, 'blah'
8
+ env 'MAILTO', "someone@example.com"
9
+ env :BLANKVAR, ''
10
+ env :NILVAR, nil
11
+ file
12
+ end
13
+
14
+ should "output MYVAR environment variable" do
15
+ assert_match "MYVAR=blah", @output
16
+ end
17
+
18
+ should "output MAILTO environment variable" do
19
+ assert_match "MAILTO=someone@example.com", @output
20
+ end
21
+
22
+ should "output BLANKVAR environment variable" do
23
+ assert_match "BLANKVAR=\"\"", @output
24
+ end
25
+
26
+ should "output NILVAR environment variable" do
27
+ assert_match "NILVAR=\"\"", @output
28
+ end
29
+ end
@@ -0,0 +1,65 @@
1
+ require 'test_helper'
2
+
3
+ class OutputJobsForRolesTest < Whenever::TestCase
4
+ test "one role requested and specified on the job" do
5
+ output = Whenever.cron :roles => [:role1], :string => \
6
+ <<-file
7
+ every 2.hours, :roles => [:role1] do
8
+ command "blahblah"
9
+ end
10
+ file
11
+
12
+ assert_equal two_hours + " /bin/bash -l -c 'blahblah'\n\n", output
13
+ end
14
+
15
+ test "one role requested but none specified on the job" do
16
+ output = Whenever.cron :roles => [:role1], :string => \
17
+ <<-file
18
+ every 2.hours do
19
+ command "blahblah"
20
+ end
21
+ file
22
+
23
+ # this should output the job because not specifying a role means "all roles"
24
+ assert_equal two_hours + " /bin/bash -l -c 'blahblah'\n\n", output
25
+ end
26
+
27
+ test "no roles requested but one specified on the job" do
28
+ output = Whenever.cron \
29
+ <<-file
30
+ every 2.hours, :roles => [:role1] do
31
+ command "blahblah"
32
+ end
33
+ file
34
+
35
+ # this should output the job because not requesting roles means "all roles"
36
+ assert_equal two_hours + " /bin/bash -l -c 'blahblah'\n\n", output
37
+ end
38
+
39
+ test "a different role requested than the one specified on the job" do
40
+ output = Whenever.cron :roles => [:role1], :string => \
41
+ <<-file
42
+ every 2.hours, :roles => [:role2] do
43
+ command "blahblah"
44
+ end
45
+ file
46
+
47
+ assert_equal "", output
48
+ end
49
+
50
+ test "with 2 roles requested and a job defined for each" do
51
+ output = Whenever.cron :roles => [:role1, :role2], :string => \
52
+ <<-file
53
+ every 2.hours, :roles => [:role1] do
54
+ command "role1_cmd"
55
+ end
56
+
57
+ every :hour, :roles => [:role2] do
58
+ command "role2_cmd"
59
+ end
60
+ file
61
+
62
+ assert_match two_hours + " /bin/bash -l -c 'role1_cmd'", output
63
+ assert_match "0 * * * * /bin/bash -l -c 'role2_cmd'", output
64
+ end
65
+ end