re_duxml 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/re_duxml/evaluate.rb +8 -3
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d7aa0ff7e9837f2d3564fc91b0c94eba1e2273bc
4
- data.tar.gz: 13885673bdf57e816f0cc1e38a57b35b0265d3c6
3
+ metadata.gz: 785d74d157df234ce45edc8a0e7e87d95ced0d5d
4
+ data.tar.gz: 39b1ab5dd640ca985b3f5d6a164cd5a6452014f1
5
5
  SHA512:
6
- metadata.gz: 19f5fe9ee8263f095be0bae588087b814c481efc68150337bf75e03fbe506385b9ec9a0220e3a09f20b2da7248a942574d9f2090c42436334e6b90769416573c
7
- data.tar.gz: 115cc0f537aa035d1ad605df26d5355b3a4b403ae06813dba067024a9ef48d495182903ed83516d558539d6d80485cf1632aea16d694a057ec7d9ce75780ef52
6
+ metadata.gz: 04a3a233407aacffdfd04dd02b23655a5d7e316c5d265f30b916e64e997c6de77f9c3a8e1f69d50de708e446f936d7895388ca203dea8db88d4a329ef53f2956
7
+ data.tar.gz: 7f47642f7815b3962a18e3bb6dfa12b56f1b6d5b0f909ce58170d7577750c31857816a617cc83ffe8f152000bd8a4734347152f7618e7f055549aefcf3496013
@@ -24,7 +24,10 @@ module ReDuxml
24
24
  end
25
25
 
26
26
  def evaluate(_expr, _param_hash={})
27
- @param_hash = _param_hash
27
+ _param_hash.each do |key, val|
28
+ @param_hash[key.to_s] = _param_hash[key]
29
+ end
30
+
28
31
  expr = resolve_params _expr
29
32
  return expr if expr.parameterized?
30
33
  return expr if Regexp.identifier.match(expr).to_s == expr
@@ -42,8 +45,10 @@ module ReDuxml
42
45
 
43
46
  def resolve_params(_expr)
44
47
  expr = _expr.dup
45
- param_hash.keys.sort_by do |key| -key.size end.each do |key|
46
- expr.gsub!(key.to_s, param_hash[key].to_s)
48
+ _expr.scan(Regexp.identifier) do |match|
49
+ param_name = match[0]
50
+ param_value = param_hash[param_name] || param_name
51
+ expr.gsub!(/\b#{Regexp.quote(param_name)}\b/, param_value.to_s)
47
52
  end
48
53
  expr
49
54
  end
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.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Kong