dynarex_cron 0.9.2 → 0.9.5

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
- SHA1:
3
- metadata.gz: 7d6d831aa410f982a4d6e362fc3054e93b897198
4
- data.tar.gz: 2b9761c099406b8e3433f30e188d0ae72b2b8cc9
2
+ SHA256:
3
+ metadata.gz: b3a65ddcd1590f382710f6f67cb50ac1143fed13c8af76dde93c76fce3a99e24
4
+ data.tar.gz: f2c111a396fc622e35cdbcd18007dc03df688a705813be5e25338bc6e55655d3
5
5
  SHA512:
6
- metadata.gz: c0880d7fcb65d010950510a5561306df1ea96ab96cb809d996b82e53df0d6a72a288ade8496ea3c9ee2935fd3e63e40daf1ec1227c24ea2866408a11a89d13b0
7
- data.tar.gz: 94e202eec354151472036d76aa5a0790221514ea2a84d71119c2eb9a5f1bbb144fcf54f0ef08951964e7360bf44e3d9c64fb3bf43341e8bd0a85fcd47abad666
6
+ metadata.gz: e782e76c62832d6cb67d090e1c074e368d1f5ffde353b53f20a7d7f4f14a029d0f287cb2da7a4b916da9a4f517eba1d616a9f05a4b95698e70b60dc8e9751a4b
7
+ data.tar.gz: cfece8f878d52864670ef0751b8ca6b3f1eeab8b256c63f243bf1497e073b76f7720ff21c2bcb14c6c42ef1852e610ff0e3d38fc88409b8405dbfc35cc545bba
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/dynarex_cron.rb CHANGED
@@ -5,47 +5,49 @@
5
5
  require 'dynarex'
6
6
  require 'chronic_cron'
7
7
  require 'sps-pub'
8
+ require 'rxfreader'
8
9
 
9
10
 
10
11
  DF = "%Y-%m-%d %H:%M"
11
12
 
12
13
  class DynarexCron
14
+ using ColouredText
13
15
 
14
16
  # options: e.g. sps_address: 'sps', sps_port: '59000'
15
17
  #
16
18
  def initialize(dxfile=nil, sps_address: 'sps', sps_port: '59000', \
17
- log: nil, time_offset: 0, logtopic: 'DynarexCron')
18
-
19
+ log: nil, time_offset: 0, logtopic: 'DynarexCron', debug: false)
20
+
19
21
 
20
22
  @dxfile, @sps_address, @sps_port, @log = dxfile, sps_address, sps_port, log
21
23
 
22
- # time_offset: used for testing a cron entry without having to change
24
+ # time_offset: used for testing a cron entry without having to change
23
25
  # the time of each entry
24
26
  @time_offset = time_offset.to_i
25
-
27
+
26
28
  @cron_entries = []
27
29
  @logtopic = logtopic
28
-
30
+
29
31
 
30
32
  if @dxfile then
31
33
 
32
34
  dynarex,_ = load_doc dxfile
33
35
  load_entries(dynarex)
34
- end
36
+ end
35
37
 
36
38
  @pub = SPSPub.new address: sps_address, port: sps_port
37
-
39
+
38
40
  end
39
41
 
40
42
  def start
41
43
 
42
44
  @running = true
43
-
45
+
44
46
  if @log then
45
47
  @log.info @logtopic + '/start: Time.now: ' \
46
48
  + (Time.now + @time_offset).strftime(DF)
47
49
  end
48
-
50
+
49
51
 
50
52
  sleep 1 until Time.now.sec == 0
51
53
 
@@ -56,17 +58,17 @@ class DynarexCron
56
58
 
57
59
  if @dxfile.is_a? String then
58
60
 
59
- # What happens if the @dxfile is a URL and the web server is
61
+ # What happens if the @dxfile is a URL and the web server is
60
62
  # temporarily unavailable? i.e. 503 Service Temporarily Unavailable
61
63
  begin
62
64
 
63
65
  dx, buffer = load_doc(@dxfile)
