dynarex_cron 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4bc6248c6383a0e442b18f9a9dab91e8c9e01001
4
- data.tar.gz: 04abe4552fef512ef4258144067bd1d9f29f717b
3
+ metadata.gz: e980550e95f742108e51c2c96c3c4553da432162
4
+ data.tar.gz: 7af232c9aeb9d3a7110c8f3e63c0614ebb38da5d
5
5
  SHA512:
6
- metadata.gz: 58b9e52e7ca6f5696bd25f88d4bd02d127725fd8073bb280045b998758e10ba53ca629162911238506f8404d0802a3686933baf9e8c6afaa9827a07a41e36622
7
- data.tar.gz: e3aff16a3a6c920066d2c9e7aaf83962865d146aefc900ce41cfc70adc173a331d3f45a23bc0130ee1bfc2a7c797d7d1d3af2472719a1e90a4ec4715a85d9ecb
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
- puts eval job
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.0
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-08 00:00:00.000000000 Z
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