Skip to content

Commit

Permalink
readme tweakerz
Browse files Browse the repository at this point in the history
  • Loading branch information
gotascii committed Oct 22, 2009
1 parent 000aaf2 commit 60b7786
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions README.rdoc
Expand Up @@ -14,7 +14,7 @@ The basic importer has a name, file, and a foreach block.
end end
end end


simple_importer uses fastercsv, which replaces the csv standard lib in ruby1.9. Importers have configuration options that match those of fastercsv. The foreach block is called for each row in the csv file. The argument passed into the foreach block is a fastercsv row created with the specified configuration options. simple_importer uses fastercsv, which replaces the csv standard lib in ruby1.9. Importers have configuration options that match those of fastercsv. The foreach block is called for each row in the csv file. The argument passed into the foreach block is a fastercsv row created with the specified configuration.


importer :items do importer :items do
file 'items.csv' file 'items.csv'
Expand Down Expand Up @@ -46,6 +46,7 @@ Importers have a default configuration that matches the following importer.
header_converters :symbol header_converters :symbol
skip_blanks false skip_blanks false
force_quotes false force_quotes false
# end default configuration


foreach do |row| foreach do |row|
Item.create(:name => row[:name]) Item.create(:name => row[:name])
Expand All @@ -54,7 +55,7 @@ Importers have a default configuration that matches the following importer.


== Before callback == Before callback


Define before_filter-style callbacks in the form of the before block. This block is run once before the importer run. Define before_filter-style callbacks in the form of the before block. This block is run once before the importer runs.


importer :items do importer :items do
file 'items.csv' file 'items.csv'
Expand Down Expand Up @@ -110,12 +111,12 @@ Nest the foreach block to give your row processing block access to foreach_file


== Loading and running importers == Loading and running importers


simple_importer provides a method that will find and load importer definitions in importers, lib/importers, and app/importers directories. simple_importer provides a method that will find and load importer definitions in the importers, lib/importers, and app/importers directories.


# importer definition is in lib/importers/item.rb # importer definition is in lib/importers/item.rb
SimpleImporter.find_importers SimpleImporter.find_importers


SimpleImporter has a collection of importers and each importer can be run once it has been loaded. SimpleImporter now has a collection of importers and each importer can be run now that it has been loaded.


# the following will fire off the actual importers # the following will fire off the actual importers
SimpleImporter.importers.each do |importer| SimpleImporter.importers.each do |importer|
Expand Down

0 comments on commit 60b7786

Please sign in to comment.