spstrigger_execute 0.5.1 → 0.5.2
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/spstrigger_execute.rb +73 -71
- data.tar.gz.sig +0 -0
- metadata +38 -38
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9e2623d7c28470a080c0db5ae3b4e56bcb022875ef6a17f95a2d20aee88f97e
|
4
|
+
data.tar.gz: 6314c39efb6225437e01a21c6b29111c5b644b8258474a4f91795850960ee13a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 962243ccdd8f1a0e79b9979ee72b319a020931121d98b7bcaa5485915ecc030f3591b4df17dfbd9f5ec077b4cc574949c6890408b36d06e2e0a2940e7d9b4824
|
7
|
+
data.tar.gz: 9af7e7cf7ddca7a312db7e5014b2e85b9face23a1d0564f8ef336d4f0c29d09f70ed47caf4371892fe9106228a46a85a8c7f2b026ce8602077f3569c271393a2
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/spstrigger_execute.rb
CHANGED
@@ -5,49 +5,51 @@
|
|
5
5
|
require 'dynarex'
|
6
6
|
require 'chronic_between'
|
7
7
|
require 'xmlregistry_objects'
|
8
|
+
require 'rxfreader'
|
8
9
|
|
9
10
|
|
10
11
|
class SPSTriggerExecute
|
11
12
|
|
12
13
|
def initialize(x, reg=nil, polyrexdoc=nil, rws=nil, log: nil)
|
13
|
-
|
14
|
+
|
14
15
|
log.info 'SPSTriggerExecute/initialize: active' if log
|
15
|
-
|
16
|
+
|
16
17
|
@rws, @log = rws, log
|
17
|
-
|
18
|
+
|
18
19
|
@patterns = if x.is_a? Dynarex then
|
19
|
-
|
20
|
+
|
20
21
|
x.to_h
|
21
|
-
|
22
|
+
|
22
23
|
elsif x.is_a? Array
|
23
24
|
x
|
24
25
|
else
|
25
|
-
|
26
|
-
buffer, _ =
|
26
|
+
|
27
|
+
buffer, _ = RXFReader.read x
|
27
28
|
dx = buffer[/^<\?dynarex /] ? Dynarex.new.import(buffer) : \
|
28
29
|
Dynarex.new(buffer)
|
29
30
|
dx.to_a
|
30
|
-
|
31
|
-
end
|
32
|
-
|
31
|
+
|
32
|
+
end
|
33
|
+
|
33
34
|
if reg and polyrexdoc then
|
34
|
-
log.info 'SPSTriggerExecute/initialize: before reg' if log
|
35
|
+
log.info 'SPSTriggerExecute/initialize: before reg' if log
|
35
36
|
puts 'reg: ' + reg.inspect
|
36
37
|
xro = XMLRegistryObjects.new(reg, polyrexdoc, log: log)
|
37
|
-
log.info 'SPSTriggerExecute/initialize: after reg' if log
|
38
|
-
@h = xro.to_h
|
39
|
-
define_methods = @h.keys.map {|x| "def #{x}() @h[:#{x}] end"}
|
40
|
-
instance_eval define_methods.join("\n")
|
41
|
-
|
38
|
+
log.info 'SPSTriggerExecute/initialize: after reg' if log
|
39
|
+
@h = xro.to_h
|
40
|
+
define_methods = @h.keys.map {|x| "def #{x}() @h[:#{x}] end"}
|
41
|
+
instance_eval define_methods.join("\n")
|
42
|
+
|
42
43
|
if log then
|
43
|
-
log.info 'SPSTriggerExecute/initialize: define_methods : ' +
|
44
|
+
log.info 'SPSTriggerExecute/initialize: define_methods : ' +
|
44
45
|
self.public_methods.sort.inspect
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
48
49
|
end
|
49
50
|
|
50
|
-
def match_and_execute(
|
51
|
+
def match_and_execute(topicx=nil, messagex=nil, topic: topicx,
|
52
|
+
message: messagex)
|
51
53
|
|
52
54
|
@log.info 'SPSTriggerExecute/match_and_execute: active' if @log
|
53
55
|
results = find_match topic, message
|
@@ -55,31 +57,31 @@ class SPSTriggerExecute
|
|
55
57
|
end
|
56
58
|
|
57
59
|
alias mae match_and_execute
|
58
|
-
|
60
|
+
|
59
61
|
def run(s)
|
60
62
|
instance_eval s
|
61
63
|
end
|
62
|
-
|
64
|
+
|
63
65
|
|
64
66
|
private
|
65
67
|
|
66
68
|
def find_match(topicx=nil, message)
|
67
|
-
|
68
|
-
|
69
|
+
|
70
|
+
|
69
71
|
@patterns.map.with_index.inject([]) do |r, row|
|
70
72
|
|
71
73
|
h, i = row
|
72
74
|
|
73
75
|
topic, msg, conditions, job = \
|
74
76
|
%i(topic msg conditions job).map {|x| h[x].to_s }
|
75
|
-
|
77
|
+
|
76
78
|
index ||= i + 1
|
77
|
-
|
79
|
+
|
78
80
|
# note: the index is only present if there is a duplicate
|
79
81
|
# Dynarex record default key
|
80
82
|
|
81
83
|
t, m = topic.length > 0, msg.length > 0
|
82
|
-
|
84
|
+
|
83
85
|
result = if topicx && t && m then
|
84
86
|
|
85
87
|
r1 = topicx.match(/#{topic}/)
|
@@ -94,98 +96,98 @@ class SPSTriggerExecute
|
|
94
96
|
|
95
97
|
elsif m then
|
96
98
|
|
97
|
-
r2 = message.match(/#{msg}/)
|
99
|
+
r2 = message.match(/#{msg}/)
|
98
100
|
{msg: r2, index: index} if r2
|
99
101
|
else
|
100
102
|
{}
|
101
|
-
end
|
103
|
+
end
|
102
104
|
|
103
105
|
if result and conditions.length > 0 then
|
104
|
-
|
106
|
+
|
105
107
|
if @log then
|
106
|
-
@log.info 'SPSTriggerExecute/find_match: conditions: ' +
|
108
|
+
@log.info 'SPSTriggerExecute/find_match: conditions: ' +
|
107
109
|
conditions.inspect
|
108
110
|
end
|
109
111
|
|
110
112
|
named_match = message.match(/#{msg}/)
|
111
|
-
|
113
|
+
|
112
114
|
variable_assignment = if named_match then
|
113
|
-
|
115
|
+
|
114
116
|
named_match.names.inject('') do |rs, name|
|
115
117
|
|
116
118
|
m = msg =~ /\?<#{name}\>\\d+/ ? 'to_i' : 'to_s'
|
117
|
-
rs << "#{name} = named_match[:#{name}].#{m}\n"
|
119
|
+
rs << "#{name} = named_match[:#{name}].#{m}\n"
|
118
120
|
end
|
119
|
-
|
120
|
-
else ''
|
121
|
+
|
122
|
+
else ''
|
121
123
|
end
|
122
124
|
|
123
125
|
|
124
126
|
success = eval (variable_assignment + conditions)
|
125
127
|
|
126
128
|
if @log then
|
127
|
-
@log.info 'SPSTriggerExecute/find_match: success : ' +
|
129
|
+
@log.info 'SPSTriggerExecute/find_match: success : ' +
|
128
130
|
success.inspect
|
129
131
|
end
|
130
|
-
|
132
|
+
|
131
133
|
result = nil unless success
|
132
134
|
end
|
133
135
|
|
134
136
|
result ? r << result : r
|
135
|
-
|
137
|
+
|
136
138
|
end
|
137
139
|
end
|
138
140
|
|
139
|
-
|
141
|
+
|
140
142
|
# not yet implemented
|
141
|
-
=begin
|
143
|
+
=begin
|
142
144
|
def method_missing(method_name, *args)
|
143
145
|
|
144
146
|
job = args.shift
|
145
147
|
# Rsc object call goes here
|
146
148
|
@log.debug 'package: ' + package.inspect
|
147
149
|
@rws.run_job package=method_name, job, {}, args
|
148
|
-
end
|
149
|
-
=end
|
150
|
-
|
150
|
+
end
|
151
|
+
=end
|
152
|
+
|
151
153
|
def prepare_jobs(results)
|
152
|
-
|
154
|
+
|
153
155
|
@log.info 'SPSTriggerExecute/prepare_jobs: active' if @log
|
154
156
|
|
155
157
|
results.inject([]) do |r,h|
|
156
|
-
|
158
|
+
|
157
159
|
if @log then
|
158
|
-
@log.info 'SPSTriggerExecute/prepare_jobs: inside inject h: ' +
|
159
|
-
h.inspect
|
160
|
+
@log.info 'SPSTriggerExecute/prepare_jobs: inside inject h: ' +
|
161
|
+
h.inspect
|
160
162
|
end
|
161
163
|
|
162
164
|
a = []
|
163
165
|
a += h[:topic].captures if h[:topic] && h[:topic].captures.any?
|
164
166
|
a += h[:msg].captures if h[:msg]
|
165
|
-
|
167
|
+
|
166
168
|
params = {}
|
167
169
|
params.merge!(h[:topic].named_captures) if h[:topic]
|
168
|
-
params.merge!(h[:msg].named_captures) if h[:msg]
|
169
|
-
|
170
|
+
params.merge!(h[:msg].named_captures) if h[:msg]
|
171
|
+
|
170
172
|
jobs = @patterns[h[:index].to_i - 1][:job]
|
171
|
-
|
172
|
-
|
173
|
+
|
174
|
+
|
173
175
|
jobs.split(/\s*;\s*/).each do |job|
|
174
176
|
|
175
177
|
job_args = job.split + a
|
176
|
-
|
178
|
+
|
177
179
|
if job[/^\/\//] then
|
178
180
|
|
179
181
|
r << [:rse, job_args, params]
|
180
182
|
|
181
|
-
|
183
|
+
|
182
184
|
elsif job[/^rse:\/\//]
|
183
|
-
|
184
|
-
r << [:rse_uri, job]
|
185
|
-
|
185
|
+
|
186
|
+
r << [:rse_uri, job]
|
187
|
+
|
186
188
|
elsif job[/^[$\w\/]+:/]
|
187
189
|
|
188
|
-
topic_message = job.gsub(/\$\d/) do |x|
|
190
|
+
topic_message = job.gsub(/\$\d/) do |x|
|
189
191
|
|
190
192
|
i = x[/\d$/].to_i - 1
|
191
193
|
x.sub(/\$\d/, a[i].to_s)
|
@@ -193,33 +195,33 @@ class SPSTriggerExecute
|
|
193
195
|
|
194
196
|
topic_message = topic_message\
|
195
197
|
.gsub(/![Tt]ime/,Time.now.strftime("%a %H:%M%P"))\
|
196
|
-
.gsub(/![Dd]ate/,Time.now.strftime("%d %b"))
|
198
|
+
.gsub(/![Dd]ate/,Time.now.strftime("%d %b"))
|
199
|
+
|
197
200
|
|
198
|
-
|
199
|
-
r << [:sps, topic_message]
|
201
|
+
r << [:sps, topic_message]
|
200
202
|
else
|
201
|
-
|
202
|
-
statement = job.gsub(/\$\d/) do |x|
|
203
|
+
|
204
|
+
statement = job.gsub(/\$\d/) do |x|
|
203
205
|
i = x[/\d$/].to_i - 1
|
204
206
|
x.sub(/\$\d/, a[i].to_s)
|
205
207
|
end
|
206
|
-
|
208
|
+
|
207
209
|
r << [:ste, statement]
|
208
|
-
|
210
|
+
|
209
211
|
end
|
210
212
|
end
|
211
|
-
|
213
|
+
|
212
214
|
@log.info 'SPSTriggerExecute/prepare_jobs: result: ' if @log
|
213
|
-
|
214
|
-
r
|
215
|
-
|
215
|
+
|
216
|
+
r
|
217
|
+
|
216
218
|
end
|
217
219
|
end
|
218
220
|
|
219
221
|
def time()
|
220
222
|
|
221
223
|
t = Time.now
|
222
|
-
|
224
|
+
|
223
225
|
def t.within?(times)
|
224
226
|
ChronicBetween.new(times).within? Time.now
|
225
227
|
end
|
@@ -230,9 +232,9 @@ class SPSTriggerExecute
|
|
230
232
|
|
231
233
|
def t.<(x)
|
232
234
|
x.is_a?(String) ? self < Chronic.parse(x) : super(x)
|
233
|
-
end
|
235
|
+
end
|
234
236
|
|
235
237
|
t
|
236
238
|
end
|
237
|
-
|
239
|
+
|
238
240
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spstrigger_execute
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -11,31 +11,31 @@ cert_chain:
|
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
13
|
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjIwMjIzMTA0NzE1WhcN
|
15
|
+
MjMwMjIzMTA0NzE1WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQC+4XPH
|
17
|
+
9FRtD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akiMxg5a1zgVdMi
|
31
|
+
3qJC24Kepyrrdjw/LNbwQStp+Wi0vn0SLtlGcwEUK+GX9sgnlFM7DACmFLa+Q07v
|
32
|
+
VMMWMT++elvuzJWh8nzyoC61wFHNv7VuFS3JLS628/fvcaJSv/14kCVxXNvXnB+0
|
33
|
+
pXBBvWBPrM0AbZd/BcMhjQOU4gFBwTZYQPNTIYuxY5+qeSklhlHOxxqjLZ80FNIW
|
34
|
+
mwE7uxev8HERyFxkyylLiD9Rn0BbWPdpvxdMR/ERf/KjoRJt+YHtqRcfHlDI7WYd
|
35
|
+
kcanouQmEubFZ26md+j9mhOx9r117kQmXW19FYMG7BO9KiM1WxGVGt02zAF1OLwF
|
36
|
+
yBsqw3zhA/dhp5I6skt1EWsm
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
38
|
+
date: 2022-02-23 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: dynarex
|
@@ -43,62 +43,62 @@ dependencies:
|
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '1.
|
46
|
+
version: '1.9'
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 1.
|
49
|
+
version: 1.9.6
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
54
|
- - "~>"
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: '1.
|
56
|
+
version: '1.9'
|
57
57
|
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: 1.
|
59
|
+
version: 1.9.6
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: chronic_between
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
64
|
- - "~>"
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
version: '0.
|
66
|
+
version: '0.5'
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: 0.
|
69
|
+
version: 0.5.0
|
70
70
|
type: :runtime
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: '0.
|
76
|
+
version: '0.5'
|
77
77
|
- - ">="
|
78
78
|
- !ruby/object:Gem::Version
|
79
|
-
version: 0.
|
79
|
+
version: 0.5.0
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: xmlregistry_objects
|
82
82
|
requirement: !ruby/object:Gem::Requirement
|
83
83
|
requirements:
|
84
84
|
- - "~>"
|
85
85
|
- !ruby/object:Gem::Version
|
86
|
-
version: '0.
|
86
|
+
version: '0.8'
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.
|
89
|
+
version: 0.8.0
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0.
|
96
|
+
version: '0.8'
|
97
97
|
- - ">="
|
98
98
|
- !ruby/object:Gem::Version
|
99
|
-
version: 0.
|
99
|
+
version: 0.8.0
|
100
100
|
description:
|
101
|
-
email:
|
101
|
+
email: digital.robertson@gmail.com
|
102
102
|
executables: []
|
103
103
|
extensions: []
|
104
104
|
extra_rdoc_files: []
|
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
requirements: []
|
126
|
-
rubygems_version: 3.
|
126
|
+
rubygems_version: 3.2.22
|
127
127
|
signing_key:
|
128
128
|
specification_version: 4
|
129
129
|
summary: An SPS client built for reponding to messages which match keywords and conditions.
|
metadata.gz.sig
CHANGED
Binary file
|