Class: BuildMaster::Include

Inherits:
Object
  • Object
show all
Defined in:
lib/buildmaster/templatelets/include.rb

Instance Method Summary collapse

Constructor Details

#initialize(site_spec) ⇒ Include

Returns a new instance of Include.



4
5
6
# File 'lib/buildmaster/templatelets/include.rb', line 4

def initialize(site_spec)  
  @site_spec = site_spec
end

Instance Method Details

#process(target, template, source) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/buildmaster/templatelets/include.rb', line 8

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