Created
September 22, 2010 16:41
-
-
Save yortz/592042 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test_helper' | |
class Shop < ActiveRecord::Base | |
end | |
class ItemDetail < ActiveRecord::Base | |
set_primary_key :id | |
data_miner do | |
import 'A csv file with no identifier', :url => 'http://imports.s3.amazonaws.com/products_no_id.csv', :errata => 'http://spreadsheets.google.com/pub?key=tF58sAgqkY214EFBMdYCIUw', :delimiter => ';' do | |
# shop = Shop.find_by_user_id(98765) | |
key 'id', :synthesize => lambda { |row| 0.upto(row.size) { |i| i } } | |
store 'title', :field_name => 'Nome*' | |
store 'description', :field_name => 'Descrizione' | |
end | |
end | |
end | |
# todo: have somebody properly organize these | |
class DataMinerTest < Test::Unit::TestCase | |
if ENV['ALL'] == 'true' or ENV['CUSTOM'] == 'true' | |
should 'import csv with no identifier' do | |
ItemDetail.run_data_miner! | |
assert ItemDetail.count > 0 | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActiveRecord::Schema.define(:version => 20090819143429) do | |
create_table 'item_details', :force => true, :options => 'ENGINE=InnoDB default charset=utf8' do |t| | |
t.string "title", :limit => 64 | |
t.text "description", :limit => 2147483647 | |
t.integer "duration", :default => 15 | |
t.decimal "price", :precision => 15, :scale => 2, :default => 0.0 | |
t.decimal "increase", :precision => 10, :scale => 2, :default => 1.0 | |
t.decimal "buy_it_now", :precision => 15, :scale => 2, :default => 0.0 | |
t.string "city", :limit => 50 | |
t.string "country", :limit => 2 | |
t.boolean "autorelist", :default => true | |
t.string "permalink", :limit => 64 | |
t.boolean "accept_offers", :default => true | |
t.string "languages", :limit => 32, :default => "" | |
t.integer "category_id" | |
t.integer "shop_category_id" | |
t.integer "quantity", :default => 1 | |
t.string "all_categories" | |
t.string "all_shop_categories" | |
t.string "product_code", :limit => 64 | |
t.string "bar_code", :limit => 64 | |
end | |
create_table 'shops', :force => true, :options => 'ENGINE=InnoDB default charset=utf8' do |t| | |
t.string "user_id" | |
t.datetime 'updated_at' | |
t.datetime 'created_at' | |
end | |
execute 'INSERT INTO shops (id, user_id) VALUES (12345, 98765);' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment