datashift 0.1.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. data/.document +5 -5
  2. data/LICENSE.txt +26 -26
  3. data/README.markdown +305 -303
  4. data/README.rdoc +19 -19
  5. data/Rakefile +93 -93
  6. data/VERSION +1 -1
  7. data/datashift-0.1.0.gem +0 -0
  8. data/datashift.gemspec +152 -136
  9. data/lib/applications/jruby/jexcel_file.rb +408 -408
  10. data/lib/applications/jruby/word.rb +79 -79
  11. data/lib/datashift.rb +152 -152
  12. data/lib/datashift/exceptions.rb +11 -11
  13. data/lib/datashift/file_definitions.rb +353 -353
  14. data/lib/datashift/mapping_file_definitions.rb +87 -87
  15. data/lib/datashift/method_detail.rb +275 -275
  16. data/lib/datashift/method_dictionary.rb +209 -209
  17. data/lib/datashift/method_mapper.rb +90 -90
  18. data/lib/generators/csv_generator.rb +36 -36
  19. data/lib/generators/excel_generator.rb +122 -122
  20. data/lib/generators/generator_base.rb +13 -13
  21. data/lib/helpers/core_ext/to_b.rb +24 -24
  22. data/lib/helpers/spree_helper.rb +153 -155
  23. data/lib/java/poi-3.7/LICENSE +507 -507
  24. data/lib/java/poi-3.7/NOTICE +21 -21
  25. data/lib/java/poi-3.7/RELEASE_NOTES.txt +115 -115
  26. data/lib/loaders/csv_loader.rb +98 -98
  27. data/lib/loaders/excel_loader.rb +155 -155
  28. data/lib/loaders/loader_base.rb +420 -420
  29. data/lib/loaders/spreadsheet_loader.rb +136 -136
  30. data/lib/loaders/spree/image_loader.rb +63 -64
  31. data/lib/loaders/spree/product_loader.rb +248 -250
  32. data/public/spree/products/large/DEMO_001_ror_bag.jpeg +0 -0
  33. data/public/spree/products/large/DEMO_002_Powerstation.jpg +0 -0
  34. data/public/spree/products/large/DEMO_003_ror_mug.jpeg +0 -0
  35. data/public/spree/products/mini/DEMO_001_ror_bag.jpeg +0 -0
  36. data/public/spree/products/mini/DEMO_002_Powerstation.jpg +0 -0
  37. data/public/spree/products/mini/DEMO_003_ror_mug.jpeg +0 -0
  38. data/public/spree/products/original/DEMO_001_ror_bag.jpeg +0 -0
  39. data/public/spree/products/original/DEMO_002_Powerstation.jpg +0 -0
  40. data/public/spree/products/original/DEMO_003_ror_mug.jpeg +0 -0
  41. data/public/spree/products/product/DEMO_001_ror_bag.jpeg +0 -0
  42. data/public/spree/products/product/DEMO_002_Powerstation.jpg +0 -0
  43. data/public/spree/products/product/DEMO_003_ror_mug.jpeg +0 -0
  44. data/public/spree/products/small/DEMO_001_ror_bag.jpeg +0 -0
  45. data/public/spree/products/small/DEMO_002_Powerstation.jpg +0 -0
  46. data/public/spree/products/small/DEMO_003_ror_mug.jpeg +0 -0
  47. data/spec/csv_loader_spec.rb +30 -30
  48. data/spec/datashift_spec.rb +26 -26
  49. data/spec/db/migrate/20110803201325_create_test_bed.rb +85 -85
  50. data/spec/excel_exporter_spec.rb +78 -78
  51. data/spec/excel_generator_spec.rb +78 -78
  52. data/spec/excel_loader_spec.rb +223 -223
  53. data/spec/file_definitions.rb +141 -141
  54. data/spec/fixtures/ProjectsDefaults.yml +29 -29
  55. data/spec/fixtures/config/database.yml +27 -24
  56. data/spec/fixtures/datashift_Spree_db.sqlite +0 -0
  57. data/spec/fixtures/interact_models_db.sqlite +0 -0
  58. data/spec/fixtures/negative/SpreeProdMiss1Mandatory.csv +4 -4
  59. data/spec/fixtures/negative/SpreeProdMissManyMandatory.csv +4 -4
  60. data/spec/fixtures/spree/SpreeProducts.csv +4 -4
  61. data/spec/fixtures/spree/SpreeProductsMultiColumn.csv +4 -4
  62. data/spec/fixtures/spree/SpreeProductsSimple.csv +4 -4
  63. data/spec/fixtures/spree/SpreeProductsWithImages.csv +4 -0
  64. data/spec/fixtures/spree/SpreeZoneExample.csv +5 -5
  65. data/spec/fixtures/test_model_defs.rb +57 -57
  66. data/spec/loader_spec.rb +120 -120
  67. data/spec/method_dictionary_spec.rb +242 -242
  68. data/spec/method_mapper_spec.rb +41 -41
  69. data/spec/spec_helper.rb +116 -116
  70. data/spec/spree_generator_spec.rb +64 -64
  71. data/spec/spree_loader_spec.rb +324 -327
  72. data/spec/spree_method_mapping_spec.rb +214 -214
  73. data/tasks/config/seed_fu_product_template.erb +15 -15
  74. data/tasks/config/tidy_config.txt +12 -12
  75. data/tasks/db_tasks.rake +65 -65
  76. data/tasks/excel_generator.rake +78 -78
  77. data/tasks/file_tasks.rake +36 -36
  78. data/tasks/import/csv.rake +49 -49
  79. data/tasks/import/excel.rake +71 -71
  80. data/tasks/spree/image_load.rake +108 -108
  81. data/tasks/spree/product_loader.rake +43 -43
  82. data/tasks/word_to_seedfu.rake +166 -166
  83. data/test/helper.rb +18 -18
  84. data/test/test_interact.rb +7 -7
  85. metadata +22 -3
  86. data/spec/fixtures/interact_spree_db.sqlite +0 -0
