Sha256: 12bbd0ffbcfaa954bad8adc3c5f38c9a21522a8b7342a6cf6b729f5eeb1b13f8

Contents?: true

Size: 1.52 KB

Versions: 6

Compression:

Stored size: 1.52 KB

Contents

module FCI
  def build_folder_xml(folder)
    attr = folder.attributes

    folder_xml = Nokogiri::XML::Builder.new do |xml|
      xml.root {
        # id - id of the original folder
        xml.folder(id: folder.id, position: attr[:position], identifier: 'folder', type: 'document') {
          xml.name {
            xml.cdata attr[:name]
          }
          xml.description {
            xml.cdata attr[:description]
          }
        }
      }
    end

    return folder_xml
  end

  def build_article_xml(article)
    attr = article.attributes

    article_xml = Nokogiri::XML::Builder.new do |xml|
      xml.root {
        # id - id of the original acticle
        # folder_id - id of the original folder
        xml.article(id: article.id, folder_id: attr[:folder_id], position: attr[:position], identifier: 'article', type: 'document') {
          xml.title {
            xml.cdata attr[:title]
          }
          xml.description {
            xml.cdata attr[:description]
          }
        }
      }
    end

    return article_xml
  end

  def build_folder_hash(folder)
    attr = folder.attributes

    return {
      id:          folder.id,
      position:    attr[:position],
      name:        attr[:name],
      description: attr[:description],
    }
  end

  def build_article_hash(article)
    attr = article.attributes

    return {
      id:          article.id,
      folder_id:   attr[:folder_id],
      position:    attr[:position],
      title:       attr[:title],
      description: attr[:description],
    }
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
fci-0.0.6 lib/fci/import.rb
fci-0.0.5 lib/fci/import.rb
fci-0.0.4 lib/fci/import.rb
fci-0.0.3 lib/fci/import.rb
fci-0.0.2 lib/fci/import.rb
fci-0.0.1 lib/fci/import.rb