Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ADD: Added home page for gem

  • Loading branch information...
commit c838e9c4857694396d85cd9bb33d9473d3a53be4 1 parent 4b6072f
@michael-harrison authored
Showing with 1 addition and 180 deletions.
  1. +0 −179 README.textile
  2. +1 −1  xml_active.gemspec
View
179 README.textile
@@ -1,179 +0,0 @@
-h1. XML Active
-
-Rails has some really fantastic features for serialisation of ActiveRecord to XML however going back the other way is not so fantastic. XML Active aims to provide the import of XML into your database while utilising the strengths of ActiveRecord. It extends ActiveRecord allowing it to seamlessly work in with your model. Here are the features provided by XML Active:
-
-* Updating of records based on an XML document containing elements matching primary key
-* Creation of records based on elements in an XML
-* Removal of records based on an XML document containing elements matching primary key
-* Choose to only update, only create or only remove records
-* Choose to combine update, create and remove actions
-* Synchronise your database with an XML Document
-
-h2. The Background
-
-h3. XML Documents
-
-XML Active relies on the XML documents created by ActiveRecord in that it utilises the element attributes and document layout. Following is a sample of an XML document. Note the @type@ attribute which helps to identify elements that are integers, arrays, etc.
-
-<pre>
-<books type="array">
- <book>
- <id type="Integer">4</id>
- <name>Book 1</name>
- </book>
- <book>
- <id type="integer">5</id>
- <name>Book 1</name>
- <chapters type="array">
- <chapter>
- <id type="integer">1</id>
- <title>Chapter 1</title>
- <introduction>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus purus nulla, condimentum vitae hendrerit nec, blandit et felis. Suspendisse vulputate mollis suscipit. Vivamus non libero quis urna gravida euismod quis in nisi. Morbi turpis orci, posuere nec ultrices ut, egestas ac purus. Morbi id pretium erat. In ullamcorper, ligula id porta pellentesque, sem turpis ultricies libero, non elementum ipsum neque at dui. Donec auctor nulla id mi dapibus id faucibus felis mollis. Curabitur imperdiet tristique nisi, consectetur molestie purus accumsan id. Curabitur lacinia diam et nisl iaculis eleifend. Quisque turpis elit, volutpat eget dapibus sed, egestas nec leo. Mauris dignissim tellus non lorem fringilla pharetra.</introduction>
- <pages type="array">
- <page>
- <id type="integer">1</id>
- <content>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus purus nulla, condimentum vitae hendrerit nec, blandit et felis. Suspendisse vulputate mollis suscipit. Vivamus non libero quis urna gravida euismod quis in nisi. Morbi turpis orci, posuere nec ultrices ut, egestas ac purus. Morbi id pretium erat. In ullamcorper, ligula id porta pellentesque, sem turpis ultricies libero, non elementum ipsum neque at dui. Donec auctor nulla id mi dapibus id faucibus felis mollis. Curabitur imperdiet tristique nisi, consectetur molestie purus accumsan id. Curabitur lacinia diam et nisl iaculis eleifend. Quisque turpis elit, volutpat eget dapibus sed, egestas nec leo. Mauris dignissim tellus non lorem fringilla pharetra.</content>
- <number>1</number>
- </page>
- <page>
- <id type="integer">2</id>
- <content>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus purus nulla, condimentum vitae hendrerit nec, blandit et felis. Suspendisse vulputate mollis suscipit. Vivamus non libero quis urna gravida euismod quis in nisi. Morbi turpis orci, posuere nec ultrices ut, egestas ac purus. Morbi id pretium erat. In ullamcorper, ligula id porta pellentesque, sem turpis ultricies libero, non elementum ipsum neque at dui. Donec auctor nulla id mi dapibus id faucibus felis mollis. Curabitur imperdiet tristique nisi, consectetur molestie purus accumsan id. Curabitur lacinia diam et nisl iaculis eleifend. Quisque turpis elit, volutpat eget dapibus sed, egestas nec leo. Mauris dignissim tellus non lorem fringilla pharetra.</content>
- <number>2</number>
- </page>
- <page>
- <id type="integer">3</id>
- <content>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus purus nulla, condimentum vitae hendrerit nec, blandit et felis. Suspendisse vulputate mollis suscipit. Vivamus non libero quis urna gravida euismod quis in nisi. Morbi turpis orci, posuere nec ultrices ut, egestas ac purus. Morbi id pretium erat. In ullamcorper, ligula id porta pellentesque, sem turpis ultricies libero, non elementum ipsum neque at dui. Donec auctor nulla id mi dapibus id faucibus felis mollis. Curabitur imperdiet tristique nisi, consectetur molestie purus accumsan id. Curabitur lacinia diam et nisl iaculis eleifend. Quisque turpis elit, volutpat eget dapibus sed, egestas nec leo. Mauris dignissim tellus non lorem fringilla pharetra.</content>
- <number>3</number>
- </page>
- </pages>
- </chapter>
- <chapter>
- <id type="integer">2</id>
- <title>Chapter 2</title>
- <introduction>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus purus nulla, condimentum vitae hendrerit nec, blandit et felis. Suspendisse vulputate mollis suscipit. Vivamus non libero quis urna gravida euismod quis in nisi. Morbi turpis orci, posuere nec ultrices ut, egestas ac purus. Morbi id pretium erat. In ullamcorper, ligula id porta pellentesque, sem turpis ultricies libero, non elementum ipsum neque at dui. Donec auctor nulla id mi dapibus id faucibus felis mollis. Curabitur imperdiet tristique nisi, consectetur molestie purus accumsan id. Curabitur lacinia diam et nisl iaculis eleifend. Quisque turpis elit, volutpat eget dapibus sed, egestas nec leo. Mauris dignissim tellus non lorem fringilla pharetra.</introduction>
- <pages type="array">
- <page>
- <id type="integer">5</id>
- <content>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus purus nulla, condimentum vitae hendrerit nec, blandit et felis. Suspendisse vulputate mollis suscipit. Vivamus non libero quis urna gravida euismod quis in nisi. Morbi turpis orci, posuere nec ultrices ut, egestas ac purus. Morbi id pretium erat. In ullamcorper, ligula id porta pellentesque, sem turpis ultricies libero, non elementum ipsum neque at dui. Donec auctor nulla id mi dapibus id faucibus felis mollis. Curabitur imperdiet tristique nisi, consectetur molestie purus accumsan id. Curabitur lacinia diam et nisl iaculis eleifend. Quisque turpis elit, volutpat eget dapibus sed, egestas nec leo. Mauris dignissim tellus non lorem fringilla pharetra.</content>
- <number>1</number>
- </page>
- <page>
- <id type="integer">6</id>
- <content>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus purus nulla, condimentum vitae hendrerit nec, blandit et felis. Suspendisse vulputate mollis suscipit. Vivamus non libero quis urna gravida euismod quis in nisi. Morbi turpis orci, posuere nec ultrices ut, egestas ac purus. Morbi id pretium erat. In ullamcorper, ligula id porta pellentesque, sem turpis ultricies libero, non elementum ipsum neque at dui. Donec auctor nulla id mi dapibus id faucibus felis mollis. Curabitur imperdiet tristique nisi, consectetur molestie purus accumsan id. Curabitur lacinia diam et nisl iaculis eleifend. Quisque turpis elit, volutpat eget dapibus sed, egestas nec leo. Mauris dignissim tellus non lorem fringilla pharetra.</content>
- <number>2</number>
- </page>
- <page>
- <id type="integer">7</id>
- <content>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus purus nulla, condimentum vitae hendrerit nec, blandit et felis. Suspendisse vulputate mollis suscipit. Vivamus non libero quis urna gravida euismod quis in nisi. Morbi turpis orci, posuere nec ultrices ut, egestas ac purus. Morbi id pretium erat. In ullamcorper, ligula id porta pellentesque, sem turpis ultricies libero, non elementum ipsum neque at dui. Donec auctor nulla id mi dapibus id faucibus felis mollis. Curabitur imperdiet tristique nisi, consectetur molestie purus accumsan id. Curabitur lacinia diam et nisl iaculis eleifend. Quisque turpis elit, volutpat eget dapibus sed, egestas nec leo. Mauris dignissim tellus non lorem fringilla pharetra.</content>
- <number>3</number>
- </page>
- <page>
- <id type="integer">8</id>
- <content>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus purus nulla, condimentum vitae hendrerit nec, blandit et felis. Suspendisse vulputate mollis suscipit. Vivamus non libero quis urna gravida euismod quis in nisi. Morbi turpis orci, posuere nec ultrices ut, egestas ac purus. Morbi id pretium erat. In ullamcorper, ligula id porta pellentesque, sem turpis ultricies libero, non elementum ipsum neque at dui. Donec auctor nulla id mi dapibus id faucibus felis mollis. Curabitur imperdiet tristique nisi, consectetur molestie purus accumsan id. Curabitur lacinia diam et nisl iaculis eleifend. Quisque turpis elit, volutpat eget dapibus sed, egestas nec leo. Mauris dignissim tellus non lorem fringilla pharetra.</content>
- <number>4</number>
- </page>
- </pages>
- </chapter>
- </chapters>
- </book>
- <book>
- <id type="integer">6</id>
- <name>Book 1</name>
- </book>
-</books>
-</code>
-</pre>
-
-h3. Database Schema
-
-XML Active will detect the primary key of the tables in your schema even if is a name other than @id@. It will use the primary key to match records for update or deletion or creation when they don't exist. Given this it's very important that the tables that you wish to synchronise have a primary key with auto increment. The good news is by default Rails will create a primary key field called @id@ that is auto-increment. At this time XML Active doesn't support compound primary keys.
-
-h3. The Model
-
-In order to identify the relationships XML Active it relies on associations so you have to make sure you define your associations in your model. Following are is a sample model.
-
-@book.rb@
-<pre>
-class Book < ActiveRecord::Base
- has_many :chapters, :dependent => :destroy
-end
-</pre>
-
-@chapter.rb@
-<pre>
-class Chapter < ActiveRecord::Base
- has_many :pages, :dependent => :destroy
- belongs_to :book
-end
-</pre>
-
-@page.rb@
-<pre>
-class Page < ActiveRecord::Base
- belongs_to :chapter
-end
-</pre>
-
-At this stage XML Active has been tested with a limited number of associations. It is hoped in the future that a more complete set of tests will exist.
-
-h2. Examples
-
-Now to the meaty part, the examples. XML Active currenly uses "Nokogiri":http://nokogiri.org/ to do its XML parsing so you can provide either a @Nokogiri::XML::Element@ or raw XML.
-
-h3. New Functions
-
-XML Active extends the ActiveRecord class giving you the following functions:
-
-@many_from_xml(xml, options)@
-Allows for the import of many records based on an XML document. This function expects an XML document similar to the following with many records in it:
-@books_changed.xml@
-<pre>
-<books type="array">
- <book>
- <id type="Integer">4</id>
- <name>Book 1</name>
- </book>
- <book>
- <id type="integer">5</id>
- <name>Book 1</name>
- </book>
- <book>
- <id type="integer">6</id>
- <name>Book 1</name>
- </book>
-</books>
-</pre>
-
-Following is an example:
-<pre>
-Book.many_from_xml File.open("books_changed.xml").read, [:update]
-</pre>
-
-@one_from_xml(xml, options)@
-Allows for the import of one record based on an XML document. This function expects an XML document similar to the following with many records in it:
-
-@one_book_changed.xml@
-<pre>
-<book>
- <id type="Integer">4</id>
- <name>Book 1</name>
-</book>
-</pre>
-
-Following is an example:
-<pre>
-Book.one_from_xml File.open("one_book_changed.xml").read, [:update]
-</pre>
-
-h3. Options
-
-You can combine any of the options (:create, :update or :destroy) and XML Active will only perform the actions provided in the options. However if you use the :sync option then all other options are ignored. Following are the current options:
-
-* @:update@ records in the database that match those in the provided XML document based on classes in the model, associations and the primary key.
-
-* @:create@ records in the database that exist in the provided XML document but not in the database. Matching is based on classes in the model, associations and the primary key.
-
-* @:destroy@ records in the database that don't exist in the provided XML document. Matching is based on classes in the model, associations and the primary key. This respects validation by using the ActiveRecord destroy rather than delete.
-
-* @:sync@ is really the combination of :create, :update and :destroy. Using this option will cause XML Active to ignore :create, :update and :destroy options and will proceed to make your database records match those in the XML document.
-
View
2  xml_active.gemspec
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
s.version = XmlActive::VERSION
s.authors = ["Michael Harrison"]
s.email = ["michael@focalpause.com"]
- s.homepage = ""
+ s.homepage = "https://github.com/michael-harrison/xml_active"
s.summary = "xml_active #{s.version}"
s.description = %q{XML Active is an extension of ActiveRecord that provides features to synchronise an ActiveRecord Model with a supplied XML document}
Please sign in to comment.
Something went wrong with that request. Please try again.