datashift 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. data/README.markdown +63 -64
  2. data/Rakefile +4 -7
  3. data/VERSION +1 -1
  4. data/datashift.gemspec +92 -62
  5. data/lib/applications/apache_poi_extensions.rb +62 -0
  6. data/lib/applications/excel.rb +78 -0
  7. data/lib/applications/excel_base.rb +65 -0
  8. data/lib/applications/jexcel_file.rb +222 -0
  9. data/lib/applications/jexcel_file_extensions.rb +244 -0
  10. data/lib/applications/jruby/{jexcel_file.rb → old_pre_proxy_jexcel_file.rb} +0 -0
  11. data/lib/applications/ruby_poi_translations.rb +64 -0
  12. data/lib/applications/spreadsheet_extensions.rb +31 -0
  13. data/lib/datashift/method_details_manager.rb +4 -0
  14. data/lib/exporters/csv_exporter.rb +3 -1
  15. data/lib/exporters/excel_exporter.rb +59 -74
  16. data/lib/generators/excel_generator.rb +70 -74
  17. data/lib/guards.rb +57 -0
  18. data/lib/loaders/excel_loader.rb +105 -105
  19. data/lib/loaders/loader_base.rb +43 -21
  20. data/lib/loaders/paperclip/attachment_loader.rb +104 -0
  21. data/lib/loaders/paperclip/datashift_paperclip.rb +78 -0
  22. data/lib/loaders/paperclip/{image_loader.rb → image_loading.rb} +2 -18
  23. data/lib/thor/{generate_excel.thor → generate.thor} +48 -0
  24. data/lib/thor/paperclip.thor +85 -0
  25. data/lib/thor/tools.thor +23 -2
  26. data/spec/Gemfile +1 -7
  27. data/spec/csv_exporter_spec.rb +4 -4
  28. data/spec/csv_loader_spec.rb +1 -1
  29. data/spec/excel_exporter_spec.rb +43 -45
  30. data/spec/excel_generator_spec.rb +132 -60
  31. data/spec/excel_loader_spec.rb +134 -140
  32. data/spec/excel_spec.rb +179 -0
  33. data/spec/fixtures/ProjectsMultiCategoriesHeaderLookup.xls +0 -0
  34. data/spec/fixtures/config/database.yml +2 -2
  35. data/spec/fixtures/db/datashift_test_models_db.sqlite +0 -0
  36. data/spec/{db → fixtures/db}/migrate/20110803201325_create_test_bed.rb +0 -0
  37. data/spec/fixtures/load_datashift.thor +3 -0
  38. data/spec/fixtures/models/category.rb +7 -0
  39. data/spec/fixtures/models/empty.rb +2 -0
  40. data/spec/fixtures/models/loader_release.rb +10 -0
  41. data/spec/fixtures/models/long_and_complex_table_linked_to_version.rb +6 -0
  42. data/spec/fixtures/models/milestone.rb +8 -0
  43. data/spec/fixtures/models/owner.rb +5 -0
  44. data/spec/fixtures/models/project.rb +26 -0
  45. data/spec/fixtures/models/test_model_defs.rb +67 -0
  46. data/spec/fixtures/models/version.rb +7 -0
  47. data/spec/loader_spec.rb +4 -3
  48. data/spec/method_dictionary_spec.rb +7 -6
  49. data/spec/method_mapper_spec.rb +3 -2
  50. data/spec/rails_sandbox/.gitignore +15 -0
  51. data/spec/rails_sandbox/Gemfile +40 -0
  52. data/spec/rails_sandbox/README.rdoc +261 -0
  53. data/spec/rails_sandbox/Rakefile +7 -0
  54. data/spec/rails_sandbox/app/assets/images/rails.png +0 -0
  55. data/spec/rails_sandbox/app/assets/javascripts/application.js +15 -0
  56. data/spec/rails_sandbox/app/assets/stylesheets/application.css +13 -0
  57. data/spec/rails_sandbox/app/controllers/application_controller.rb +3 -0
  58. data/spec/rails_sandbox/app/helpers/application_helper.rb +2 -0
  59. data/spec/rails_sandbox/app/mailers/.gitkeep +0 -0
  60. data/spec/rails_sandbox/app/models/.gitkeep +0 -0
  61. data/spec/rails_sandbox/app/models/category.rb +7 -0
  62. data/spec/rails_sandbox/app/models/empty.rb +2 -0
  63. data/spec/rails_sandbox/app/models/loader_release.rb +10 -0
  64. data/spec/rails_sandbox/app/models/long_and_complex_table_linked_to_version.rb +6 -0
  65. data/spec/rails_sandbox/app/models/milestone.rb +8 -0
  66. data/spec/rails_sandbox/app/models/owner.rb +5 -0
  67. data/spec/rails_sandbox/app/models/project.rb +26 -0
  68. data/spec/rails_sandbox/app/models/test_model_defs.rb +67 -0
  69. data/spec/rails_sandbox/app/models/version.rb +7 -0
  70. data/spec/rails_sandbox/app/views/layouts/application.html.erb +14 -0
  71. data/spec/rails_sandbox/config.ru +4 -0
  72. data/spec/rails_sandbox/config/application.rb +62 -0
  73. data/spec/rails_sandbox/config/boot.rb +6 -0
  74. data/spec/rails_sandbox/config/database.yml +20 -0
  75. data/spec/rails_sandbox/config/environment.rb +5 -0
  76. data/spec/rails_sandbox/config/environments/development.rb +37 -0
  77. data/spec/rails_sandbox/config/environments/production.rb +67 -0
  78. data/spec/rails_sandbox/config/environments/test.rb +37 -0
  79. data/spec/rails_sandbox/config/initializers/backtrace_silencers.rb +7 -0
  80. data/spec/rails_sandbox/config/initializers/inflections.rb +15 -0
  81. data/spec/rails_sandbox/config/initializers/mime_types.rb +5 -0
  82. data/spec/rails_sandbox/config/initializers/secret_token.rb +7 -0
  83. data/spec/rails_sandbox/config/initializers/session_store.rb +8 -0
  84. data/spec/rails_sandbox/config/initializers/wrap_parameters.rb +14 -0
  85. data/spec/rails_sandbox/config/locales/en.yml +5 -0
  86. data/spec/rails_sandbox/config/routes.rb +58 -0
  87. data/spec/rails_sandbox/db/migrate/20110803201325_create_test_bed.rb +96 -0
  88. data/spec/rails_sandbox/db/schema.rb +81 -0
  89. data/spec/rails_sandbox/db/seeds.rb +7 -0
  90. data/spec/rails_sandbox/lib/assets/.gitkeep +0 -0
  91. data/spec/rails_sandbox/lib/tasks/.gitkeep +0 -0
  92. data/spec/rails_sandbox/log/.gitkeep +0 -0
  93. data/spec/rails_sandbox/public/404.html +26 -0
  94. data/spec/rails_sandbox/public/422.html +26 -0
  95. data/spec/rails_sandbox/public/500.html +25 -0
  96. data/spec/rails_sandbox/public/favicon.ico +0 -0
  97. data/spec/rails_sandbox/public/index.html +241 -0
  98. data/spec/rails_sandbox/public/robots.txt +5 -0
  99. data/spec/rails_sandbox/script/rails +6 -0
  100. data/spec/rails_sandbox/test/fixtures/.gitkeep +0 -0
  101. data/spec/rails_sandbox/test/functional/.gitkeep +0 -0
  102. data/spec/rails_sandbox/test/integration/.gitkeep +0 -0
  103. data/spec/rails_sandbox/test/performance/browsing_test.rb +12 -0
  104. data/spec/rails_sandbox/test/test_helper.rb +13 -0
  105. data/spec/rails_sandbox/test/unit/.gitkeep +0 -0
  106. data/spec/rails_sandbox/vendor/assets/javascripts/.gitkeep +0 -0
  107. data/spec/rails_sandbox/vendor/assets/stylesheets/.gitkeep +0 -0
  108. data/spec/rails_sandbox/vendor/plugins/.gitkeep +0 -0
  109. data/spec/spec_helper.rb +144 -121
  110. data/spec/thor_spec.rb +34 -14
  111. metadata +207 -194
  112. data/lib/helpers/spree_helper.rb +0 -213
  113. data/lib/loaders/spreadsheet_loader.rb +0 -144
  114. data/lib/loaders/spree/image_loader.rb +0 -90
  115. data/lib/loaders/spree/product_loader.rb +0 -354
  116. data/lib/thor/spree/bootstrap_cleanup.thor +0 -61
  117. data/lib/thor/spree/products_images.thor +0 -252
  118. data/lib/thor/spree/reports.thor +0 -56
  119. data/public/spree/products/large/DEMO_001_ror_bag.jpeg +0 -0
  120. data/public/spree/products/large/DEMO_002_Powerstation.jpg +0 -0
  121. data/public/spree/products/large/DEMO_003_ror_mug.jpeg +0 -0
  122. data/public/spree/products/mini/DEMO_001_ror_bag.jpeg +0 -0
  123. data/public/spree/products/mini/DEMO_002_Powerstation.jpg +0 -0
  124. data/public/spree/products/mini/DEMO_003_ror_mug.jpeg +0 -0
  125. data/public/spree/products/original/DEMO_001_ror_bag.jpeg +0 -0
  126. data/public/spree/products/original/DEMO_002_Powerstation.jpg +0 -0
  127. data/public/spree/products/original/DEMO_003_ror_mug.jpeg +0 -0
  128. data/public/spree/products/product/DEMO_001_ror_bag.jpeg +0 -0
  129. data/public/spree/products/product/DEMO_002_Powerstation.jpg +0 -0
  130. data/public/spree/products/product/DEMO_003_ror_mug.jpeg +0 -0
  131. data/public/spree/products/small/DEMO_001_ror_bag.jpeg +0 -0
  132. data/public/spree/products/small/DEMO_002_Powerstation.jpg +0 -0
  133. data/public/spree/products/small/DEMO_003_ror_mug.jpeg +0 -0
  134. data/spec/fixtures/datashift_Spree_db.sqlite +0 -0
  135. data/spec/fixtures/datashift_test_models_db.sqlite +0 -0
  136. data/spec/fixtures/negative/SpreeProdMiss1Mandatory.csv +0 -4
  137. data/spec/fixtures/negative/SpreeProdMiss1Mandatory.xls +0 -0
  138. data/spec/fixtures/negative/SpreeProdMissManyMandatory.csv +0 -4
  139. data/spec/fixtures/negative/SpreeProdMissManyMandatory.xls +0 -0
  140. data/spec/fixtures/spree/SpreeImages.xls +0 -0
  141. data/spec/fixtures/spree/SpreeMultiVariant.csv +0 -4
  142. data/spec/fixtures/spree/SpreeProducts.csv +0 -4
  143. data/spec/fixtures/spree/SpreeProducts.xls +0 -0
  144. data/spec/fixtures/spree/SpreeProductsDefaults.yml +0 -15
  145. data/spec/fixtures/spree/SpreeProductsMandatoryOnly.xls +0 -0
  146. data/spec/fixtures/spree/SpreeProductsMultiColumn.csv +0 -4
  147. data/spec/fixtures/spree/SpreeProductsMultiColumn.xls +0 -0
  148. data/spec/fixtures/spree/SpreeProductsSimple.csv +0 -4
  149. data/spec/fixtures/spree/SpreeProductsSimple.xls +0 -0
  150. data/spec/fixtures/spree/SpreeProductsWithImages.csv +0 -4
  151. data/spec/fixtures/spree/SpreeProductsWithImages.xls +0 -0
  152. data/spec/fixtures/spree/SpreeZoneExample.csv +0 -5
  153. data/spec/fixtures/spree/SpreeZoneExample.xls +0 -0
  154. data/spec/spree_exporter_spec.rb +0 -72
  155. data/spec/spree_generator_spec.rb +0 -96
  156. data/spec/spree_images_loader_spec.rb +0 -107
  157. data/spec/spree_loader_spec.rb +0 -375
  158. data/spec/spree_method_mapping_spec.rb +0 -226
  159. data/spec/spree_variants_loader_spec.rb +0 -189
  160. data/tasks/export/excel_generator.rake +0 -102
  161. data/tasks/import/excel.rake +0 -75
  162. data/test/helper.rb +0 -18
  163. data/test/test_interact.rb +0 -7
