Class: Wukong::Processor::JoinXML
- Inherits:
-
Wukong::Processor
- Object
- Hanuman::Stage
- Wukong::Processor
- Wukong::Processor::JoinXML
- Defined in:
- lib/wukong/widget/reducers/join_xml.rb
Overview
Joins XML input data based on a root tag.
Constant Summary
Constants inherited from Wukong::Processor
Instance Attribute Summary
Attributes included from Hanuman::StageInstanceMethods
Instance Method Summary collapse
Methods inherited from Wukong::Processor
configure, description, #finalize, #perform_action, #receive_action, #stop
Methods included from Logging
Methods inherited from Hanuman::Stage
Methods included from Hanuman::StageClassMethods
#builder, #label, #register, #set_builder
Methods included from Hanuman::StageInstanceMethods
#add_link, #linkable_name, #root
Instance Method Details
#process(line) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/wukong/widget/reducers/join_xml.rb', line 13 def process line if match = terminator.match(line) if match.end(0) == line.size @lines << line else @lines << line[0...match.end(0)] end yield @lines.join("\n") @lines = [] @lines << line[match.end(0)..-1] unless match.end(0) == line.size else @lines << line end end |
#setup ⇒ Object
9 10 11 |
# File 'lib/wukong/widget/reducers/join_xml.rb', line 9 def setup @lines = [] end |
#terminator ⇒ Object
28 29 30 |
# File 'lib/wukong/widget/reducers/join_xml.rb', line 28 def terminator %r{<\s*/\s*#{root}\s*>}i end |