Class: ASpaceExport::RawXMLHandler

Inherits:
Object
  • Object
show all
Defined in:
backend/app/exporters/lib/streaming_xml.rb

Instance Method Summary collapse

Constructor Details

#initializeRawXMLHandler

Returns a new instance of RawXMLHandler.



4
5
6
# File 'backend/app/exporters/lib/streaming_xml.rb', line 4

def initialize
  @fragments = {}
end

Instance Method Details

#<<(s) ⇒ Object



8
9
10
11
12
# File 'backend/app/exporters/lib/streaming_xml.rb', line 8

def <<(s)
  id = SecureRandom.hex
  @fragments[id] = s
  ":aspace_fragment_#{id}"
end

#substitute_fragments(xml_string) ⇒ Object



14
15
16
17
18
19
20
# File 'backend/app/exporters/lib/streaming_xml.rb', line 14

def substitute_fragments(xml_string)
  @fragments.each do |id, fragment|
    xml_string.gsub!(/:aspace_fragment_#{id}/, fragment)
  end

  xml_string
end