spstrigger_execute 0.2.1 → 0.3.0
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.tar.gz.sig +0 -0
- data/lib/spstrigger_execute.rb +42 -22
- metadata +10 -10
- 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: 37e6cc9ce29fd8d990464781f453c43cc63e0cb8
|
4
|
+
data.tar.gz: bf224caaaaa1a60e8bb9ce82420acc086cff0211
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c0541a03d545717c9c239cd33475762f799dd16f6fa2e71622ad5e80780cb270b65a5c3eef5c9f416810deb3bea9c63ade3851647436d82c3aeaecc24381a11
|
7
|
+
data.tar.gz: 7f60069dba09e5d58f135a69f7cb0b006b55f9117e86ff1467d461cc2519788590e7e6204eda6edc4b22769866ab8849246b367cd07a13405ecd1bdac750f171
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/spstrigger_execute.rb
CHANGED
@@ -9,9 +9,9 @@ require 'xmlregistry_objects'
|
|
9
9
|
|
10
10
|
class SPSTriggerExecute
|
11
11
|
|
12
|
-
def initialize(x, reg=nil, polyrexdoc=nil)
|
13
|
-
|
12
|
+
def initialize(x, reg=nil, polyrexdoc=nil, logfile: nil)
|
14
13
|
|
14
|
+
@log = Logger.new logfile,'daily' if logfile
|
15
15
|
dx = if x.is_a? Dynarex then
|
16
16
|
|
17
17
|
x
|
@@ -24,15 +24,15 @@ class SPSTriggerExecute
|
|
24
24
|
end
|
25
25
|
|
26
26
|
@patterns = dx.to_h
|
27
|
-
|
27
|
+
|
28
28
|
if reg and polyrexdoc then
|
29
|
-
|
29
|
+
|
30
30
|
xro = XMLRegistryObjects.new(reg, polyrexdoc)
|
31
31
|
|
32
32
|
@h = xro.to_h
|
33
33
|
define_methods = @h.keys.map {|x| "def #{x}() @h[:#{x}] end"}
|
34
34
|
instance_eval define_methods.join("\n")
|
35
|
-
|
35
|
+
log 'define_methods : ' + self.public_methods.sort.inspect
|
36
36
|
end
|
37
37
|
|
38
38
|
end
|
@@ -43,6 +43,11 @@ class SPSTriggerExecute
|
|
43
43
|
end
|
44
44
|
|
45
45
|
alias mae match_and_execute
|
46
|
+
|
47
|
+
def run(s)
|
48
|
+
instance_eval s
|
49
|
+
end
|
50
|
+
|
46
51
|
|
47
52
|
private
|
48
53
|
|
@@ -81,7 +86,9 @@ class SPSTriggerExecute
|
|
81
86
|
|
82
87
|
if result and conditions.length > 0 then
|
83
88
|
|
89
|
+
log 'conditions: ' + conditions.inspect
|
84
90
|
success = eval conditions
|
91
|
+
log 'success : ' + success.inspect
|
85
92
|
result = nil unless success
|
86
93
|
end
|
87
94
|
|
@@ -90,6 +97,12 @@ class SPSTriggerExecute
|
|
90
97
|
end
|
91
98
|
end
|
92
99
|
|
100
|
+
def log(s)
|
101
|
+
if @log then
|
102
|
+
@logger.debug s
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
93
106
|
def prepare_jobs(results)
|
94
107
|
|
95
108
|
results.inject([]) do |r,h|
|
@@ -98,33 +111,39 @@ class SPSTriggerExecute
|
|
98
111
|
a += h[:topic].captures if h[:topic] && h[:topic].captures.any?
|
99
112
|
a += h[:msg].captures if h[:msg]
|
100
113
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
if job[/^\/\//] then
|
114
|
+
jobs = @patterns[h[:index].to_i - 1][:job]
|
115
|
+
|
116
|
+
jobs.split(/\s*;\s*/).each do |job|
|
105
117
|
|
106
|
-
|
118
|
+
job_args = job.split + a
|
107
119
|
|
108
|
-
|
120
|
+
if job[/^\/\//] then
|
109
121
|
|
110
|
-
|
122
|
+
r << [:rse, job_args]
|
123
|
+
|
124
|
+
elsif job[/^[\w\/]+:/]
|
111
125
|
|
112
|
-
|
113
|
-
x.sub(/\$\d/, a[i])
|
114
|
-
end
|
126
|
+
topic_message = job.gsub(/\$\d/) do |x|
|
115
127
|
|
116
|
-
|
117
|
-
|
118
|
-
|
128
|
+
i = x[/\d$/].to_i - 1
|
129
|
+
x.sub(/\$\d/, a[i])
|
130
|
+
end
|
119
131
|
|
120
|
-
|
121
|
-
|
122
|
-
|
132
|
+
topic_message = topic_message\
|
133
|
+
.gsub(/![Tt]ime/,Time.now.strftime("%a %H:%M%P"))\
|
134
|
+
.gsub(/![Dd]ate/,Time.now.strftime("%d %b"))
|
123
135
|
|
136
|
+
|
137
|
+
r << [:sps, topic_message]
|
138
|
+
else
|
139
|
+
|
140
|
+
r << [:ste, job]
|
141
|
+
|
124
142
|
end
|
125
|
-
|
126
143
|
end
|
144
|
+
|
127
145
|
r
|
146
|
+
|
128
147
|
end
|
129
148
|
end
|
130
149
|
|
@@ -138,4 +157,5 @@ class SPSTriggerExecute
|
|
138
157
|
|
139
158
|
t
|
140
159
|
end
|
160
|
+
|
141
161
|
end
|
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.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
rlSMrvljzPJPts27UIPIfU02mkTZzELneWPUEQlIK/ADjdiGu2uxlWT5g77gwM+g
|
32
32
|
fYtWdC+NEqa0rg==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2015-03-
|
34
|
+
date: 2015-03-09 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: dynarex
|
@@ -59,40 +59,40 @@ dependencies:
|
|
59
59
|
requirements:
|
60
60
|
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: '0.
|
62
|
+
version: '0.3'
|
63
63
|
- - ">="
|
64
64
|
- !ruby/object:Gem::Version
|
65
|
-
version: 0.
|
65
|
+
version: 0.3.0
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
68
|
version_requirements: !ruby/object:Gem::Requirement
|
69
69
|
requirements:
|
70
70
|
- - "~>"
|
71
71
|
- !ruby/object:Gem::Version
|
72
|
-
version: '0.
|
72
|
+
version: '0.3'
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.
|
75
|
+
version: 0.3.0
|
76
76
|
- !ruby/object:Gem::Dependency
|
77
77
|
name: xmlregistry_objects
|
78
78
|
requirement: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0.
|
82
|
+
version: '0.5'
|
83
83
|
- - ">="
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version: 0.
|
85
|
+
version: 0.5.1
|
86
86
|
type: :runtime
|
87
87
|
prerelease: false
|
88
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
89
|
requirements:
|
90
90
|
- - "~>"
|
91
91
|
- !ruby/object:Gem::Version
|
92
|
-
version: '0.
|
92
|
+
version: '0.5'
|
93
93
|
- - ">="
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: 0.
|
95
|
+
version: 0.5.1
|
96
96
|
description:
|
97
97
|
email: james@r0bertson.co.uk
|
98
98
|
executables: []
|
metadata.gz.sig
CHANGED
Binary file
|