Project

muffins

0.0
No commit activity in last 3 years
No release in over 3 years
An Object to XML/HTML mapping library using Virtus and Nokogiri
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.9.2
~> 2.7.0

Runtime

~> 1.5.5
~> 0.5.1
 Project Readme

Muffins

travis

A Nokogiri-based Object to XML/HTML mapping library.

Installation

gem install muffins

Examples

##XML

<books>
  <book>
    <asin>1400079985</asin>
    <item_attributes>
      <title>War and Peace (Vintage Classics)</title>
      <author>Leo Tolstoy</author>
      <EAN>9781400079988</EAN>
      <release_date>2008-12-02</release_date>
    </item_attributes>
    <reviews>
      <editorial_review>ZOMG.</editorial_review>
    </reviews>
    <similar_products>
      <similar_product>
        <title>Anna Karenina</title>
        <EAN>9780143035008</EAN>
      </similar_product>
    </similar_products>
  </book>
</books>

##Map XML

Primary class:

    class Book

      include Muffins

      path 'book'

      map :asin, String

      within :item_attributes do |attributes|
        attributes.map :title, String
        attributes.map :author, String, :collection => true
        attributes.map :ean, String, :to => 'EAN'
        attributes.map :release_date, Date
      end

      map :editorial_review, String, :within => :reviews

    end

##Usage

    Book.parse(xml)

returns:

    [#<Book:0x233ebe8 @asin='1400079985', @title="War and Peace (Vintage Classics)", @author="Leo Tolstoy", @ean="9781400079988", @release_date=Tue, 02 Dec 2008, @editorial_review='ZOMG.', :similar_products=[#<Product:0x234ebe9 @title='Anna Karenina', @ean='9780143035008'>]>]