dynarex_cron 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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/dynarex_cron.rb +30 -3
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e980550e95f742108e51c2c96c3c4553da432162
|
4
|
+
data.tar.gz: 7af232c9aeb9d3a7110c8f3e63c0614ebb38da5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c4c84262152476d7c77f4e0af4e7aefd145552bff9f3661b7b120e3854a6b272f8c166a73b6583d6cb13017884715f2d082c58e47d618fd7b822e5726c690b5
|
7
|
+
data.tar.gz: a448969c712427a9b16eba93865fd54f414e40daa64c1ce71e1a01e4eb431bc8e5e67a165dd6b2e2e9ef0a5e219e753caacc39710b7b34e92a8acd5099d744e6
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/dynarex_cron.rb
CHANGED
@@ -5,14 +5,17 @@
|
|
5
5
|
require 'run_every'
|
6
6
|
require 'dynarex'
|
7
7
|
require 'chronic_cron'
|
8
|
+
require 'simplepubsub'
|
9
|
+
require 'rscript'
|
8
10
|
|
9
11
|
TF = "%Y-%m-%d %H:%M"
|
10
12
|
|
11
13
|
class DynarexCron
|
12
14
|
|
13
|
-
def initialize(dynarex_file)
|
15
|
+
def initialize(dynarex_file, sps_address=nil)
|
14
16
|
@dynarex = Dynarex.new dynarex_file
|
15
17
|
@dynarex.to_h.each {|h| h[:cron] = ChronicCron.new(h[:expression]) }
|
18
|
+
@sps_address = sps_address
|
16
19
|
end
|
17
20
|
|
18
21
|
def start
|
@@ -20,7 +23,7 @@ class DynarexCron
|
|
20
23
|
RunEvery.new.minute do
|
21
24
|
@dynarex.to_h.each do |h|
|
22
25
|
if h[:cron].to_time.strftime(TF) == Time.now.strftime(TF) then
|
23
|
-
run(h[:job])
|
26
|
+
Thread.new { run(h[:job]) }
|
24
27
|
h[:cron].next
|
25
28
|
end
|
26
29
|
end
|
@@ -31,7 +34,31 @@ class DynarexCron
|
|
31
34
|
private
|
32
35
|
|
33
36
|
def run(job)
|
34
|
-
|
37
|
+
|
38
|
+
case job
|
39
|
+
|
40
|
+
when /^(run )/
|
41
|
+
code2, args = RScript.new.read ($').scan(/[^'"]+/).map(&:strip)
|
42
|
+
eval code2
|
43
|
+
|
44
|
+
when /^(pub\s*(?:lish)?\s+)/
|
45
|
+
|
46
|
+
return unless @sps_address
|
47
|
+
SimplePubSub::Client.connect(@sps_address) do |client|
|
48
|
+
topic, msg = ($').split(/:\s*/,2)
|
49
|
+
client.publish(topic, msg)
|
50
|
+
end
|
51
|
+
|
52
|
+
when /^`([^`]+)/
|
53
|
+
`#{$1}`
|
54
|
+
|
55
|
+
when %r{http://}
|
56
|
+
open(s, 'UserAgent' => 'DynarexCron v0.1')
|
57
|
+
|
58
|
+
else
|
59
|
+
puts eval(s)
|
60
|
+
end
|
61
|
+
|
35
62
|
end
|
36
63
|
|
37
64
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynarex_cron
|
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
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
y6cNz+NnybgoQfG28NcwV1e/31NTJk5VqdKHKnTfPcp/y35T9YoElNn5cSs93qc5
|
32
32
|
U5VVkvsVQudaZw==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2013-07-
|
34
|
+
date: 2013-07-09 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: dynarex
|
metadata.gz.sig
CHANGED
Binary file
|