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.
- checksums.yaml +4 -4
- data/lib/re_duxml/evaluate.rb +8 -3
- 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: 785d74d157df234ce45edc8a0e7e87d95ced0d5d
|
4
|
+
data.tar.gz: 39b1ab5dd640ca985b3f5d6a164cd5a6452014f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04a3a233407aacffdfd04dd02b23655a5d7e316c5d265f30b916e64e997c6de77f9c3a8e1f69d50de708e446f936d7895388ca203dea8db88d4a329ef53f2956
|
7
|
+
data.tar.gz: 7f47642f7815b3962a18e3bb6dfa12b56f1b6d5b0f909ce58170d7577750c31857816a617cc83ffe8f152000bd8a4734347152f7618e7f055549aefcf3496013
|
data/lib/re_duxml/evaluate.rb
CHANGED
@@ -24,7 +24,10 @@ module ReDuxml
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def evaluate(_expr, _param_hash={})
|
27
|
-
|
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
|
-
|
46
|
-
|
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
|