Sha256: 640c8b19df35a81f63fabf89b8d3f125bde85904f2d9cb18b401800008ac21e0

Contents?: true

Size: 769 Bytes

Versions: 8

Compression:

Stored size: 769 Bytes

Contents

module BuildMaster
class Include
  def initialize(site_spec)  
    @site_spec = site_spec
  end
  
  def process(target, template, source)
      elements_xpath = template.attribute_value!('elements')
      if (elements_xpath[elements_xpath.length - 1, 1] == '*')
        elements_xpath = elements_xpath[0, elements_xpath.length - 1]
        REXML::XPath.each(source.document, elements_xpath) do |matched|
          matched.each_child {|child| target.add(deep_clone(child))}
        end
      else
        REXML::XPath.each(source.document, elements_xpath) {|matched| target.add(deep_clone(matched))}
      end
  end
  
  private  
  def deep_clone(node )
    if node.kind_of? REXML::Parent
      node.deep_clone
    else
      node.clone
    end
  end
        
end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
BuildMaster-0.8.0 lib/buildmaster/templatelets/include.rb
BuildMaster-0.8.1 lib/buildmaster/templatelets/include.rb
BuildMaster-0.9.0 lib/buildmaster/templatelets/include.rb
BuildMaster-0.9.1 lib/buildmaster/templatelets/include.rb
BuildMaster-1.0.6 lib/buildmaster/site/templatelets/include.rb
BuildMaster-1.0.9 lib/buildmaster/site/templatelets/include.rb
BuildMaster-1.1.12 lib/buildmaster/site/templatelets/include.rb
BuildMaster-1.1.9 lib/buildmaster/site/templatelets/include.rb