@@ -1,21 +1,21 @@
1
- Apache POI
2
- Copyright 2009 The Apache Software Foundation
3
-
4
- This product includes software developed by
5
- The Apache Software Foundation (http://www.apache.org/).
6
-
7
- This product contains the DOM4J library (http://www.dom4j.org).
8
- Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
9
-
10
- This product contains parts that were originally based on software from BEA.
11
- Copyright (c) 2000-2003, BEA Systems, <http://www.bea.com/>.
12
-
13
- This product contains W3C XML Schema documents. Copyright 2001-2003 (c)
14
- World Wide Web Consortium (Massachusetts Institute of Technology, European
15
- Research Consortium for Informatics and Mathematics, Keio University)
16
-
17
- This product contains the Piccolo XML Parser for Java
18
- (http://piccolo.sourceforge.net/). Copyright 2002 Yuval Oren.
19
-
20
- This product contains the chunks_parse_cmds.tbl file from the vsdump program.
21
- Copyright (C) 2006-2007 Valek Filippov (frob@df.ru)
1
+ Apache POI
2
+ Copyright 2009 The Apache Software Foundation
3
+
4
+ This product includes software developed by
5
+ The Apache Software Foundation (http://www.apache.org/).
6
+
7
+ This product contains the DOM4J library (http://www.dom4j.org).
8
+ Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
9
+
10
+ This product contains parts that were originally based on software from BEA.
11
+ Copyright (c) 2000-2003, BEA Systems, <http://www.bea.com/>.
12
+
13
+ This product contains W3C XML Schema documents. Copyright 2001-2003 (c)
14
+ World Wide Web Consortium (Massachusetts Institute of Technology, European
15
+ Research Consortium for Informatics and Mathematics, Keio University)
16
+
17
+ This product contains the Piccolo XML Parser for Java
18
+ (http://piccolo.sourceforge.net/). Copyright 2002 Yuval Oren.
19
+
20
+ This product contains the chunks_parse_cmds.tbl file from the vsdump program.
21
+ Copyright (C) 2006-2007 Valek Filippov (frob@df.ru)
@@ -1,115 +1,115 @@
1
- The Apache POI is pleased to announce the release of POI 3.7.
2
-
3
- See the downloads page for binary and source distributions: http://poi.apache.org/download.html
4
-
5
-
6
- Release Notes -- Apache POI -- Version 3.7
7
-
8
- Apache POI is an open source Java library for working with Microsoft Office documents.
9
- POI 3.7 is an incremental feature release based on the earlier 3.6 release.
10
-
11
- The most notable changes since POI 3.6 are:
12
- -------------------------------------------
13
- OOXML
14
- * support for reading aes-encrypted/write-protected ooxml files
15
- * support Java 1.5 in auto-generated xmlbeans for ooxml schemas
16
-
17
- Spreadsheet (Excel)
18
- * initial support for autofilters
19
- * support for data validation for ooxml format
20
- * initial support for themes for ooxml format
21
- * added implementation for new functions: RANDBETWEEN, POISSON, SUBTOTAL, TEXT, TRUNC
22
- * support evaluation of indirect defined names in INDIRECT
23
- * numerous fixes and performance optimizations in the Formula Evaluation module
24
- * ability to add, modify and remove series from HSSF Charts
25
- * numerous improvements in the cell data formatter (handling more formatting rules, better color detection, allow overriding of default locale)
26
- * more examples including a rich "spreadsheet to HTML" converter
27
-
28
- Document (Word)
29
- * initial support for the HWPF revision marks authors list
30
- * support for border codes in HWPF
31
- * support for processing of symbols in HWPF
32
- * support sections in Word 6 and Word 95 files
33
- * improved reading of auto-saved ("complex") documents in HWPF
34
- * improved support for manipulation of tables and paragraphs in XWPF
35
-
36
- SlideShow (PowerPoint)
37
- * allow editing workbooks embedded into HSLF slide shows
38
-
39
- Text Extraction
40
- * support for text extraction from XSLF tables
41
- * add PublisherTextExtractor support to extractorfactory
42
- * support attachments as embedded documents within the new OutlookTextExtactor
43
- * new event based XSSF text extractor (XSSFEventBasedExcelExtractor)
44
- * make it easier to tell which content types each POIXMLTextExtractor handles
45
- * paragraph level as well as whole-file text extraction for word 6/95 files
46
-
47
-
48
- * ...and much much more: code cleanup, many bug fixes and performance improvements
49
-
50
- Contributors
51
- ------------
52
-
53
- The following people have contributed to this release by submitting bug
54
- reports or by participating in the issue resolution process (in strict alphabetical order).
55
-
56
- Alexey Butchik Jeff Lavezzo Philippe Laflamme
57
- Andrew Shirley Jens Gatze Raiko Eckstein
58
- Andrzej Bialecki Jerry Soung Rainer Schwarze
59
- Antoni Mylka Jonathan Holloway Ranvijay Singh
60
- Antony Bowesman Josh Micich Rick Cameron
61
- Antti Koskimaki Jukka Zitting Robert Kish
62
- Attila Kiraily Kai Zimmermann Robin Salkeld
63
- Bob Smith Kalpesh Parmar Ryan Lauck
64
- Brendan Nolan Kamil Soltys Ryan Skow
65
- Charlie Chang Karl Eilebrecht Samuel Yung
66
- Chris Barlock Ken Arnold Simon Kelly
67
- Chris Lott Liu Yan Stefan Stern
68
- Christiaan Fluit Lon Binder Steve Wolke
69
- Dave Fisher Martin Studer TK Gospodinov
70
- Dave Syer Martin W. Kirst Tao Jiang
71
- David Agnew Maxim Valyanskiy Ted Schrader
72
- David Lewis Michael Vilensky Thomas Herre
73
- Dmitry Sviridov Michel Boudinot Tomas Prochazka
74
- Domenico Napoletano Nick Burch Tony Harvey
75
- Ed Beaty Paul Spencer Trejkaz (pen name)
76
- Fabio Ebner Payam Hekmat Tsutomu YANO
77
- Fred Ross Peter Kutak Viveck Shastri
78
- Grzegorz Bloch Petr Udalau Vladimir Korenev
79
- Henry Huang Phil Dunlea William J. Coleda
80
- Immad Naseer Phil Varner Yegor Kozlov
81
- Jan Stette Philipp Epp Zhang Zhang
82
-
83
-
84
- Thank you all very much! Contributions are always welcome, come join the project.
85
-
86
- Release Contents
87
- ----------------
88
-
89
- This release comes in two forms:
90
- - pre-built binaries containing compiled versions of all Apache POI components and documentation
91
- (poi-bin-3.7-20101029.zip or poi-bin-3.7-20101029.tar.gz)
92
- - source archive you can build POI from (poi-src-3.7-20101029.zip or poi-src-3.7-20101029.tar.gz)
93
-
94
- Pre-built versions of all POI components are also available in the central Maven repository
95
- under Group ID "org.apache.poi" and Version "3.7"
96
-
97
- All release artifacts are accompanied by MD5 checksums and a PGP signatures
98
- that you can use to verify the authenticity of your download.
99
- The public key used for the PGP signature can be found at
100
- http://svn.apache.org/repos/asf/poi/tags/REL_3_7/KEYS
101
-
102
-
103
- About Apache POI
104
- -----------------------
105
-
106
- Apache POI is well-known in the Java field as a library for reading and
107
- writing Microsoft Office file formats, such as Excel, PowerPoint, Visio and
108
- Word. Since POI 3.5, the new OOXML (Office Open XML) formats introduced in Office 2007 have been supported.
109
-
110
- For more information, visit http://poi.apache.org/
111
-
112
-
113
- For the Apache POI Team
114
- Yegor Kozlov
115
-
1
+ The Apache POI is pleased to announce the release of POI 3.7.
2
+
3
+ See the downloads page for binary and source distributions: http://poi.apache.org/download.html
4
+
5
+
6
+ Release Notes -- Apache POI -- Version 3.7
7
+
8
+ Apache POI is an open source Java library for working with Microsoft Office documents.
9
+ POI 3.7 is an incremental feature release based on the earlier 3.6 release.
10
+
11
+ The most notable changes since POI 3.6 are:
12
+ -------------------------------------------
13
+ OOXML
14
+ * support for reading aes-encrypted/write-protected ooxml files
15
+ * support Java 1.5 in auto-generated xmlbeans for ooxml schemas
16
+
17
+ Spreadsheet (Excel)
18
+ * initial support for autofilters
19
+ * support for data validation for ooxml format
20
+ * initial support for themes for ooxml format
21
+ * added implementation for new functions: RANDBETWEEN, POISSON, SUBTOTAL, TEXT, TRUNC
22
+ * support evaluation of indirect defined names in INDIRECT
23
+ * numerous fixes and performance optimizations in the Formula Evaluation module
24
+ * ability to add, modify and remove series from HSSF Charts
25
+ * numerous improvements in the cell data formatter (handling more formatting rules, better color detection, allow overriding of default locale)
26
+ * more examples including a rich "spreadsheet to HTML" converter
27
+
28
+ Document (Word)
29
+ * initial support for the HWPF revision marks authors list
30
+ * support for border codes in HWPF
31
+ * support for processing of symbols in HWPF
32
+ * support sections in Word 6 and Word 95 files
33
+ * improved reading of auto-saved ("complex") documents in HWPF
34
+ * improved support for manipulation of tables and paragraphs in XWPF
35
+
36
+ SlideShow (PowerPoint)
37
+ * allow editing workbooks embedded into HSLF slide shows
38
+
39
+ Text Extraction
40
+ * support for text extraction from XSLF tables
41
+ * add PublisherTextExtractor support to extractorfactory
42
+ * support attachments as embedded documents within the new OutlookTextExtactor
43
+ * new event based XSSF text extractor (XSSFEventBasedExcelExtractor)
44
+ * make it easier to tell which content types each POIXMLTextExtractor handles
45
+ * paragraph level as well as whole-file text extraction for word 6/95 files
46
+
47
+
48
+ * ...and much much more: code cleanup, many bug fixes and performance improvements
49
+
50
+ Contributors
51
+ ------------
52
+
53
+ The following people have contributed to this release by submitting bug
54
+ reports or by participating in the issue resolution process (in strict alphabetical order).
55
+
56
+ Alexey Butchik Jeff Lavezzo Philippe Laflamme
57
+ Andrew Shirley Jens Gatze Raiko Eckstein
58
+ Andrzej Bialecki Jerry Soung Rainer Schwarze
59
+ Antoni Mylka Jonathan Holloway Ranvijay Singh
60
+ Antony Bowesman Josh Micich Rick Cameron
61
+ Antti Koskimaki Jukka Zitting Robert Kish
62
+ Attila Kiraily Kai Zimmermann Robin Salkeld
63
+ Bob Smith Kalpesh Parmar Ryan Lauck
64
+ Brendan Nolan Kamil Soltys Ryan Skow
65
+ Charlie Chang Karl Eilebrecht Samuel Yung
66
+ Chris Barlock Ken Arnold Simon Kelly
67
+ Chris Lott Liu Yan Stefan Stern
68
+ Christiaan Fluit Lon Binder Steve Wolke
69
+ Dave Fisher Martin Studer TK Gospodinov
70
+ Dave Syer Martin W. Kirst Tao Jiang
71
+ David Agnew Maxim Valyanskiy Ted Schrader
72
+ David Lewis Michael Vilensky Thomas Herre
73
+ Dmitry Sviridov Michel Boudinot Tomas Prochazka
74
+ Domenico Napoletano Nick Burch Tony Harvey
75
+ Ed Beaty Paul Spencer Trejkaz (pen name)
76
+ Fabio Ebner Payam Hekmat Tsutomu YANO
77
+ Fred Ross Peter Kutak Viveck Shastri
78
+ Grzegorz Bloch Petr Udalau Vladimir Korenev
79
+ Henry Huang Phil Dunlea William J. Coleda
80
+ Immad Naseer Phil Varner Yegor Kozlov
81
+ Jan Stette Philipp Epp Zhang Zhang
82
+
83
+
84
+ Thank you all very much! Contributions are always welcome, come join the project.
85
+
86
+ Release Contents
87
+ ----------------
88
+
89
+ This release comes in two forms:
90
+ - pre-built binaries containing compiled versions of all Apache POI components and documentation
91
+ (poi-bin-3.7-20101029.zip or poi-bin-3.7-20101029.tar.gz)
92
+ - source archive you can build POI from (poi-src-3.7-20101029.zip or poi-src-3.7-20101029.tar.gz)
93
+
94
+ Pre-built versions of all POI components are also available in the central Maven repository
95
+ under Group ID "org.apache.poi" and Version "3.7"
96
+
97
+ All release artifacts are accompanied by MD5 checksums and a PGP signatures
98
+ that you can use to verify the authenticity of your download.
99
+ The public key used for the PGP signature can be found at
100
+ http://svn.apache.org/repos/asf/poi/tags/REL_3_7/KEYS
101
+
102
+
103
+ About Apache POI
104
+ -----------------------
105
+
106
+ Apache POI is well-known in the Java field as a library for reading and
107
+ writing Microsoft Office file formats, such as Excel, PowerPoint, Visio and
108
+ Word. Since POI 3.5, the new OOXML (Office Open XML) formats introduced in Office 2007 have been supported.
109
+
110
+ For more information, visit http://poi.apache.org/
111
+
112
+
113
+ For the Apache POI Team
114
+ Yegor Kozlov
115
+
@@ -1,99 +1,99 @@
1
- # Copyright:: (c) Autotelik Media Ltd 2011
2
- # Author :: Tom Statter
3
- # Date :: Aug 2011
4
- # License:: MIT
5
- #
6
- # Details:: Specific loader to support CSV files.
7
- #
8
- #
9
- require 'loaders/loader_base'
10
- require 'datashift/exceptions'
11
- require 'datashift/method_mapper'
12
-
13
- module DataShift
14
-
15
- module CsvLoading
16
-
17
- def perform_csv_load(file_name, options = {})
18
-
19
- require "csv"
20
-
21
- # TODO - can we abstract out what a 'parsed file' is - so a common object can represent excel,csv etc
22
- # then we can make load() more generic
23
-
24
- @parsed_file = CSV.read(file_name)
25
-
26
-
27
- @method_mapper = DataShift::MethodMapper.new
28
-
29
- @mandatory = options[:mandatory] || []
30
-
31
- # Create a method_mapper which maps list of headers into suitable calls on the Active Record class
32
- map_headers_to_operators( @parsed_file.shift, options[:strict] , @mandatory )
33
-
34
- unless(@method_mapper.missing_methods.empty?)
35
- puts "WARNING: Following column headings could not be mapped : #{@method_mapper.missing_methods.inspect}"
36
- raise MappingDefinitionError, "ERROR: Missing mappings for #{@method_mapper.missing_methods.size} column headings"
37
- end
38
-
39
- #if(options[:verbose])
40
- puts "\n\n\nLoading from CSV file: #{file_name}"
41
- puts "Processing #{@parsed_file.size} rows"
42
- # end
43
-
44
- load_object_class.transaction do
45
- @loaded_objects = []
46
-
47
- @parsed_file.each do |row|
48
-
49
- # TODO - Smart sorting of column processing order ....
50
- # Does not currently ensure mandatory columns (for valid?) processed first but model needs saving
51
- # before associations can be processed so user should ensure mandatory columns are prior to associations
52
-
53
- # as part of this we also attempt to save early, for example before assigning to
54
- # has_and_belongs_to associations which require the load_object has an id for the join table
55
-
56
- # Iterate over the columns method_mapper found in Excel,
57
- # pulling data out of associated column
58
- @method_mapper.method_details.each_with_index do |method_detail, col|
59
-
60
- value = row[col]
61
-
62
- prepare_data(method_detail, value)
63
-
64
- process()
65
- end
66
-
67
- # TODO - handle when it's not valid ?
68
- # Process rest and dump out an exception list of Products ??
69
-
70
- puts "SAVING ROW #{row} : #{load_object.inspect}" #if options[:verbose]
71
-
72
- save
73
-
74
- # don't forget to reset the object or we'll update rather than create
75
- new_load_object
76
-
77
- end
78
- end
79
- end
80
- end
81
-
82
- class CsvLoader < LoaderBase
83
-
84
- include DataShift::CsvLoading
85
-
86
- def initialize(klass, object = nil, options = {})
87
- super( klass, object, options )
88
- raise "Cannot load - failed to create a #{klass}" unless @load_object
89
- end
90
-
91
- def perform_load( file_name, options = {} )
92
- perform_csv_load( file_name, options )
93
-
94
- puts "CSV loading stage complete - #{loaded_objects.size} rows added."
95
- end
96
-
97
- end
98
-
1
+ # Copyright:: (c) Autotelik Media Ltd 2011
2
+ # Author :: Tom Statter
3
+ # Date :: Aug 2011
4
+ # License:: MIT
5
+ #
6
+ # Details:: Specific loader to support CSV files.
7
+ #
8
+ #
9
+ require 'loaders/loader_base'
10
+ require 'datashift/exceptions'
11
+ require 'datashift/method_mapper'
12
+
13
+ module DataShift
14
+
15
+ module CsvLoading
16
+
17
+ def perform_csv_load(file_name, options = {})
18
+
19
+ require "csv"
20
+
21
+ # TODO - can we abstract out what a 'parsed file' is - so a common object can represent excel,csv etc
22
+ # then we can make load() more generic
23
+
24
+ @parsed_file = CSV.read(file_name)
25
+
26
+
27
+ @method_mapper = DataShift::MethodMapper.new
28
+
29
+ @mandatory = options[:mandatory] || []
30
+
31
+ # Create a method_mapper which maps list of headers into suitable calls on the Active Record class
32
+ map_headers_to_operators( @parsed_file.shift, options[:strict] , @mandatory )
33
+
34
+ unless(@method_mapper.missing_methods.empty?)
35
+ puts "WARNING: Following column headings could not be mapped : #{@method_mapper.missing_methods.inspect}"
36
+ raise MappingDefinitionError, "ERROR: Missing mappings for #{@method_mapper.missing_methods.size} column headings"
37
+ end
38
+
39
+ #if(options[:verbose])
40
+ puts "\n\n\nLoading from CSV file: #{file_name}"
41
+ puts "Processing #{@parsed_file.size} rows"
42
+ # end
43
+
44
+ load_object_class.transaction do
45
+ @loaded_objects = []
46
+
47
+ @parsed_file.each do |row|
48
+
49
+ # TODO - Smart sorting of column processing order ....
50
+ # Does not currently ensure mandatory columns (for valid?) processed first but model needs saving
51
+ # before associations can be processed so user should ensure mandatory columns are prior to associations
52
+
53
+ # as part of this we also attempt to save early, for example before assigning to
54
+ # has_and_belongs_to associations which require the load_object has an id for the join table
55
+
56
+ # Iterate over the columns method_mapper found in Excel,
57
+ # pulling data out of associated column
58
+ @method_mapper.method_details.each_with_index do |method_detail, col|
59
+
60
+ value = row[col]
61
+
62
+ prepare_data(method_detail, value)
63
+
64
+ process()
65
+ end
66
+
67
+ # TODO - handle when it's not valid ?
68
+ # Process rest and dump out an exception list of Products ??
69
+
70
+ puts "SAVING ROW #{row} : #{load_object.inspect}" #if options[:verbose]
71
+
72
+ save
73
+
74
+ # don't forget to reset the object or we'll update rather than create
75
+ new_load_object
76
+
77
+ end
78
+ end
79
+ end
80
+ end
81
+
82
+ class CsvLoader < LoaderBase
83
+
84
+ include DataShift::CsvLoading
85
+
86
+ def initialize(klass, object = nil, options = {})
87
+ super( klass, object, options )
88
+ raise "Cannot load - failed to create a #{klass}" unless @load_object
89
+ end
90
+
91
+ def perform_load( file_name, options = {} )
92
+ perform_csv_load( file_name, options )
93
+
94
+ puts "CSV loading stage complete - #{loaded_objects.size} rows added."
95
+ end
96
+
97
+ end
98
+
99
99
  end