-
Notifications
You must be signed in to change notification settings - Fork 10
Notes
*Don't take this too seriously, this document is only for my benefit, it's all a work in progress, etc :-)
This plugin is intended to compliment the rails_admin export function. It is intended to allow the user to import data from a variety of file formats.
- CSV, delimited by comma. Should we support semi-colon and tab delimited CSV? Technically not CSV...
- JSON
- XML
- YAML *Note that this format is not supported by rails_admin_export (but it should be!)
- RSS *See section below
This particular fork also allows for the configuration of a 'key' field, which determines if a record is new, wherein a new record should be created, or if the record already exists and should only be updated.
Currently, the only working file format is comma delimited CSV files.
RSS files must be handled as a special case. Other file formats allow one to serialize data isomorphically. RSS, however, imposes a strict structure and therefore, a mapping between item fields must be established. For every <item>
in an RSS file, there exists:
- The title of the item
<title>
- A description of the item
<description>
- A link to that item
<link>
- A unique identifier
<guid>
- The data published
<pubDate>
Given a ActiveRecord
create_table "posts", :force => true do |t|
t.string "post_title", :null => false
t.text "post_body", :null => false
t.datetime "published_at"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "edited_at", :null => false
end
This is how you might map records to RSS items
RailsAdminImport.config do |config|
rss_mapping do
{
:title => Proc.new{ |item| item.title + item.published.to_s },
:body => Proc.new{ |item| item.summary },
:published_at => Proc.new{ |item| item.published }
}
end
end