datashift 0.1.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -5
- data/LICENSE.txt +26 -26
- data/README.markdown +305 -303
- data/README.rdoc +19 -19
- data/Rakefile +93 -93
- data/VERSION +1 -1
- data/datashift-0.1.0.gem +0 -0
- data/datashift.gemspec +152 -136
- data/lib/applications/jruby/jexcel_file.rb +408 -408
- data/lib/applications/jruby/word.rb +79 -79
- data/lib/datashift.rb +152 -152
- data/lib/datashift/exceptions.rb +11 -11
- data/lib/datashift/file_definitions.rb +353 -353
- data/lib/datashift/mapping_file_definitions.rb +87 -87
- data/lib/datashift/method_detail.rb +275 -275
- data/lib/datashift/method_dictionary.rb +209 -209
- data/lib/datashift/method_mapper.rb +90 -90
- data/lib/generators/csv_generator.rb +36 -36
- data/lib/generators/excel_generator.rb +122 -122
- data/lib/generators/generator_base.rb +13 -13
- data/lib/helpers/core_ext/to_b.rb +24 -24
- data/lib/helpers/spree_helper.rb +153 -155
- data/lib/java/poi-3.7/LICENSE +507 -507
- data/lib/java/poi-3.7/NOTICE +21 -21
- data/lib/java/poi-3.7/RELEASE_NOTES.txt +115 -115
- data/lib/loaders/csv_loader.rb +98 -98
- data/lib/loaders/excel_loader.rb +155 -155
- data/lib/loaders/loader_base.rb +420 -420
- data/lib/loaders/spreadsheet_loader.rb +136 -136
- data/lib/loaders/spree/image_loader.rb +63 -64
- data/lib/loaders/spree/product_loader.rb +248 -250
- data/public/spree/products/large/DEMO_001_ror_bag.jpeg +0 -0
- data/public/spree/products/large/DEMO_002_Powerstation.jpg +0 -0
- data/public/spree/products/large/DEMO_003_ror_mug.jpeg +0 -0
- data/public/spree/products/mini/DEMO_001_ror_bag.jpeg +0 -0
- data/public/spree/products/mini/DEMO_002_Powerstation.jpg +0 -0
- data/public/spree/products/mini/DEMO_003_ror_mug.jpeg +0 -0
- data/public/spree/products/original/DEMO_001_ror_bag.jpeg +0 -0
- data/public/spree/products/original/DEMO_002_Powerstation.jpg +0 -0
- data/public/spree/products/original/DEMO_003_ror_mug.jpeg +0 -0
- data/public/spree/products/product/DEMO_001_ror_bag.jpeg +0 -0
- data/public/spree/products/product/DEMO_002_Powerstation.jpg +0 -0
- data/public/spree/products/product/DEMO_003_ror_mug.jpeg +0 -0
- data/public/spree/products/small/DEMO_001_ror_bag.jpeg +0 -0
- data/public/spree/products/small/DEMO_002_Powerstation.jpg +0 -0
- data/public/spree/products/small/DEMO_003_ror_mug.jpeg +0 -0
- data/spec/csv_loader_spec.rb +30 -30
- data/spec/datashift_spec.rb +26 -26
- data/spec/db/migrate/20110803201325_create_test_bed.rb +85 -85
- data/spec/excel_exporter_spec.rb +78 -78
- data/spec/excel_generator_spec.rb +78 -78
- data/spec/excel_loader_spec.rb +223 -223
- data/spec/file_definitions.rb +141 -141
- data/spec/fixtures/ProjectsDefaults.yml +29 -29
- data/spec/fixtures/config/database.yml +27 -24
- data/spec/fixtures/datashift_Spree_db.sqlite +0 -0
- data/spec/fixtures/interact_models_db.sqlite +0 -0
- data/spec/fixtures/negative/SpreeProdMiss1Mandatory.csv +4 -4
- data/spec/fixtures/negative/SpreeProdMissManyMandatory.csv +4 -4
- data/spec/fixtures/spree/SpreeProducts.csv +4 -4
- data/spec/fixtures/spree/SpreeProductsMultiColumn.csv +4 -4
- data/spec/fixtures/spree/SpreeProductsSimple.csv +4 -4
- data/spec/fixtures/spree/SpreeProductsWithImages.csv +4 -0
- data/spec/fixtures/spree/SpreeZoneExample.csv +5 -5
- data/spec/fixtures/test_model_defs.rb +57 -57
- data/spec/loader_spec.rb +120 -120
- data/spec/method_dictionary_spec.rb +242 -242
- data/spec/method_mapper_spec.rb +41 -41
- data/spec/spec_helper.rb +116 -116
- data/spec/spree_generator_spec.rb +64 -64
- data/spec/spree_loader_spec.rb +324 -327
- data/spec/spree_method_mapping_spec.rb +214 -214
- data/tasks/config/seed_fu_product_template.erb +15 -15
- data/tasks/config/tidy_config.txt +12 -12
- data/tasks/db_tasks.rake +65 -65
- data/tasks/excel_generator.rake +78 -78
- data/tasks/file_tasks.rake +36 -36
- data/tasks/import/csv.rake +49 -49
- data/tasks/import/excel.rake +71 -71
- data/tasks/spree/image_load.rake +108 -108
- data/tasks/spree/product_loader.rake +43 -43
- data/tasks/word_to_seedfu.rake +166 -166
- data/test/helper.rb +18 -18
- data/test/test_interact.rb +7 -7
- metadata +22 -3
- data/spec/fixtures/interact_spree_db.sqlite +0 -0
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/spec/csv_loader_spec.rb
CHANGED
@@ -1,31 +1,31 @@
|
|
1
|
-
# Copyright:: (c) Autotelik Media Ltd 2011
|
2
|
-
# Author :: Tom Statter
|
3
|
-
# Date :: Aug 2011
|
4
|
-
# License:: MIT
|
5
|
-
#
|
6
|
-
# Details:: Specs for Excel aspect of Active Record Loader
|
7
|
-
#
|
8
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
9
|
-
|
10
|
-
require 'erb'
|
11
|
-
require 'excel_loader'
|
12
|
-
|
13
|
-
describe 'CSV Loader' do
|
14
|
-
|
15
|
-
before(:all) do
|
16
|
-
|
17
|
-
# load our test model definitions - Project etc
|
18
|
-
require File.join($DataShiftFixturePath, 'test_model_defs')
|
19
|
-
|
20
|
-
db_connect( 'test_file' ) # , test_memory, test_mysql
|
21
|
-
migrate_up
|
22
|
-
@klazz = Project
|
23
|
-
end
|
24
|
-
|
25
|
-
before(:each) do
|
26
|
-
MethodDictionary.clear
|
27
|
-
MethodDictionary.find_operators( @klazz )
|
28
|
-
MethodDictionary.find_operators( @assoc_klazz )
|
29
|
-
end
|
30
|
-
|
1
|
+
# Copyright:: (c) Autotelik Media Ltd 2011
|
2
|
+
# Author :: Tom Statter
|
3
|
+
# Date :: Aug 2011
|
4
|
+
# License:: MIT
|
5
|
+
#
|
6
|
+
# Details:: Specs for Excel aspect of Active Record Loader
|
7
|
+
#
|
8
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
9
|
+
|
10
|
+
require 'erb'
|
11
|
+
require 'excel_loader'
|
12
|
+
|
13
|
+
describe 'CSV Loader' do
|
14
|
+
|
15
|
+
before(:all) do
|
16
|
+
|
17
|
+
# load our test model definitions - Project etc
|
18
|
+
require File.join($DataShiftFixturePath, 'test_model_defs')
|
19
|
+
|
20
|
+
db_connect( 'test_file' ) # , test_memory, test_mysql
|
21
|
+
migrate_up
|
22
|
+
@klazz = Project
|
23
|
+
end
|
24
|
+
|
25
|
+
before(:each) do
|
26
|
+
MethodDictionary.clear
|
27
|
+
MethodDictionary.find_operators( @klazz )
|
28
|
+
MethodDictionary.find_operators( @assoc_klazz )
|
29
|
+
end
|
30
|
+
|
31
31
|
end
|
data/spec/datashift_spec.rb
CHANGED
@@ -1,27 +1,27 @@
|
|
1
|
-
# Copyright:: (c) Autotelik Media Ltd 2011
|
2
|
-
# Author :: Tom Statter
|
3
|
-
# Date :: Oct 2011
|
4
|
-
# License:: MIT
|
5
|
-
#
|
6
|
-
# Details:: Specs for high level apsects of DataShift library
|
7
|
-
#
|
8
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
9
|
-
|
10
|
-
describe 'DataShift' do
|
11
|
-
|
12
|
-
before(:each) do
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should provide gem version" do
|
16
|
-
DataShift::gem_version
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should provide gem name" do
|
20
|
-
DataShift::gem_name.should == 'datashift'
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should provide root_path" do
|
24
|
-
DataShift.root_path.should_not be_empty
|
25
|
-
end
|
26
|
-
|
1
|
+
# Copyright:: (c) Autotelik Media Ltd 2011
|
2
|
+
# Author :: Tom Statter
|
3
|
+
# Date :: Oct 2011
|
4
|
+
# License:: MIT
|
5
|
+
#
|
6
|
+
# Details:: Specs for high level apsects of DataShift library
|
7
|
+
#
|
8
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
9
|
+
|
10
|
+
describe 'DataShift' do
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should provide gem version" do
|
16
|
+
DataShift::gem_version
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should provide gem name" do
|
20
|
+
DataShift::gem_name.should == 'datashift'
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should provide root_path" do
|
24
|
+
DataShift.root_path.should_not be_empty
|
25
|
+
end
|
26
|
+
|
27
27
|
end
|
@@ -1,85 +1,85 @@
|
|
1
|
-
# Author :: Tom Statter
|
2
|
-
# Date :: Aug 2011
|
3
|
-
# License:: MIT
|
4
|
-
#
|
5
|
-
# Details:: Migration to create a test database that exercises all aspects of Active Record models
|
6
|
-
#
|
7
|
-
|
8
|
-
class CreateTestBed < ActiveRecord::Migration
|
9
|
-
|
10
|
-
def self.up
|
11
|
-
|
12
|
-
# has many :milestones
|
13
|
-
create_table :projects do |t|
|
14
|
-
t.string :title
|
15
|
-
t.string :value_as_string
|
16
|
-
t.text :value_as_text
|
17
|
-
t.boolean :value_as_boolean, :default => false
|
18
|
-
t.datetime :value_as_datetime, :default => nil
|
19
|
-
t.integer :value_as_integer, :default => 0
|
20
|
-
t.decimal :value_as_double, :precision => 8, :scale => 2, :default => 0.0
|
21
|
-
t.timestamps
|
22
|
-
end
|
23
|
-
|
24
|
-
# belongs_to :project, project => has_many
|
25
|
-
create_table :milestones do |t|
|
26
|
-
t.string :name
|
27
|
-
t.datetime :datetime, :default => nil
|
28
|
-
t.decimal :cost, :precision => 8, :scale => 2, :default => 0.0
|
29
|
-
t.references :project
|
30
|
-
t.timestamps
|
31
|
-
end
|
32
|
-
|
33
|
-
# belongs_to :project, project => has_one
|
34
|
-
create_table :owners do |t|
|
35
|
-
t.string :name
|
36
|
-
t.references :project
|
37
|
-
t.timestamps
|
38
|
-
end
|
39
|
-
|
40
|
-
# has_belongs_to_many :project
|
41
|
-
create_table :categories do |t|
|
42
|
-
t.string :reference
|
43
|
-
t.timestamps
|
44
|
-
end
|
45
|
-
|
46
|
-
# testing has_belongs_to_many (hence no id)
|
47
|
-
create_table :categories_projects, :id => false do |t|
|
48
|
-
t.references :category
|
49
|
-
t.references :project
|
50
|
-
end
|
51
|
-
|
52
|
-
create_table :versions do |t|
|
53
|
-
t.string :name
|
54
|
-
t.timestamps
|
55
|
-
end
|
56
|
-
|
57
|
-
# testing project has_many release + versions :through
|
58
|
-
create_table :loader_releases do |t|
|
59
|
-
t.string :name
|
60
|
-
t.references :project
|
61
|
-
t.references :version
|
62
|
-
t.timestamps
|
63
|
-
end
|
64
|
-
|
65
|
-
|
66
|
-
create_table :long_and_complex_table_linked_to_versions do |t|
|
67
|
-
t.references :version
|
68
|
-
end
|
69
|
-
|
70
|
-
create_table :empties do |t|
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
def self.down
|
76
|
-
drop_table :projects
|
77
|
-
drop_table :categories
|
78
|
-
drop_table :loader_releases
|
79
|
-
drop_table :versions
|
80
|
-
drop_table :categories_projectss
|
81
|
-
drop_table :milestones
|
82
|
-
drop_table :long_and_complex_table_linked_to_versions
|
83
|
-
drop_table :empties
|
84
|
-
end
|
85
|
-
end
|
1
|
+
# Author :: Tom Statter
|
2
|
+
# Date :: Aug 2011
|
3
|
+
# License:: MIT
|
4
|
+
#
|
5
|
+
# Details:: Migration to create a test database that exercises all aspects of Active Record models
|
6
|
+
#
|
7
|
+
|
8
|
+
class CreateTestBed < ActiveRecord::Migration
|
9
|
+
|
10
|
+
def self.up
|
11
|
+
|
12
|
+
# has many :milestones
|
13
|
+
create_table :projects do |t|
|
14
|
+
t.string :title
|
15
|
+
t.string :value_as_string
|
16
|
+
t.text :value_as_text
|
17
|
+
t.boolean :value_as_boolean, :default => false
|
18
|
+
t.datetime :value_as_datetime, :default => nil
|
19
|
+
t.integer :value_as_integer, :default => 0
|
20
|
+
t.decimal :value_as_double, :precision => 8, :scale => 2, :default => 0.0
|
21
|
+
t.timestamps
|
22
|
+
end
|
23
|
+
|
24
|
+
# belongs_to :project, project => has_many
|
25
|
+
create_table :milestones do |t|
|
26
|
+
t.string :name
|
27
|
+
t.datetime :datetime, :default => nil
|
28
|
+
t.decimal :cost, :precision => 8, :scale => 2, :default => 0.0
|
29
|
+
t.references :project
|
30
|
+
t.timestamps
|
31
|
+
end
|
32
|
+
|
33
|
+
# belongs_to :project, project => has_one
|
34
|
+
create_table :owners do |t|
|
35
|
+
t.string :name
|
36
|
+
t.references :project
|
37
|
+
t.timestamps
|
38
|
+
end
|
39
|
+
|
40
|
+
# has_belongs_to_many :project
|
41
|
+
create_table :categories do |t|
|
42
|
+
t.string :reference
|
43
|
+
t.timestamps
|
44
|
+
end
|
45
|
+
|
46
|
+
# testing has_belongs_to_many (hence no id)
|
47
|
+
create_table :categories_projects, :id => false do |t|
|
48
|
+
t.references :category
|
49
|
+
t.references :project
|
50
|
+
end
|
51
|
+
|
52
|
+
create_table :versions do |t|
|
53
|
+
t.string :name
|
54
|
+
t.timestamps
|
55
|
+
end
|
56
|
+
|
57
|
+
# testing project has_many release + versions :through
|
58
|
+
create_table :loader_releases do |t|
|
59
|
+
t.string :name
|
60
|
+
t.references :project
|
61
|
+
t.references :version
|
62
|
+
t.timestamps
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
create_table :long_and_complex_table_linked_to_versions do |t|
|
67
|
+
t.references :version
|
68
|
+
end
|
69
|
+
|
70
|
+
create_table :empties do |t|
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.down
|
76
|
+
drop_table :projects
|
77
|
+
drop_table :categories
|
78
|
+
drop_table :loader_releases
|
79
|
+
drop_table :versions
|
80
|
+
drop_table :categories_projectss
|
81
|
+
drop_table :milestones
|
82
|
+
drop_table :long_and_complex_table_linked_to_versions
|
83
|
+
drop_table :empties
|
84
|
+
end
|
85
|
+
end
|
data/spec/excel_exporter_spec.rb
CHANGED
@@ -1,79 +1,79 @@
|
|
1
|
-
# Copyright:: (c) Autotelik Media Ltd 2011
|
2
|
-
# Author :: Tom Statter
|
3
|
-
# Date :: Aug 2011
|
4
|
-
# License:: MIT
|
5
|
-
#
|
6
|
-
# Details:: Specs for Excel aspect of Active Record Loader
|
7
|
-
#
|
8
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
9
|
-
|
10
|
-
if(Guards::jruby?)
|
11
|
-
require 'erb'
|
12
|
-
require 'excel_generator'
|
13
|
-
|
14
|
-
include DataShift
|
15
|
-
|
16
|
-
describe 'Excel Generator' do
|
17
|
-
|
18
|
-
before(:all) do
|
19
|
-
db_connect( 'test_file' ) # , test_memory, test_mysql
|
20
|
-
|
21
|
-
# load our test model definitions - Project etc
|
22
|
-
require File.join($DataShiftFixturePath, 'test_model_defs')
|
23
|
-
|
24
|
-
# handle migration changes or reset of test DB
|
25
|
-
migrate_up
|
26
|
-
|
27
|
-
db_clear() # todo read up about proper transactional fixtures
|
28
|
-
results_clear()
|
29
|
-
|
30
|
-
@klazz = Project
|
31
|
-
@assoc_klazz = Category
|
32
|
-
end
|
33
|
-
|
34
|
-
before(:each) do
|
35
|
-
MethodDictionary.clear
|
36
|
-
MethodDictionary.find_operators( @klazz )
|
37
|
-
MethodDictionary.find_operators( @assoc_klazz )
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should be able to create a new excel generator" do
|
41
|
-
generator = ExcelGenerator.new( 'dummy.xls' )
|
42
|
-
|
43
|
-
generator.should_not be_nil
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should generate template .xls file from model" do
|
47
|
-
|
48
|
-
expect = result_file('project_template_spec.xls')
|
49
|
-
|
50
|
-
gen = ExcelGenerator.new( expect )
|
51
|
-
|
52
|
-
gen.generate(Project)
|
53
|
-
|
54
|
-
File.exists?(expect).should be_true
|
55
|
-
|
56
|
-
puts "Can manually check file @ #{expect}"
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should export a simple model to .xls spreedsheet" do
|
60
|
-
|
61
|
-
Project.create( :value_as_string => 'Value as Text', :value_as_boolean => true, :value_as_double => 75.672)
|
62
|
-
#001 Demo string blah blah 2011-02-14 1.00 320.00
|
63
|
-
|
64
|
-
expect= result_file('simple_export_spec.xls')
|
65
|
-
|
66
|
-
gen = ExcelGenerator.new(expect)
|
67
|
-
|
68
|
-
items = Project.all
|
69
|
-
|
70
|
-
gen.export(items)
|
71
|
-
|
72
|
-
File.exists?(expect).should be_true
|
73
|
-
|
74
|
-
end
|
75
|
-
|
76
|
-
end
|
77
|
-
else
|
78
|
-
puts "WARNING: skipped excel_generator_spec : Requires JRUBY - JExcelFile requires JAVA"
|
1
|
+
# Copyright:: (c) Autotelik Media Ltd 2011
|
2
|
+
# Author :: Tom Statter
|
3
|
+
# Date :: Aug 2011
|
4
|
+
# License:: MIT
|
5
|
+
#
|
6
|
+
# Details:: Specs for Excel aspect of Active Record Loader
|
7
|
+
#
|
8
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
9
|
+
|
10
|
+
if(Guards::jruby?)
|
11
|
+
require 'erb'
|
12
|
+
require 'excel_generator'
|
13
|
+
|
14
|
+
include DataShift
|
15
|
+
|
16
|
+
describe 'Excel Generator' do
|
17
|
+
|
18
|
+
before(:all) do
|
19
|
+
db_connect( 'test_file' ) # , test_memory, test_mysql
|
20
|
+
|
21
|
+
# load our test model definitions - Project etc
|
22
|
+
require File.join($DataShiftFixturePath, 'test_model_defs')
|
23
|
+
|
24
|
+
# handle migration changes or reset of test DB
|
25
|
+
migrate_up
|
26
|
+
|
27
|
+
db_clear() # todo read up about proper transactional fixtures
|
28
|
+
results_clear()
|
29
|
+
|
30
|
+
@klazz = Project
|
31
|
+
@assoc_klazz = Category
|
32
|
+
end
|
33
|
+
|
34
|
+
before(:each) do
|
35
|
+
MethodDictionary.clear
|
36
|
+
MethodDictionary.find_operators( @klazz )
|
37
|
+
MethodDictionary.find_operators( @assoc_klazz )
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should be able to create a new excel generator" do
|
41
|
+
generator = ExcelGenerator.new( 'dummy.xls' )
|
42
|
+
|
43
|
+
generator.should_not be_nil
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should generate template .xls file from model" do
|
47
|
+
|
48
|
+
expect = result_file('project_template_spec.xls')
|
49
|
+
|
50
|
+
gen = ExcelGenerator.new( expect )
|
51
|
+
|
52
|
+
gen.generate(Project)
|
53
|
+
|
54
|
+
File.exists?(expect).should be_true
|
55
|
+
|
56
|
+
puts "Can manually check file @ #{expect}"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should export a simple model to .xls spreedsheet" do
|
60
|
+
|
61
|
+
Project.create( :value_as_string => 'Value as Text', :value_as_boolean => true, :value_as_double => 75.672)
|
62
|
+
#001 Demo string blah blah 2011-02-14 1.00 320.00
|
63
|
+
|
64
|
+
expect= result_file('simple_export_spec.xls')
|
65
|
+
|
66
|
+
gen = ExcelGenerator.new(expect)
|
67
|
+
|
68
|
+
items = Project.all
|
69
|
+
|
70
|
+
gen.export(items)
|
71
|
+
|
72
|
+
File.exists?(expect).should be_true
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
else
|
78
|
+
puts "WARNING: skipped excel_generator_spec : Requires JRUBY - JExcelFile requires JAVA"
|
79
79
|
end # jruby
|