gregfitz23-chrono_trigger 0.1.0 → 0.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.
- data/README.rdoc +11 -10
- data/VERSION.yml +1 -1
- data/lib/chrono_trigger/process.rb +2 -1
- data/lib/chrono_trigger/runner.rb +2 -2
- data/lib/chrono_trigger/trigger.rb +6 -1
- data/lib/triggers/test_triggers.rb +6 -1
- data/test/test_helper.rb +9 -1
- data/test/test_trigger.rb +12 -0
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -10,18 +10,19 @@ A cron framework for defining cron tasks using a readable DSL.
|
|
10
10
|
|
11
11
|
== SYNOPSIS:
|
12
12
|
|
13
|
-
Create trigger files
|
13
|
+
Create trigger files directory.
|
14
14
|
Triggers should follow the pattern:
|
15
15
|
|
16
|
-
do
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
16
|
+
trigger "name" do
|
17
|
+
runs { code to execute }
|
18
|
+
on :monday
|
19
|
+
every :minutes=>10
|
20
|
+
at :hour=>9, :minute=>[30,50]
|
21
|
+
end
|
22
|
+
Run `chrono_trigger -t{full path to trigger file}`.
|
23
|
+
Other available options are:
|
24
|
+
* -a - Specify an application context for the triggers to run against.
|
25
|
+
* -e - Specify the environment the triggers should run against
|
25
26
|
|
26
27
|
== REQUIREMENTS:
|
27
28
|
|
data/VERSION.yml
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require "chrono_trigger"
|
1
2
|
module ChronoTrigger
|
2
3
|
|
3
4
|
class Process
|
@@ -7,7 +8,7 @@ module ChronoTrigger
|
|
7
8
|
setup(options)
|
8
9
|
|
9
10
|
shell = ChronoTrigger::Shell.new
|
10
|
-
shell.load_triggers(options[:
|
11
|
+
shell.load_triggers(options[:trigger_files].split(":"))
|
11
12
|
loop do
|
12
13
|
shell.execute_triggers
|
13
14
|
sleep 1.minute.to_i
|
@@ -64,8 +64,8 @@ module ChronoTrigger
|
|
64
64
|
opts.separator ""
|
65
65
|
opts.separator ""; opts.separator "ChronoTrigger Options:"
|
66
66
|
|
67
|
-
opts.on("-
|
68
|
-
options[:
|
67
|
+
opts.on("-tTRIGGER_FILES", "--triggers TRIGGER_FILES", "Path to file(s) specifying triggers to be executed. Multiple files should be separated by a :. When also specifying -a, this path will be relative to the application path") do |trigger_files|
|
68
|
+
options[:trigger_files] = trigger_files
|
69
69
|
end
|
70
70
|
|
71
71
|
opts.on("-f", "--force", "Force restart of ChronoTrigger process (can be used in conjunction with -P).") do
|
@@ -1,8 +1,13 @@
|
|
1
1
|
trigger "trigger1" do
|
2
|
-
runs { puts "trigger 1 runs every 1 minutes; executed at #{Time.now}"}
|
2
|
+
runs { puts "trigger 1 runs every 1 minutes; executed at #{Time.now}" }
|
3
3
|
every :minutes=>1
|
4
4
|
end
|
5
5
|
|
6
|
+
trigger "exception trigger" do
|
7
|
+
runs { raise Exception.new("test exception")}
|
8
|
+
every :minutes=>2
|
9
|
+
end
|
10
|
+
|
6
11
|
trigger "trigger2" do
|
7
12
|
runs { puts "trigger 2 runs every 5 minutes; executed at #{Time.now}"}
|
8
13
|
every :minutes=>5
|
data/test/test_helper.rb
CHANGED
@@ -2,4 +2,12 @@ require 'stringio'
|
|
2
2
|
require 'test/unit'
|
3
3
|
require File.dirname(__FILE__) + '/../lib/chrono_trigger'
|
4
4
|
require "shoulda"
|
5
|
-
require "mocha"
|
5
|
+
require "mocha"
|
6
|
+
|
7
|
+
|
8
|
+
def quietly
|
9
|
+
old_stderr = $stderr
|
10
|
+
STDERR.reopen("/dev/null", 'w')
|
11
|
+
yield
|
12
|
+
$stderr = old_stderr
|
13
|
+
end
|
data/test/test_trigger.rb
CHANGED
@@ -18,6 +18,18 @@ class TestTrigger < Test::Unit::TestCase
|
|
18
18
|
should "execute @block_to_run on call to execute" do
|
19
19
|
assert_equal @block_to_run, @trigger.execute
|
20
20
|
end
|
21
|
+
|
22
|
+
context "that raises an exception" do
|
23
|
+
setup do
|
24
|
+
@trigger.runs { raise Exception.new("test error")}
|
25
|
+
end
|
26
|
+
|
27
|
+
should "be caught and logged by the trigger" do
|
28
|
+
assert_nothing_raised do
|
29
|
+
quietly { @trigger.execute }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end #that raises an exception
|
21
33
|
end #and a block of code to run
|
22
34
|
|
23
35
|
context "and a call to #on with some days" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gregfitz23-chrono_trigger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Fitzgerald
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-04-
|
12
|
+
date: 2009-04-17 00:00:00 -07:00
|
13
13
|
default_executable: chrono_trigger
|
14
14
|
dependencies: []
|
15
15
|
|