64
- load_entries dx if @buffer != buffer
66
+ load_entries dx if @buffer != buffer
65
67
  @buffer = buffer
66
-
68
+
67
69
  rescue
68
- @log.debug @logtopic + '/start: warning: ' + ($!).inspect
69
- end
70
+ @log.debug @logtopic + '/start: warning: ' + ($!).inspect if @log
71
+ end
70
72
 
71
73
  end
72
74
 
@@ -76,11 +78,11 @@ class DynarexCron
76
78
  end
77
79
 
78
80
  end
79
-
81
+
80
82
  def stop()
81
83
  @running = false
82
84
  end
83
-
85
+
84
86
  private
85
87
 
86
88
  def load_doc(dynarex_file)
@@ -88,42 +90,43 @@ class DynarexCron
88
90
  if dynarex_file.is_a?(Dynarex) then
89
91
  dynarex_file
90
92
  else
91
-
92
- buffer, _ = RXFHelper.read(dynarex_file)
93
- dx = buffer =~ /<?dynarex/ ? Dynarex.new.import(buffer) : \
93
+
94
+ buffer, _ = RXFReader.read(dynarex_file)
95
+ dx = buffer =~ /<\?dynarex/ ? Dynarex.new.import(buffer) : \
94
96
  Dynarex.new(buffer)
95
-
97
+
96
98
  [dx, buffer]
97
99
  end
98
-
100
+
99
101
  end
100
102
 
101
103
  def load_entries(dx)
102
-
104
+
103
105
  if dx.summary[:sps_address] then
104
106
  @sps_address, @sps_port = dx.summary[:sps_address]\
105
107
  .split(':',2) << '59000'
106
108
  end
107
-
108
- @cron_entries = dx.to_h
109
- @cron_entries.each do |h|
109
+
110
+ @cron_entries = dx.to_a
111
+ @cron_entries.each do |h|
110
112
  h[:cron] = ChronicCron.new(h[:expression], Time.now + @time_offset)
111
113
  end
112
- end
113
-
114
+ end
115
+
114
116
 
115
117
  def iterate(cron_entries)
116
-
118
+
119
+ puts ('h:' + h.inspect).debug if @debug
117
120
  cron_entries.each do |h|
118
-
121
+
119
122
  datetime = (Time.now + @time_offset).strftime(DF)
120
-
123
+
121
124
  if @log then
122
125
  @log.info @logtopic + '/iterate: datetime: ' + datetime
123
126
  @log.info @logtopic + '/iterate: cron.to_time: ' \
124
127
  + h[:cron].to_time.strftime(DF)
125
128
  end
126
-
129
+
127
130
  if h[:cron].to_time.strftime(DF) == datetime then
128
131
 
129
132
  begin
@@ -131,26 +134,26 @@ class DynarexCron
131
134
  if h[:fqm].empty? and @log then
132
135
  @log.debug @logtopic + '/iterate: no h[:fqw] found ' + h.inspect
133
136
  end
134
-
137
+
135
138
  msg = h[:fqm].gsub('!Time',Time.now.strftime("%H:%M"))
136
139
 
137
140
  @pub.notice msg
138
141
 
139
142
  rescue
140
-
143
+
141
144
  if @log then
142
145
  @log.debug @logtopic + '/iterate: cron: ' + h[:cron].inspect
143
146
  @log.debug @logtopic + '/iterate: h: ' + h.inspect + ' : ' \
144
147
  + ($!).inspect
145
148
  end
146
-
149
+
147
150
  end
148
-
151
+
149
152
  h[:cron].next # advances the time
150
-
153
+
151
154
  end
152
155
 
153
156
  end
154
157
  end
155
158
 
