Sha256: 9a4f3fa7b168a5b4ce1f41906c7745b19c057c903eb40334f5fd068a778a7310

Contents?: true

Size: 847 Bytes

Versions: 9

Compression:

Stored size: 847 Bytes

Contents

require "progressbar"

module AbstractImporter
  module Reporters
    class ProgressReporter < BaseReporter

      def finish_setup(importer, ms)
        total = importer.collections.reduce(0) do |total, collection|
          total + importer.count_collection(collection)
        end
        @pbar = ProgressBar.new("progress", total)
      end

      def finish_all(importer, ms)
        pbar.finish
        io.puts "Finished in #{distance_of_time(ms)}"
      end

      def start_collection(collection)
        # Say nothing
      end



      def record_created(record)
        pbar.inc
      end

      def record_failed(record, hash)
        pbar.inc
      end

      def record_skipped(hash)
        pbar.inc
      end

      def batch_inserted(size)
        pbar.inc size
      end

    protected
      attr_reader :pbar

    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
abstract_importer-1.9.0 lib/abstract_importer/reporters/progress_reporter.rb
abstract_importer-1.8.0 lib/abstract_importer/reporters/progress_reporter.rb
abstract_importer-1.7.0 lib/abstract_importer/reporters/progress_reporter.rb
abstract_importer-1.6.0 lib/abstract_importer/reporters/progress_reporter.rb
abstract_importer-1.5.6 lib/abstract_importer/reporters/progress_reporter.rb
abstract_importer-1.5.5 lib/abstract_importer/reporters/progress_reporter.rb
abstract_importer-1.5.4 lib/abstract_importer/reporters/progress_reporter.rb
abstract_importer-1.5.3 lib/abstract_importer/reporters/progress_reporter.rb
abstract_importer-1.5.2 lib/abstract_importer/reporters/progress_reporter.rb