Sha256: 0ef6daf2656247a9e38d8d425a8abea36cfd2b05aa3ad769b828928342d08bf8

Contents?: true

Size: 1.64 KB

Versions: 8

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 Datashift
        
    class Spreereports < 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

8 entries across 8 versions & 2 rubygems

Version Path
datashift_spree-0.4.2 lib/thor/spree/reports.thor
datashift_spree-0.4.1 lib/thor/spree/reports.thor
datashift_spree-0.4.0 lib/thor/spree/reports.thor
datashift_spree-0.3.0 lib/thor/spree/reports.thor
datashift_spree-0.2.1 lib/thor/spree/reports.thor
datashift_spree-0.2.0 lib/thor/spree/reports.thor
datashift_spree-0.1.0 lib/thor/spree/reports.thor
datashift-0.9.0 lib/thor/spree/reports.thor