156
- end
159
+ 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.9.2
4
+ version: 0.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -10,28 +10,32 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
- YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
- 8ixkARkWAmV1MB4XDTE2MTIxODEyNTg1MFoXDTE3MTIxODEyNTg1MFowSDESMBAG
16
- A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
- EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
- ggEBAN2Vvyb/QYOsoGhEsfMN27RtbJDiIzBlwitRF5NnJK0aHIIDWuYZQ36kVtlH
19
- pUf7FN+amWMN3RfiqkWSy103UT69WFY1wbLYAGdL9ieuknSZyO66wdBYLHQphD6w
20
- Q86Zm694ssWU4Dcavh9ypoY3r+Wy5PLUcL7YbxpGRvWepgXKkS1DFmXY+5PgxJ63
21
- 0d11cBgiT7wv7k3Osd0eKtqCKIuEfzuvoQn6WXed+LpYWkGcEOpDHjl1thkydecG
22
- DP8qqyFF5hVDlfrkI65t1YLFVOT9mbIQW0gAVG6hRFH9vYesHpkrLLISD+bimitP
23
- RVH8qW3iEg7njDwe8DI7IhEsOZMCAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
24
- DwQEAwIEsDAdBgN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DprLKZAN1CqNd/
36
+ I84GSXqtRpTn4jeExOFOFvme
33
37
  -----END CERTIFICATE-----
34
- date: 2017-12-11 00:00:00.000000000 Z
38
+ date: 2022-02-23 00:00:00.000000000 Z
35
39
  dependencies:
36
40
  - !ruby/object:Gem::Dependency
37
41
  name: chronic_cron
@@ -39,40 +43,40 @@ dependencies:
39
43
  requirements:
40
44
  - - "~>"
41
45
  - !ruby/object:Gem::Version
42
- version: '0.3'
46
+ version: '0.7'
43
47
  - - ">="
44
48
  - !ruby/object:Gem::Version
45
- version: 0.3.7
49
+ version: 0.7.1
46
50
  type: :runtime
47
51
  prerelease: false
48
52
  version_requirements: !ruby/object:Gem::Requirement
49
53
  requirements:
50
54
  - - "~>"
51
55
  - !ruby/object:Gem::Version
52
- version: '0.3'
56
+ version: '0.7'
53
57
  - - ">="
54
58
  - !ruby/object:Gem::Version
55
- version: 0.3.7
59
+ version: 0.7.1
56
60
  - !ruby/object:Gem::Dependency
57
61
  name: dynarex
58
62
  requirement: !ruby/object:Gem::Requirement
59
63
  requirements:
60
64
  - - "~>"
61
65
  - !ruby/object:Gem::Version
62
- version: '1.7'
66
+ version: '1.9'
63
67
  - - ">="
64
68
  - !ruby/object:Gem::Version
65
- version: 1.7.27
69
+ version: 1.9.6
66
70
  type: :runtime
67
71
  prerelease: false
68
72
  version_requirements: !ruby/object:Gem::Requirement
69
73
  requirements:
70
74
  - - "~>"
71
75
  - !ruby/object:Gem::Version
72
- version: '1.7'
76
+ version: '1.9'
73
77
  - - ">="
74
78
  - !ruby/object:Gem::Version
75
- version: 1.7.27
79
+ version: 1.9.6
76
80
  - !ruby/object:Gem::Dependency
77
81
  name: sps-pub
78
82
  requirement: !ruby/object:Gem::Requirement
@@ -94,7 +98,7 @@ dependencies:
94
98
  - !ruby/object:Gem::Version
95
99
  version: 0.5.5
96
100
  description:
97
- email: james@jamesrobertson.eu
101
+ email: digital.robertson@gmail.com
98
102
  executables: []
99
103
  extensions: []
100
104
  extra_rdoc_files: []
@@ -119,8 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
123
  - !ruby/object:Gem::Version
120
124
  version: '0'
121
125
  requirements: []
122
- rubyforge_project:
123
- rubygems_version: 2.6.13
126
+ rubygems_version: 3.2.22
124
127
  signing_key:
125
128
  specification_version: 4
126
129
  summary: Publishes SimplePubSub messages by reading cron entries from a Dynarex document
metadata.gz.sig CHANGED
Binary file