Module: ProformaXML::Helpers::ExportHelpers
- Included in:
- Exporter
- Defined in:
- lib/proformaxml/helpers/export_helpers.rb
Instance Method Summary collapse
- #add_dachsfisch_node(xml, dachsfisch_node, node_name_fallback = nil) ⇒ Object
- #add_description_to_xml(xml, description) ⇒ Object
- #add_namespaces_for_dachsfisch_node(dachsfisch_node, xml) ⇒ Object
- #add_parent_uuid_and_lang_to_header(header) ⇒ Object
- #add_test_configuration(xml, test) ⇒ Object
- #attach_file(xml, file) ⇒ Object
- #embed_file(file, xml) ⇒ Object
Instance Method Details
#add_dachsfisch_node(xml, dachsfisch_node, node_name_fallback = nil) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/proformaxml/helpers/export_helpers.rb', line 34 def add_dachsfisch_node(xml, dachsfisch_node, node_name_fallback = nil) if dachsfisch_node.blank? xml.send(node_name_fallback, '') if node_name_fallback.present? return end xml_snippet = Dachsfisch::JSON2XMLConverter.perform(json: dachsfisch_node.to_json) add_namespaces_for_dachsfisch_node(dachsfisch_node, xml) xml << xml_snippet end |
#add_description_to_xml(xml, description) ⇒ Object
22 23 24 |
# File 'lib/proformaxml/helpers/export_helpers.rb', line 22 def add_description_to_xml(xml, description) xml.send(:description, description) if description.present? end |
#add_namespaces_for_dachsfisch_node(dachsfisch_node, xml) ⇒ Object
50 51 52 53 54 |
# File 'lib/proformaxml/helpers/export_helpers.rb', line 50 def add_namespaces_for_dachsfisch_node(dachsfisch_node, xml) dachsfisch_node.reject {|k| k == '@@order' }.flat_map {|_, val| val['@xmlns'].to_a }.uniq.each do |namespace| xml.doc.root.add_namespace(namespace[0], namespace[1]) unless namespace[0] == '$' end end |
#add_parent_uuid_and_lang_to_header(header) ⇒ Object
45 46 47 48 |
# File 'lib/proformaxml/helpers/export_helpers.rb', line 45 def add_parent_uuid_and_lang_to_header(header) header['lang'] = @task.language if @task.language.present? header['parent-uuid'] = @task.parent_uuid if @task.parent_uuid.present? end |
#add_test_configuration(xml, test) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/proformaxml/helpers/export_helpers.rb', line 26 def add_test_configuration(xml, test) xml.send(:'test-configuration') do add_filerefs(xml, test) if test.files add_dachsfisch_node(xml, test.configuration) add_dachsfisch_node(xml, test.) end end |
#attach_file(xml, file) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/proformaxml/helpers/export_helpers.rb', line 6 def attach_file(xml, file) if file. (file, xml) else xml.send "attached-#{file.binary ? 'bin' : 'txt'}-file", file.filename end end |
#embed_file(file, xml) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/proformaxml/helpers/export_helpers.rb', line 14 def (file, xml) if file.binary xml.send :'embedded-bin-file', {filename: file.filename}, Base64.encode64(file.content) else xml.send :'embedded-txt-file', {filename: file.filename}, file.content end end |