@@ -1,61 +0,0 @@
1
- # Copyright:: (c) Autotelik Media Ltd 2012
2
- # Author :: Tom Statter
3
- # Date :: March 2012
4
- # License:: MIT. Free, Open Source.
5
- #
6
- # Usage::
7
- # bundle exec thor help datashift:spreeboot
8
- # bundle exec thor datashift:spreeboot:cleanup
9
- #
10
- # Note, not DataShift, case sensitive, create namespace for command line : datashift
11
-
12
- module Datashift
13
-
14
- class Spreeboot < Thor
15
-
16
- include DataShift::Logging
17
-
18
- desc "cleanup", "Remove Spree Product/Variant data from DB"
19
-
20
- def cleanup()
21
-
22
- require File.expand_path('config/environment.rb')
23
-
24
- require 'spree_helper'
25
-
26
- require File.expand_path('config/environment.rb')
27
-
28
- ActiveRecord::Base.connection.execute("TRUNCATE spree_products_taxons")
29
-
30
- cleanup = %w{ Image OptionType OptionValue
31
- Product Property ProductGroup ProductProperty ProductOptionType
32
- Variant Taxonomy Taxon
33
- }
34
-
35
- cleanup.each do |k|
36
- klass = DataShift::SpreeHelper::get_spree_class(k)
37
- if(klass)
38
- puts "Clearing model #{klass}"
39
- begin
40
- klass.delete_all
41
- rescue => e
42
- puts e
43
- end
44
- else
45
- puts "WARNING - Could not find AR model for class name #{k}"
46
- end
47
- end
48
-
49
- image_bank = 'public/spree/products'
50
-
51
- if(File.exists?(image_bank) )
52
- puts "Removing old Product assets from '#{image_bank}'"
53
- FileUtils::rm_rf(image_bank)
54
- end
55
-
56
- FileUtils::rm_rf('MissingRecords') if(File.exists?('MissingRecords') )
57
-
58
- end
59
-
60
- end
61
- end
@@ -1,252 +0,0 @@
1
- # Copyright:: (c) Autotelik Media Ltd 2012
2
- # Author :: Tom Statter
3
- # Date :: March 2012
4
- # License:: MIT. Free, Open Source.
5
- #
6
- # Usage::
7
- # bundle exec thor help datashift:spree
8
- # bundle exec thor datashift:spree:products -i db/datashift/MegamanFozz20111115_load.xls -s 299S_
9
- #
10
- # bundle exec thor datashift:spree:images -i db/datashift/imagebank -s -p 299S_
11
- #
12
-
13
- # Note, not DataShift, case sensitive, create namespace for command line : datashift
14
- module Datashift
15
-
16
-
17
- class Spree < Thor
18
-
19
- include DataShift::Logging
20
-
21
- desc "products", "Populate Spree Product/Variant data from .xls (Excel) or CSV file"
22
-
23
- method_option :input, :aliases => '-i', :required => true, :desc => "The import file (.xls or .csv)"
24
- method_option :sku_prefix, :aliases => '-s', :desc => "Prefix to add to each SKU before saving Product"
25
- method_option :verbose, :aliases => '-v', :type => :boolean, :desc => "Verbose logging"
26
- method_option :config, :aliases => '-c', :type => :string, :desc => "Configuration file containg defaults or over rides in YAML"
27
-
28
- def products()
29
-
30
- # TODO - We're assuming run from a rails app/top level dir...
31
- # ...can we make this more robust ? e.g what about when using active record but not in Rails app,
32
- require File.expand_path('config/environment.rb')
33
-
34
- input = options[:input]
35
-
36
- require 'product_loader'
37
-
38
- loader = DataShift::SpreeHelper::ProductLoader.new
39
-
40
- # YAML configuration file to drive defaults etc
41
-
42
- if(options[:config])
43
- raise "Bad Config - Cannot find specified file #{options[:config]}" unless File.exists?(options[:config])
44
-
45
- loader.configure_from( options[:config] )
46
- else
47
- loader.set_default_value('available_on', Time.now.to_s(:db) )
48
- loader.set_default_value('cost_price', 0.0 )
49
- loader.set_default_value('price', 0.0 )
50
- end
51
-
52
- loader.set_prefix('sku', options[:sku_prefix] ) if(options[:sku_prefix])
53
-
54
- puts "DataShift::Product starting upload from file: #{input}"
55
-
56
- options = {:mandatory => ['sku', 'name', 'price']}
57
-
58
- # In >= 1.1.0 Image moved to master Variant from Product
59
- options[:force_inclusion] = ['images'] if(DataShift::SpreeHelper::version.to_f > 1 )
60
-
61
- loader.perform_load(input, options)
62
- end
63
-
64
-
65
- desc "attach_images", "Populate Products with images from Excel/CSV\nProvide column SKU or Name\nProvide column 'attachment' containing full path to image"
66
- # :dummy => dummy run without actual saving to DB
67
- method_option :input, :aliases => '-i', :required => true, :desc => "The 2 column import file (.xls or .csv)"
68
-
69
- def attach_images()
70
-
71
- require File.expand_path('config/environment.rb')
72
-
73
- require 'image_loader'
74
-
75
- image_klazz = DataShift::SpreeHelper::get_spree_class('Image' )
76
-
77
- # force inclusion means add to operator list even if not present
78
- options = { :force_inclusion => ['sku', 'attachment'] } if(SpreeHelper::version.to_f > 1 )
79
-
80
- loader = DataShift::SpreeHelper::ImageLoader.new(nil, options)
81
-
82
- loader.perform_load( options[:input], options )
83
- end
84
-
85
-
86
- #
87
- # => thor datashift:spree:images input=vendor/extensions/site/fixtures/images
88
- # => rake datashift:spree:images input=C:\images\photos large dummy=true
89
- #
90
- # => rake datashift:spree:images input=C:\images\taxon_icons skip_if_no_assoc=true klass=Taxon
91
- #
92
- desc "images", "Populate the DB with images from a directory\nwhere image names contain somewhere the Product Sku/Name"
93
-
94
- # :dummy => dummy run without actual saving to DB
95
- method_option :input, :aliases => '-i', :required => true, :desc => "The input path containing images "
96
-
97
- method_option :glob, :aliases => '-g', :desc => 'The glob to use to find files e.g. \'{*.jpg,*.gif,*.png}\' '
98
- method_option :recursive, :aliases => '-r', :type => :boolean, :desc => "Scan sub directories of input for images"
99
-
100
- method_option :sku, :aliases => '-s', :desc => "Lookup Product based on image name starting with sku"
101
- method_option :sku_prefix, :aliases => '-p', :desc => "SKU prefix to add to each image name before attempting Product lookup"
102
- method_option :dummy, :aliases => '-d', :type => :boolean, :desc => "Dummy run, do not actually save Image or Product"
103
-
104
- method_option :process_when_no_assoc, :aliases => '-f', :type => :boolean, :desc => "Process image even if no Product found - force loading"
105
- method_option :skip_when_assoc, :aliases => '-x', :type => :boolean, :desc => "DO not process image if Product already has image"
106
-
107
- method_option :verbose, :aliases => '-v', :type => :boolean, :desc => "Verbose logging"
108
- method_option :config, :aliases => '-c', :type => :string, :desc => "Configuration file for Image Loader in YAML"
109
- method_option :split_file_name_on, :type => :string, :desc => "delimiter to progressivley split filename for Prod lookup", :default => '_'
110
- method_option :case_sensitive, :type => :boolean, :desc => "Use case sensitive where clause to find Product"
111
- method_option :use_like, :type => :boolean, :desc => "Use sku/name LIKE 'string%' instead of sku/name = 'string' in where clauses to find Product"
112
-
113
- def images()
114
-
115
- require File.expand_path('config/environment.rb')
116
-
117
- require 'spree/image_loader'
118
-
119
- @verbose = options[:verbose]
120
-
121
- puts "Using Product Name for lookup" unless(options[:sku])
122
- puts "Using SKU for lookup" if(options[:sku])
123
-
124
- image_klazz = DataShift::SpreeHelper::get_spree_class('Image' )
125
-
126
- attachment_klazz = DataShift::SpreeHelper::get_spree_class('Product' )
127
- attachment_field = 'name'
128
-
129
- if(options[:sku] || SpreeHelper::version.to_f > 1)
130
- attachment_klazz = DataShift::SpreeHelper::get_spree_class('Variant' )
131
- attachment_field = 'sku'
132
- end
133
-
134
- image_loader = DataShift::SpreeHelper::ImageLoader.new(nil, options)
135
-
136
- if(options[:config])
137
- raise "Bad Config - Cannot find specified file #{options[:config]}" unless File.exists?(options[:config])
138
-
139
- image_loader.configure_from( options[:config] )
140
- end
141
-
142
- loader_config = image_loader.options
143
-
144
- puts "CONFIG: #{loader_config.inspect}"
145
- puts "OPTIONS #{options.inspect}"
146
-
147
- @image_path = options[:input]
148
-
149
- unless(File.exists?(@image_path))
150
- puts "ERROR: Supplied Path [#{@image_path}] not accesible"
151
- exit(-1)
152
- end
153
-
154
- logger.info "Loading Spree images from #{@image_path}"
155
-
156
- missing_records = []
157
-
158
- # try splitting up filename in various ways looking for the SKU
159
- split_on = loader_config['split_file_name_on'] || options[:split_file_name_on]
160
-
161
- image_cache = DataShift::ImageLoading::get_files(@image_path, options)
162
-
163
- puts "Found #{image_cache.size} image files - splitting names on delimiter : #{split_on}"
164
-
165
- image_cache.each do |image_name|
166
-
167
- image_base_name = File.basename(image_name)
168
-
169
- logger.info "Processing image file #{image_base_name} "
170
-
171
- base_name = File.basename(image_name, '.*')
172
- base_name.strip!
173
-
174
- record = nil
175
-
176
- record = image_loader.get_record_by(attachment_klazz, attachment_field, base_name)
177
-
178
- # TODO move into the ImageLoading module
179
- #
180
- # try the seperate individual portions of the filename, front -> back
181
- base_name.split(split_on).each do |x|
182
- x = "#{options[:sku_prefix]}#{x}" if(options[:sku_prefix])
183
-
184
- record = image_loader.get_record_by(attachment_klazz, attachment_field, x)
185
- break if record
186
- end unless(record)
187
-
188
- # this time try sequentially and incrementally scanning
189
- base_name.split(split_on).inject("") do |str, x|
190
- z = (options[:sku_prefix]) ? "#{options[:sku_prefix]}#{str}#{x}": "#{str}#{x}"
191
- puts z
192
- record = image_loader.get_record_by(attachment_klazz, attachment_field, z)
193
- break if record
194
- x
195
- end unless(record)
196
-
197
- # END TODO
198
-
199
- record = record.product if(record && record.respond_to?(:product)) # SKU stored on Variant but we want it's master Product
200
-
201
- if(record)
202
- logger.info "Found record for attachment : #{record.inspect}"
203
-
204
- if(options[:skip_when_assoc])
205
-
206
- paper_clip_name = image_base_name.gsub(Paperclip::Attachment::default_options[:restricted_characters], '_')
207
-
208
- exists = record.images.detect {|i| puts "Check #{paper_clip_name} matches #{i.attachment_file_name}"; i.attachment_file_name == paper_clip_name }
209
- if(exists)
210
- rid = record.respond_to?(:name) ? record.name : record.id
211
- puts "Skipping Image #{image_name} already loaded for #{rid}"
212
- logger.info "Skipping - Image #{image_name} already loaded for #{attachment_klazz}"
213
- next
214
- end
215
- end
216
- else
217
- missing_records << image_name
218
- end
219
-
220
- next if(options[:dummy]) # Don't actually create/upload to DB if we are doing dummy run
221
-
222
- # Check if Image must have an associated record
223
- if(record || (record.nil? && options[:process_when_no_assoc]))
224
- image_loader.reset()
225
-
226
- logger.info("Adding Image #{image_name} to Product #{record.name}")
227
- image_loader.create_image(image_klazz, image_name, record)
228
- puts "Added Image #{File.basename(image_name)} to Product #{record.sku} : #{record.name}" if(@verbose)
229
- end
230
-
231
- end
232
-
233
- unless missing_records.empty?
234
- FileUtils.mkdir_p('MissingRecords') unless File.directory?('MissingRecords')
235
-
236
- puts "WARNING : #{missing_records.size} of #{image_cache.size} images could not be attached to a Product"
237
- puts 'For your convenience a copy of images with MISSING Products will be saved to : ./MissingRecords'
238
- missing_records.each do |i|
239
- puts "Copying #{i} to MissingRecords folder" if(options[:verbose])
240
- FileUtils.cp( i, 'MissingRecords') unless(options[:dummy] == 'true')
241
- end
242
- else
243
- puts "All images (#{image_cache.size}) were succesfully attached to a Product"
244
- end
245
-
246
- puts "Dummy Run Complete- if happy run without -d" if(options[:dummy])
247
-
248
- end
249
-
250
- end
251
-
252
- end
@@ -1,56 +0,0 @@
1
- # Copyright:: (c) Autotelik Media Ltd 2012
2
- # Author :: Tom Statter
3
- # Date :: March 2012
4
- # License:: MIT. Free, Open Source.
5
- #
6
- # Usage::
7
- # bundle exec thor help datashift:reports:missing_images
8
- # bundle exec thor datashift:spreeboot:cleanup
9
- #
10
- # Note, not DataShift, case sensitive, create namespace for command line : datashift
11
-
12
- require 'excel_exporter'
13
-
14
- module Datashift
15
-
16
- class Spreereports < Thor
17
-
18
- include DataShift::Logging
19
-
20
- desc "no_image", "Spree Products without an image"
21
-
22
- def no_image(report = nil)
23
-
24
- require 'spree_helper'
25
- require 'csv_exporter'
26
- require 'image_loader'
27
-
28
- require File.expand_path('config/environment.rb')
29
-
30
- klass = DataShift::SpreeHelper::get_spree_class('Product')
31
-
32
- missing = klass.all.find_all {|p| p.images.size == 0 }
33
-
34
- puts "There are #{missing.size} Products (of #{klass.count}) without an associated Image"
35
-
36
- fname = report ? report : "missing_images"
37
-
38
- if(DataShift::Guards::jruby?)
39
- puts "Creating report #{fname}.xls"
40
- DataShift::ExcelExporter.new( fname + '.xls' ).export( missing, :methods => ['sku'] )
41
- else
42
- puts "Creating report #{fname}.csv"
43
- DataShift::CsvExporter.new( fname + '.csv' ).export( missing, :methods => ['sku'] )
44
- puts missing.collect(&:name).join('\n')
45
- end
46
-
47
- # TODO - cross check file locations for possible candidates
48
- #image_cache = DataShift::ImageLoading::get_files(@cross_check_location, options)
49
-
50
- # missing.each {
51
-
52
- # puts images.inspect
53
- end
54
- end
55
-
56
- end
@@ -1,4 +0,0 @@
1
- "Name","Description","Available On"," Price","CostPrice","product_properties","count_on_hand","Taxons","Option Types"
2
- "Demo Product for AR Loader","blah blah","2011-02-14",400.00,320.00,"name:test_pp_001",12,"Paintings","mime_type:jpeg, PDF,PNG"
3
- "Demo Excel Load via Jruby","less blah","2011-05-14",100.00,30.00,"name:test_pp_001",5,"Paintings","mime_type:jpeg, PDF,PNG"
4
- "Demo third row in future","more blah blah","2012-07-01",50.34,23.34,"name:test_pp_002,test_pp_003",23,"Drawings","mime_type:jpeg,PDF,PNG|print_type:black_white,colour"
@@ -1,4 +0,0 @@
1
- "SKU","Description","Available On","CostPrice","product_properties","count_on_hand","Taxons","Option Types"
2
- "DEMO_001","blah blah","2011-02-14",320.00,"name:test_pp_001",12,"Paintings","mime_type:jpeg, PDF,PNG"
3
- "DEMO_002","less blah","2011-05-14",30.00,"name:test_pp_001",5,"Paintings","mime_type:jpeg, PDF,PNG"
4
- "DEMO_003","more blah blah","2012-07-01",23.34,"name:test_pp_002,test_pp_003",23,"Drawings","mime_type:jpeg,PDF,PNG|print_type:black_white,colour"
Binary file
@@ -1,4 +0,0 @@
1
- "SKU","Name","Description","Available On"," Price","CostPrice","Option Types","Option Types","Variants","count_on_hand"
2
- "MV_001","Demo Product for AR Loader","blah blah","2011-02-14",399.99,320.00,"mime_type:jpeg, PDF;print_type:colour",,"mime_type:PNG","12|6|7"
3
- "MV_002","Demo Excel Load via Jruby","less blah","2011-05-14",100.00,30.00,"mime_type:jpeg;print_type:black_white",,"mime_type:PNG;print_type:black_white","5|4"
4
- "MV_003","Demo third row in future","more blah blah","2012-07-01",50.34,23.34,"mime_type:jpeg;print_type:colour, sepia;size:large|mime_type:PNG","mime_type:PDF|print_type:black_white",,"12|4|7|12"
@@ -1,4 +0,0 @@
1
- "SKU","Name","Description","Available On"," Price","CostPrice","product_properties","Taxons","OptionTypes","Variants","count_on_hand"
2
- "DEMO_001","Demo Product for AR Loader","blah blah","2011-02-14",399.99,320.00,"test_pp_001","Paintings|WaterColour",,"mime_type:jpeg,PDF,PNG","12|6|7"
3
- "DEMO_002","Demo Excel Load via Jruby","less blah","2011-05-14",100.00,30.00,"test_pp_003","Paintings|Oils|Paintings>Nature>Seascape","mime_type:jpeg, PDF,PNG",,"5|4|2"
4
- "DEMO_003","Demo third row in future","more blah blah","2012-07-01",50.34,23.34,"test_pp_002|test_pp_003:Example free value|yet_another_property","Drawings|Landscape",,"mime_type:jpeg,PDF,PNG|print_type:black_white,colour","12|4|7|12|18"
Binary file
@@ -1,15 +0,0 @@
1
- ## YAML Template.
2
-
3
- # Format is :
4
- # --- !ruby/object:ActiveRecordModel
5
- # :datashift_defaults
6
- # key: value
7
- #
8
-
9
- Spree::Product:
10
- datashift_defaults:
11
- available_on: Time.now.to_s(:db)
12
- cost_price: 1.0
13
- meta_description: 'super duper meta desc.'
14
- meta_keywords: 'techno dubstep d&b'
15
-