lib/thor/spree/bootstrap_cleanup.thor in datashift-0.7.0 vs lib/thor/spree/bootstrap_cleanup.thor in datashift-0.8.0

- old
+ new

@@ -6,10 +6,14 @@ # Usage:: # bundle exec thor help datashift:spreeboot # bundle exec thor datashift:spreeboot:cleanup # # Note, not DataShift, case sensitive, create namespace for command line : datashift + +require File.expand_path('config/environment.rb') + + module Datashift class Spreeboot < Thor include DataShift::Logging @@ -20,33 +24,35 @@ require 'spree_helper' require File.expand_path('config/environment.rb') + ActiveRecord::Base.connection.execute("TRUNCATE spree_products_taxons") + cleanup = %w{ Image OptionType OptionValue Product Property ProductGroup ProductProperty ProductOptionType - Variant Taxonomy Taxon Zone + Variant Taxonomy Taxon } cleanup.each do |k| klass = DataShift::SpreeHelper::get_spree_class(k) - if(klass) - puts "Clearing model #{klass}" - klass.delete_all - else - puts "WARNING - Coulod not find AR model for class name #{k}" + if(klass) + puts "Clearing model #{klass}" + klass.delete_all + else + puts "WARNING - Could not find AR model for class name #{k}" + end end - - end - if(File.exists?('public/spree/products') ) - puts "Removing old Product assets from 'public/spree/products'" - FileUtils::rm_rf('public/public/spree/products') - end + image_bank = 'public/spree/products' - FileUtils::rm_rf('MissingRecords') if(File.exists?('MissingRecords') ) + if(File.exists?(image_bank) ) + puts "Removing old Product assets from '#{image_bank}'" + FileUtils::rm_rf(image_bank) + end - end + FileUtils::rm_rf('MissingRecords') if(File.exists?('MissingRecords') ) + + end -end - + end end \ No newline at end of file