Sha256: cea4d564a3612c8c21cbd72f48d747eb670fe77e46879ef08bcfd6c2465477e5

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

module ZCI
  def parse_category_xml(xml_file)
    doc = Nokogiri::XML.parse(xml_file)
    category_xml = doc.xpath("//category").first

    {
      id: category_xml[:id],
      name: category_xml.xpath('name').text,
      description: category_xml.xpath('description').text,
      position: category_xml[:position],
    }
  end

  def parse_section_xml(xml_file)
    doc = Nokogiri::XML.parse(xml_file)
    section_xml = doc.xpath("//section").first

    {
      id: section_xml[:id],
      category_id: section_xml[:category_id],
      name: section_xml.xpath('name').text,
      description: section_xml.xpath('description').text,
      position: section_xml[:position],
    }
  end

  def parse_article_xml(xml_file)
    doc = Nokogiri::XML.parse(xml_file)
    article_xml = doc.xpath('//article').first

    {
      id: article_xml[:id],
      section_id: article_xml[:section_id],
      title: article_xml.xpath('title').text,
      body: article_xml.xpath('body').text,
      position: article_xml[:position],
    }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
zci-0.11.0 lib/zci/export.rb
zci-0.10.1 lib/zci/export.rb
zci-0.10.0 lib/zci/export.rb