Sha256: ca352ed74757224ab4fb8d4552dfe8c1a35b1ed1bc041929949e3bc2b1470601

Contents?: true

Size: 1.64 KB

Versions: 1

Compression:

Stored size: 1.64 KB

Contents

# Copyright:: (c) Autotelik Media Ltd 2012
# Author ::   Tom Statter
# Date ::     March 2012
# License::   MIT. Free, Open Source.
#
# Usage::
# bundle exec thor help datashift:reports:missing_images
# bundle exec thor datashift:spreeboot:cleanup
#
# Note, not DataShift, case sensitive, create namespace for command line : datashift

require 'excel_exporter'
  
module DatashiftSpree
        
    class Reports < Thor     
  
      include DataShift::Logging
       
      desc "no_image", "Spree Products without an image"
    
      def no_image(report = nil)

        require 'spree_helper'
        require 'csv_exporter'
        require 'image_loader'

        require File.expand_path('config/environment.rb')

        klass = DataShift::SpreeHelper::get_spree_class('Product')
      
        missing = klass.all.find_all {|p| p.images.size == 0 }
      
        puts "There are #{missing.size} Products (of #{klass.count}) without an associated Image"
      
        fname = report ? report : "missing_images"
      
        if(DataShift::Guards::jruby?)
          puts "Creating report #{fname}.xls"  
          DataShift::ExcelExporter.new( fname + '.xls' ).export( missing, :methods => ['sku'] )
        else
          puts "Creating report #{fname}.csv"
          DataShift::CsvExporter.new( fname + '.csv' ).export( missing, :methods => ['sku'] )
          puts missing.collect(&:name).join('\n')
        end   
      
# TODO - cross check file locations for possible candidates 
        #image_cache = DataShift::ImageLoading::get_files(@cross_check_location, options)
        
        # missing.each { 
      
        # puts images.inspect
      end
    end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
datashift_spree-0.5.0 lib/thor/spree/reports.thor