marty 2.5.8 → 2.5.9
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
- data/Gemfile +1 -0
- data/Gemfile.lock +6 -1
- data/app/components/marty/script_tester.rb +1 -1
- data/lib/marty/rule_script_set.rb +25 -10
- data/lib/marty/version.rb +1 -1
- data/spec/features/rule_spec.rb +7 -6
- data/spec/features/scripting_test_spec.rb +7 -0
- data/spec/models/rule_spec.rb +13 -6
- data/spec/other/diagnostic/delayed_job_workers_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec3679621406e9c0a3d3a343f38bc89cd467a9e39c353b7a2a4911877482194d
|
4
|
+
data.tar.gz: fde0d9513d1f964b7a9a7022d964971a6aa486785027e7e96ddb1da11c815807
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d520244f0c0e98a1ae3c779660f049663514f2062eabd837e3167bb6098754476abef431e5f9c22fdd460567c56791a7d08095b852af0c807a628c6998148cfc
|
7
|
+
data.tar.gz: f6d70ee23ab6b1a571a5bb913ffc10e453169731b4e5736a8ac22ff830262b65d19e9cf81361f8e54f54fd774d64b6149f6d572c524249af8c80a9315537da95
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
marty (2.5.
|
4
|
+
marty (2.5.9)
|
5
5
|
aws-sigv4 (~> 1.0, >= 1.0.2)
|
6
6
|
axlsx (= 3.0.0pre)
|
7
7
|
coderay
|
@@ -69,6 +69,7 @@ GEM
|
|
69
69
|
nokogiri (~> 1.8, >= 1.8.2)
|
70
70
|
rubyzip (~> 1.2, >= 1.2.1)
|
71
71
|
builder (3.2.3)
|
72
|
+
byebug (11.0.0)
|
72
73
|
capybara (2.18.0)
|
73
74
|
addressable
|
74
75
|
mini_mime (>= 0.1.3)
|
@@ -152,6 +153,9 @@ GEM
|
|
152
153
|
pry (0.12.2)
|
153
154
|
coderay (~> 1.1.0)
|
154
155
|
method_source (~> 0.9.0)
|
156
|
+
pry-byebug (3.7.0)
|
157
|
+
byebug (~> 11.0)
|
158
|
+
pry (~> 0.10)
|
155
159
|
pry-rails (0.3.9)
|
156
160
|
pry (>= 0.10.4)
|
157
161
|
public_suffix (3.0.3)
|
@@ -264,6 +268,7 @@ DEPENDENCIES
|
|
264
268
|
mcfly
|
265
269
|
netzke (= 6.5.0.0)
|
266
270
|
pg
|
271
|
+
pry-byebug
|
267
272
|
pry-rails
|
268
273
|
rails (~> 5.1.4)
|
269
274
|
rails-controller-testing
|
@@ -34,7 +34,7 @@ class Marty::RuleScriptSet < Delorean::AbstractContainer
|
|
34
34
|
|
35
35
|
def write_attr(k, v)
|
36
36
|
equals, rhs = v == :parameter ? [' =?', ''] :
|
37
|
-
[
|
37
|
+
[" =\n", v.lines.map { |l| ' ' * 8 + l }.join]
|
38
38
|
k + equals + rhs
|
39
39
|
end
|
40
40
|
|
@@ -128,24 +128,33 @@ class Marty::RuleScriptSet < Delorean::AbstractContainer
|
|
128
128
|
errs
|
129
129
|
end
|
130
130
|
|
131
|
-
def
|
132
|
-
|
133
|
-
errs = { class_body: self.class.body_lines } + code_section_counts(ruleh)
|
134
|
-
ranges0 = errs.values.reduce([0]) do |acc, len|
|
131
|
+
def search_ranges(oh, line)
|
132
|
+
ranges0 = oh.values.reduce([0]) do |acc, len|
|
135
133
|
acc + [acc.last + len]
|
136
134
|
end
|
137
|
-
ranges =
|
135
|
+
ranges = oh.keys.zip(ranges0.each_cons(2).to_a)
|
138
136
|
secnm, (st, en) = ranges.detect do |sec, (st, en)|
|
139
137
|
line.between?(st, en - 1)
|
140
138
|
end
|
141
139
|
[secnm, line - st + 1]
|
140
|
+
end
|
141
|
+
|
142
|
+
def get_parse_error_field(ruleh, exc)
|
143
|
+
line = (exc.line || 1) - 1
|
144
|
+
errs = { class_body: self.class.body_lines } + code_section_counts(ruleh)
|
145
|
+
secnm, line_in_sec = search_ranges(errs, line)
|
146
|
+
if [:computed_guards, :results].include?(secnm)
|
147
|
+
h = Hash[ruleh[secnm.to_s].map { |k, v| [k, v.lines.count + 1] }]
|
148
|
+
attrnm, = search_ranges(h, line_in_sec)
|
149
|
+
end
|
150
|
+
[secnm, attrnm || line_in_sec]
|
142
151
|
rescue StandardError => e
|
143
152
|
Marty::Logger.error('RuleScriptSet#get_parse_error_field',
|
144
153
|
error: e.message,
|
145
154
|
backtrace: e.backtrace,
|
146
155
|
ruleh: ruleh,
|
147
156
|
line: line)
|
148
|
-
[
|
157
|
+
[nil, nil]
|
149
158
|
end
|
150
159
|
|
151
160
|
def get_engine(ruleh)
|
@@ -184,10 +193,16 @@ class Marty::RuleScriptSet < Delorean::AbstractContainer
|
|
184
193
|
@@engines[[pt, sname]] = sset.parse_check(sname, get_code(ruleh))
|
185
194
|
end
|
186
195
|
rescue Delorean::ParseError => e
|
187
|
-
secnm,
|
196
|
+
secnm, attr_or_line = get_parse_error_field(ruleh, e)
|
188
197
|
msg = e.message.capitalize
|
189
|
-
|
190
|
-
|
198
|
+
field = secnm ? "field '#{secnm}'" : ''
|
199
|
+
where = if attr_or_line.is_a?(String)
|
200
|
+
then "(attribute #{attr_or_line})"
|
201
|
+
elsif attr_or_line.is_a?(Integer)
|
202
|
+
then "(line #{attr_or_line})"
|
203
|
+
else ''
|
204
|
+
end
|
205
|
+
raise "Error in rule '#{ruleh['name']}' #{field} #{where}: #{msg}"
|
191
206
|
end
|
192
207
|
|
193
208
|
def self.indent(s)
|
data/lib/marty/version.rb
CHANGED
data/spec/features/rule_spec.rb
CHANGED
@@ -222,16 +222,16 @@ feature 'rule view', js: true do
|
|
222
222
|
fill_in(:computed_guards, with: "x = true\ny = false\nvar = 123j\nz = true")
|
223
223
|
press('OK')
|
224
224
|
wait_for_ajax
|
225
|
-
exp = "Computed - Error in rule 'abc' field 'computed_guards'
|
226
|
-
'Syntax error'
|
225
|
+
exp = "Computed - Error in rule 'abc' field 'computed_guards' "\
|
226
|
+
'(attribute var): Syntax error'
|
227
227
|
expect(page).to have_content(exp)
|
228
228
|
sleep 2
|
229
229
|
|
230
230
|
fill_in(:computed_guards, with: %Q(var1 = "good"\nvar2 = 123\nvar3 = 123j))
|
231
231
|
press('OK')
|
232
232
|
wait_for_ajax
|
233
|
-
exp = "Computed - Error in rule 'abc' field 'computed_guards'
|
234
|
-
'Syntax error'
|
233
|
+
exp = "Computed - Error in rule 'abc' field 'computed_guards' "\
|
234
|
+
'(attribute var3): Syntax error'
|
235
235
|
expect(page).to have_content(exp)
|
236
236
|
sleep 2
|
237
237
|
|
@@ -239,7 +239,7 @@ feature 'rule view', js: true do
|
|
239
239
|
fill_in(:results, with: %Q(var3 = 123j\nvar1 = "good"\nvar2 = 123))
|
240
240
|
press('OK')
|
241
241
|
wait_for_ajax
|
242
|
-
exp = "Computed - Error in rule 'abc' field 'results' (
|
242
|
+
exp = "Computed - Error in rule 'abc' field 'results' (attribute var3): "\
|
243
243
|
'Syntax error'
|
244
244
|
expect(page).to have_content(exp)
|
245
245
|
sleep 2
|
@@ -247,7 +247,8 @@ feature 'rule view', js: true do
|
|
247
247
|
fill_in(:results, with: %Q(abc = "def"\ndef = 5\nxyz = def+10\nsadf asdf lsf))
|
248
248
|
press('OK')
|
249
249
|
wait_for_ajax
|
250
|
-
exp = "Computed - Error in rule 'abc' field 'results' (
|
250
|
+
exp = "Computed - Error in rule 'abc' field 'results' (attribute xyz): "\
|
251
|
+
'Syntax error'
|
251
252
|
expect(page).to have_content(exp)
|
252
253
|
sleep 2
|
253
254
|
|
@@ -119,6 +119,13 @@ DELOREAN
|
|
119
119
|
expect(page).to have_content 'undefined parameter p0'
|
120
120
|
end
|
121
121
|
|
122
|
+
and_by 'see malformed params error' do
|
123
|
+
fill_in('params', with: 'a = Wrong::Class.last')
|
124
|
+
press('Compute')
|
125
|
+
wait_for_ajax
|
126
|
+
expect(page).to have_content 'Malformed input parameters'
|
127
|
+
end
|
128
|
+
|
122
129
|
and_by 'compute attrs with good params' do
|
123
130
|
fill_in('params', with: "a = 1.1\nc = 2.2\np0 = 3.3\n")
|
124
131
|
press('Compute')
|
data/spec/models/rule_spec.rb
CHANGED
@@ -74,7 +74,7 @@ module Marty::RuleSpec
|
|
74
74
|
@rule_type = 'SimpleRule'
|
75
75
|
@computed_guards = { 'guard1' => 'zvjsdf12.z8*' }
|
76
76
|
exp = Regexp.new("Computed - Error in rule 'testrule' field "\
|
77
|
-
"'computed_guards' .
|
77
|
+
"'computed_guards' .attribute guard1.: Syntax error")
|
78
78
|
expect { subject }.to raise_error(exp)
|
79
79
|
end
|
80
80
|
it 'detects errors in computed results' do
|
@@ -83,7 +83,7 @@ module Marty::RuleSpec
|
|
83
83
|
'does_not_compute' => 'zvjsdf12.z8*' }
|
84
84
|
@grids = { 'grid1' => 'DataGrid1', 'grid2' => 'DataGrid2' }
|
85
85
|
exp = Regexp.new("Computed - Error in rule 'testrule' field "\
|
86
|
-
"'results' .
|
86
|
+
"'results' .attribute does_not_compute.: Syntax error")
|
87
87
|
expect { subject }.to raise_error(exp)
|
88
88
|
end
|
89
89
|
it 'detects errors in computed results 2' do
|
@@ -92,9 +92,16 @@ module Marty::RuleSpec
|
|
92
92
|
@grids = { 'grid1' => 'DataGrid1', 'grid2' => 'DataGrid1',
|
93
93
|
'grid3' => 'DataGrid3' }
|
94
94
|
exp = Regexp.new("Computed - Error in rule 'testrule' field "\
|
95
|
-
"'results' .
|
95
|
+
"'results' .attribute does_not_compute.: Syntax error")
|
96
96
|
expect { subject }.to raise_error(exp)
|
97
97
|
end
|
98
|
+
it 'avoids delorean parse bug (redline 168745)' do
|
99
|
+
@rule_type = 'SimpleRule'
|
100
|
+
@results = { 'parse_bug' => "true\n&& false" }
|
101
|
+
@grids = { 'grid1' => 'DataGrid1', 'grid2' => 'DataGrid1',
|
102
|
+
'grid3' => 'DataGrid3' }
|
103
|
+
expect { subject }.to_not raise_error
|
104
|
+
end
|
98
105
|
it 'detects errors in computed results 3' do
|
99
106
|
@rule_type = 'SimpleRule'
|
100
107
|
@results = { 'does_compute' => '1+2',
|
@@ -104,7 +111,7 @@ module Marty::RuleSpec
|
|
104
111
|
@grids = { 'grid1' => 'DataGrid1', 'grid2' => 'DataGrid1',
|
105
112
|
'grid3' => 'DataGrid1' }
|
106
113
|
exp = Regexp.new("Computed - Error in rule 'testrule' field "\
|
107
|
-
"'results' .
|
114
|
+
"'results' .attribute does_not_compute.: Syntax error")
|
108
115
|
expect { subject }.to raise_error(exp)
|
109
116
|
end
|
110
117
|
it 'reports bad grid names' do
|
@@ -145,7 +152,7 @@ module Marty::RuleSpec
|
|
145
152
|
@rule_type = 'XRule'
|
146
153
|
@results = { 'x' => 'zx sdf wer' }
|
147
154
|
exp = Regexp.new("Computed - Error in rule 'testrule' field "\
|
148
|
-
"'results' .
|
155
|
+
"'results' .attribute x.: Syntax error")
|
149
156
|
expect { subject }.to raise_error(exp)
|
150
157
|
end
|
151
158
|
it 'rule script stuff overrides 1' do
|
@@ -159,7 +166,7 @@ module Marty::RuleSpec
|
|
159
166
|
@rule_type = 'XRule'
|
160
167
|
@computed_guards = { 'abc' => 'err err err', 'xyz_guard' => 'xyz_param' }
|
161
168
|
exp = Regexp.new("Computed - Error in rule 'testrule' field "\
|
162
|
-
"'computed_guards' .
|
169
|
+
"'computed_guards' .attribute abc.: Syntax error")
|
163
170
|
expect { subject }.to raise_error(exp)
|
164
171
|
end
|
165
172
|
it 'rule script stuff overrides 3' do
|
@@ -2,13 +2,13 @@ require 'spec_helper'
|
|
2
2
|
require 'job_helper'
|
3
3
|
|
4
4
|
describe Marty::Diagnostic::DelayedJobWorkers do
|
5
|
-
def sample_data opts={}
|
5
|
+
def sample_data opts = {}
|
6
6
|
ip, error, status = opts.values_at(:ip, :error, :status)
|
7
7
|
{
|
8
8
|
ip || Marty::Helper.my_ip => {
|
9
9
|
'Delayed Workers / Node' => {
|
10
10
|
'description' => error ? '3' : '4',
|
11
|
-
'status' => status,
|
11
|
+
'status' => status || true,
|
12
12
|
'consistent' => nil
|
13
13
|
},
|
14
14
|
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.5.
|
4
|
+
version: 2.5.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arman Bostani
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date: 2019-03-
|
17
|
+
date: 2019-03-12 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: pg
|