re_duxml 0.2.2 → 0.2.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 785d74d157df234ce45edc8a0e7e87d95ced0d5d
4
- data.tar.gz: 39b1ab5dd640ca985b3f5d6a164cd5a6452014f1
3
+ metadata.gz: 137900a8cff029f268daeb5a3e7423dd2cc7976f
4
+ data.tar.gz: 1446449984ed19d2545ccf2ee42a1f64bb0fb922
5
5
  SHA512:
6
- metadata.gz: 04a3a233407aacffdfd04dd02b23655a5d7e316c5d265f30b916e64e997c6de77f9c3a8e1f69d50de708e446f936d7895388ca203dea8db88d4a329ef53f2956
7
- data.tar.gz: 7f47642f7815b3962a18e3bb6dfa12b56f1b6d5b0f909ce58170d7577750c31857816a617cc83ffe8f152000bd8a4734347152f7618e7f055549aefcf3496013
6
+ metadata.gz: 7d89f27bbf73a6311ffc0b7c38458e7b6959f07aea9dbffa2af3d1b7cbff0b0e2dba4a4b3034a7a5c7e5ba55fbe9dc15377f4f5d46fb02d5955b0c4bd9ac1ce1
7
+ data.tar.gz: 8035361a455de992579d58bab2e563172dbf39cfcf85399c61589cb6b10ee15db0fac7340e57c94bea58a55cbc9ff48c35f44bfce7bd25093675c33ce7991293
@@ -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? ? reply.macro_string : reply.demacro
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
@@ -56,7 +56,9 @@ module ReDuxml
56
56
  include Symbolic
57
57
 
58
58
  def reduce(_ast)
59
- ast = _ast.type.respond_to?(:symbol) ? _ast : new_ast(parser.logic[_ast.type.to_s], _ast.children.dup)
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
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: re_duxml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Kong