Class: BuildMaster::Include
- Inherits:
-
Object
- Object
- BuildMaster::Include
- Defined in:
- lib/buildmaster/templatelets/include.rb
Instance Method Summary collapse
-
#initialize(site_spec) ⇒ Include
constructor
A new instance of Include.
- #process(target, template, source) ⇒ Object
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 |