ruby-clock 2.0.0.beta6 → 2.0.0.beta7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -6
- data/README.md +3 -3
- data/example-app/Clockfile +17 -1
- data/example-app/Gemfile +0 -1
- data/lib/ruby-clock/shell.rb +4 -6
- data/lib/ruby-clock/version.rb +1 -1
- data/lib/rufus_monkeypatch.rb +8 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a64343fae81372c459f3ea52c8358f2b9425c16fdb354ba29eeff18cc836927
|
4
|
+
data.tar.gz: cd17b15fcc7dcbdccc6e83dedab43316036a1b2a3a3cc143add9d7523586f4d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e07fe25a8ee147c0dfca4fb90904b5a2c4a79d4c0e59953a616466080a626d95a457a8efd1844e92bed7a130fd0ad15480beb4be9155ab3d7a3f903decf5024
|
7
|
+
data.tar.gz: d8d40783de5f21398e1170f6bbfd9212fae1ba90a879aaec68002d433a9499455f6e506c968e8e040cce81f99e74991bba8c35a29e6ff94dd34b3dcd763f3c5d
|
data/CHANGELOG.md
CHANGED
@@ -6,10 +6,16 @@
|
|
6
6
|
* RUBY_CLOCK_SHUTDOWN_WAIT_SECONDS value is logged when starting
|
7
7
|
* DSL methods are now at the top-level namespace (`schedule.every` → `every`, `schedule.cron` → `cron`)
|
8
8
|
* Error handler definition is now at the top-level namespace (`def schedule.on_error` → `on_error do`)
|
9
|
-
* Around callbacks now have a top-level namespace method. `def schedule.around_trigger` → `around_action`
|
10
|
-
* Multiple around callbacks can be consecutively assigned - no need to put all behavior into one
|
11
|
-
* Errors encountered when loading Clockfile (such as incorrect cron
|
9
|
+
* Around callbacks now have a top-level namespace method. `def schedule.around_trigger` → `around_action do`
|
10
|
+
* Multiple around callbacks can be consecutively assigned - no need to put all behavior into one method
|
11
|
+
* Errors encountered when loading Clockfile (such as incorrect cron syntax)
|
12
12
|
will be reported to the error handler
|
13
|
+
* The automatic identifier generator will now ignore `}` and `end` lines
|
14
|
+
* posix-spawn is no longer used. In ruby 3, native `Process.spawn` is more performant. See
|
15
|
+
[posix-spawn#90](https://github.com/rtomayko/posix-spawn/issues/90)
|
16
|
+
and
|
17
|
+
[terrapin#19](https://github.com/thoughtbot/terrapin/pull/19)
|
18
|
+
for more info.
|
13
19
|
|
14
20
|
### Anti-Features
|
15
21
|
* ruby 3.0 is now the minimum version
|
@@ -26,11 +32,9 @@
|
|
26
32
|
* The top of every Clockfile must begin with `using RubyClock::DSL`
|
27
33
|
* If you have an existing `def schedule.around_trigger`, you will need to change it to use the new
|
28
34
|
`around_action` method.
|
29
|
-
* Your existing Clockfile will still work, but you now have the option to use
|
35
|
+
* Your existing Clockfile with `schedule.foo` invocations will still work, but you now have the option to use
|
30
36
|
`every`, `cron`, and `on_error` at the top-level, without referencing `schedule`.
|
31
|
-
See the readme for examples.
|
32
37
|
* You now have the option of catching and reporting errors encountered when parsing the Clockfile.
|
33
|
-
See the readme.
|
34
38
|
* There is no longer a need to have a binstub in rails. You can delete bin/clock from your app.
|
35
39
|
* The invocations (in Procfile, or wherever else you start ruby-clock) should change from
|
36
40
|
|
data/README.md
CHANGED
@@ -28,7 +28,7 @@ You can change this number with `RUBY_CLOCK_SHUTDOWN_WAIT_SECONDS` in the enviro
|
|
28
28
|
|
29
29
|
## Installation
|
30
30
|
|
31
|
-
ruby >=
|
31
|
+
ruby >= 3.0 is required.
|
32
32
|
|
33
33
|
Add these lines to your application's Gemfile:
|
34
34
|
|
@@ -239,7 +239,7 @@ end
|
|
239
239
|
By default they will be run with
|
240
240
|
[ruby backticks](https://livebook.manning.com/concept/ruby/backtick).
|
241
241
|
For better performance, install the [terrapin](https://github.com/thoughtbot/terrapin)
|
242
|
-
|
242
|
+
gem.
|
243
243
|
|
244
244
|
`shell` is a convenience method which just passes the string on.
|
245
245
|
If you want to use other terrapin features, you can skip the `shell` command
|
@@ -283,7 +283,7 @@ end
|
|
283
283
|
```
|
284
284
|
|
285
285
|
There are also `rake_execute` and `rake_async`.
|
286
|
-
See [the code](https://github.com/jjb/ruby-clock/blob/main/lib/rake.rb)
|
286
|
+
See [the code](https://github.com/jjb/ruby-clock/blob/main/lib/ruby-clock/rake.rb)
|
287
287
|
and [this article](https://code.jjb.cc/running-rake-tasks-from-within-ruby-on-rails-code) for more info.
|
288
288
|
|
289
289
|
### Job Identifier
|
data/example-app/Clockfile
CHANGED
@@ -14,7 +14,7 @@ end
|
|
14
14
|
# end
|
15
15
|
|
16
16
|
around_action do |job_proc, job_info|
|
17
|
-
puts "before1 #{job_info.class}"
|
17
|
+
puts "before1 #{job_info.class} #{job_info.identifier}"
|
18
18
|
job_proc.call
|
19
19
|
puts "after1"
|
20
20
|
end
|
@@ -60,3 +60,19 @@ end
|
|
60
60
|
# def schedule.around_trigger(job_info, &job_proc)
|
61
61
|
# puts "ruby-clock 1-style around trigger!"
|
62
62
|
# end
|
63
|
+
|
64
|
+
every('2 seconds', blocking: true) do
|
65
|
+
begin
|
66
|
+
|
67
|
+
1.times {
|
68
|
+
begin
|
69
|
+
puts "hello from a stress test for the autonamer"
|
70
|
+
end
|
71
|
+
|
72
|
+
}
|
73
|
+
# this is a comment!
|
74
|
+
|
75
|
+
end
|
76
|
+
# another comment
|
77
|
+
|
78
|
+
end
|
data/example-app/Gemfile
CHANGED
data/lib/ruby-clock/shell.rb
CHANGED
@@ -2,13 +2,11 @@ module RubyClock::Shell
|
|
2
2
|
def shell_runner
|
3
3
|
@shell_runner ||= begin
|
4
4
|
require 'terrapin'
|
5
|
-
|
6
|
-
|
7
|
-
unless Terrapin::CommandLine.runner.class == Terrapin::CommandLine::PosixRunner
|
5
|
+
unless Terrapin::CommandLine.runner.class == Terrapin::CommandLine::ProcessRunner
|
8
6
|
puts <<~MESSAGE
|
9
7
|
|
10
|
-
🤷 terrapin
|
11
|
-
|
8
|
+
🤷 terrapin is installed, but for some reason terrapin is
|
9
|
+
using backticks as its runner.
|
12
10
|
|
13
11
|
MESSAGE
|
14
12
|
end
|
@@ -19,7 +17,7 @@ module RubyClock::Shell
|
|
19
17
|
puts <<~MESSAGE
|
20
18
|
|
21
19
|
🦥 Using ruby backticks for shell commands.
|
22
|
-
For better performance, install the terrapin
|
20
|
+
For better performance, install the terrapin gem.
|
23
21
|
See README.md for more info.
|
24
22
|
|
25
23
|
MESSAGE
|
data/lib/ruby-clock/version.rb
CHANGED
data/lib/rufus_monkeypatch.rb
CHANGED
@@ -1,8 +1,15 @@
|
|
1
1
|
require 'method_source'
|
2
2
|
class Rufus::Scheduler::Job
|
3
|
+
UNDESIRED_ELEMENTS = ['', '}', 'end']
|
3
4
|
def identifier
|
4
5
|
@identifier ||= begin
|
5
|
-
name
|
6
|
+
return name if name
|
7
|
+
|
8
|
+
lines = handler.source.split("\n")
|
9
|
+
whitespace_removed = lines.map(&:strip)
|
10
|
+
undesired_removed = whitespace_removed - UNDESIRED_ELEMENTS
|
11
|
+
comment_only_lines_removed = undesired_removed.grep_v(/#.*/)
|
12
|
+
comment_only_lines_removed[-1] # final line
|
6
13
|
rescue
|
7
14
|
begin
|
8
15
|
source_location.join('-')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-clock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.beta7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Bachir
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rufus-scheduler
|
@@ -276,7 +276,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
276
276
|
- !ruby/object:Gem::Version
|
277
277
|
version: 1.3.1
|
278
278
|
requirements: []
|
279
|
-
rubygems_version: 3.
|
279
|
+
rubygems_version: 3.3.7
|
280
280
|
signing_key:
|
281
281
|
specification_version: 4
|
282
282
|
summary: A job scheduler which runs jobs each in their own thread in a persistent
|