re_duxml 0.1.3 → 0.1.4

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.rb +5 -5
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8ecc1d4c65a2c7a250242ef624861b9a9d7ce12e
4
- data.tar.gz: a15cfeae9bd1cfc2432b2adc0dddf73434288ce8
3
+ metadata.gz: 4d2ccb9fa84a9e969220ff9ab2cbe9a945cb9f07
4
+ data.tar.gz: 9f9c52ad59e65c6d888e18c35cdbdf900c962aa5
5
5
  SHA512:
6
- metadata.gz: 1215f4cdf0abb5df9a3b28b28579ea14841aab9f1c49cb86dcb7b92f24f3e219c878971ff44f842249eb0ea81084bc38cdcbcba6528d7e68c1c6fe2c3492b2dd
7
- data.tar.gz: 95e86ed98dd38f51c52ab34ce350c38be085a421efd7f799dd19fbf00a27cbd5e58bd783992f91cacd001dc46d796a6da76f2c7698704d697f2b48218b2aca0d
6
+ metadata.gz: 61dfd7e3bc30423fbc216947232d60d7da2247a74d18c26f984450d00c92e627c79fc250fba7e3b70695f70e59545c37521c575e7015e12eef62407f01a342df
7
+ data.tar.gz: 6e6c50737da85d318f516f2f10d6daa905b0ddae7ddbb60ea1e11d312a9f2b95b49920e3fc80f70cbf760424b6224b8985652994d56e83ad5eed123ca4381711
data/lib/re_duxml.rb CHANGED
@@ -11,6 +11,7 @@ module ReDuxml
11
11
  # @param doc_or_node [Doc, String] XML to load; can be Doc, String path or String XML; also XML Element when recursing
12
12
  # @return [Doc] instantiated XML with parameters resolved with given values
13
13
  def resolve(doc_or_node, parent_params={})
14
+ @e ||= Evaluator.new
14
15
  if doc_or_node.is_a?(Element)
15
16
  resolved_node = doc_or_node.stub
16
17
  resolved_node.attributes.each do |attr, val|
@@ -18,11 +19,11 @@ module ReDuxml
18
19
  end
19
20
  this_params = get_params(doc_or_node, parent_params)
20
21
  new_children = doc_or_node.nodes.collect do |child|
21
- if child.respond_to?(:nodes)
22
+ if child.respond_to?(:nodes) # if this node is an XML element...
22
23
  new_child = child.clone
23
24
  new_child[:if] = resolve_str(new_child[:if], this_params) if new_child[:if]
24
- if new_child.if?
25
- new_child[:if] = nil
25
+ if new_child.if? # if this node should exist
26
+ new_child[:if] = nil if new_child[:if] == 'true'
26
27
  child_params = get_params(new_child, this_params)
27
28
  new_instances = new_child.activate
28
29
  i = -1
@@ -31,13 +32,12 @@ module ReDuxml
31
32
  resolve(inst, child_params.merge({'iterator' => i.to_s}))
32
33
  end
33
34
  end
34
- else
35
+ else # this is a text node
35
36
  resolve_str(child, this_params)
36
37
  end
37
38
  end.flatten.compact
38
39
  resolved_node << new_children
39
40
  else
40
- @e ||= Evaluator.new
41
41
  @src_doc = get_doc doc_or_node
42
42
  @doc = Doc.new << resolve(src_doc.root, parent_params)
43
43
  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.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Kong