re_duxml 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/re_duxml.rb +6 -1
- data/lib/re_duxml/evaluate.rb +3 -1
- data/lib/re_duxml/evaluate/parser.rb +2 -2
- data/lib/ruby_ext/macro.rb +6 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 137900a8cff029f268daeb5a3e7423dd2cc7976f
|
4
|
+
data.tar.gz: 1446449984ed19d2545ccf2ee42a1f64bb0fb922
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d89f27bbf73a6311ffc0b7c38458e7b6959f07aea9dbffa2af3d1b7cbff0b0e2dba4a4b3034a7a5c7e5ba55fbe9dc15377f4f5d46fb02d5955b0c4bd9ac1ce1
|
7
|
+
data.tar.gz: 8035361a455de992579d58bab2e563172dbf39cfcf85399c61589cb6b10ee15db0fac7340e57c94bea58a55cbc9ff48c35f44bfce7bd25093675c33ce7991293
|
data/lib/re_duxml.rb
CHANGED
@@ -90,7 +90,12 @@ module ReDuxml
|
|
90
90
|
return output_str if questions.empty?
|
91
91
|
questions.each do |question|
|
92
92
|
reply = Macro.new e.evaluate(question, param_hash).to_s
|
93
|
-
replacement_str = reply.parameterized?
|
93
|
+
replacement_str = if reply.parameterized?
|
94
|
+
reply.to_s
|
95
|
+
else
|
96
|
+
macro_value = reply.demacro
|
97
|
+
Regexp.string.match(macro_value) ? macro_value[1..-2] : macro_value
|
98
|
+
end
|
94
99
|
macro_string = Macro.new(question).macro_string
|
95
100
|
output_str.gsub!(macro_string, replacement_str)
|
96
101
|
end
|
data/lib/re_duxml/evaluate.rb
CHANGED
@@ -56,7 +56,9 @@ module ReDuxml
|
|
56
56
|
include Symbolic
|
57
57
|
|
58
58
|
def reduce(_ast)
|
59
|
-
|
59
|
+
return _ast if _ast.children.empty?
|
60
|
+
ast = _ast.type.respond_to?(:symbol) ? _ast
|
61
|
+
: new_ast(parser.logic[_ast.type.to_s], _ast.children.dup)
|
60
62
|
if ast.children.any?
|
61
63
|
operator = ast.type
|
62
64
|
args = ast.children.collect do |c|
|
@@ -126,7 +126,7 @@ module ReDuxml
|
|
126
126
|
unless output.count == 1
|
127
127
|
fail ParseError, "Invalid statement"
|
128
128
|
end
|
129
|
-
|
129
|
+
|
130
130
|
output.first
|
131
131
|
end # def parse(expr)
|
132
132
|
|
@@ -142,4 +142,4 @@ module ReDuxml
|
|
142
142
|
Array.new(count) { output.pop }.reverse.compact
|
143
143
|
end
|
144
144
|
end # class Parser
|
145
|
-
end # module ReDuxml
|
145
|
+
end # module ReDuxml
|
data/lib/ruby_ext/macro.rb
CHANGED
@@ -44,8 +44,13 @@ class Macro
|
|
44
44
|
macro_string[2..-2]
|
45
45
|
end
|
46
46
|
|
47
|
+
def to_s
|
48
|
+
macro_string
|
49
|
+
end
|
50
|
+
|
47
51
|
# returns nil if not, and match data for any parameter names found
|
48
52
|
def parameterized?
|
53
|
+
return false if macro_string[2] == '"' && macro_string[-2] == '"'
|
49
54
|
macro_string.match Regexp.identifier
|
50
55
|
end
|
51
|
-
end # class Macro
|
56
|
+
end # class Macro
|