Sha256: d7a907aef55ed3465a7c56c7e9d46bec0b852d6459032ecfc9b20a885922a9d1

Contents?: true

Size: 1.07 KB

Versions: 55

Compression:

Stored size: 1.07 KB

Contents

# encoding: utf-8
#
module Picky

  module Indexers

    #
    #
    class Base

      attr_reader :index_or_category

      forward :source,
              :to => :index_or_category

      def initialize index_or_category
        @index_or_category = index_or_category
      end

      # Starts the indexing process.
      #
      def prepare categories, scheduler = Scheduler.new
        source_for_prepare = source
        check source_for_prepare
        categories.empty
        process source_for_prepare, categories, scheduler do |prepared_file|
          notify_finished prepared_file
        end
      end

      # Explicitly reset the source to avoid caching trouble.
      #
      def reset source
        source.reset      if source.respond_to?(:reset)
        source.reconnect! if source.respond_to?(:reconnect!)
      end

      def check source
        raise "Trying to index without a source for #{@index_or_category.name}." unless source
      end

      def notify_finished prepared_file
        Picky.logger.tokenize @index_or_category, prepared_file
      end

    end

  end

end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
picky-4.15.0 lib/picky/indexers/base.rb
picky-4.14.0 lib/picky/indexers/base.rb
picky-4.13.1 lib/picky/indexers/base.rb
picky-4.13.0 lib/picky/indexers/base.rb
picky-4.12.13 lib/picky/indexers/base.rb
picky-4.12.12 lib/picky/indexers/base.rb
picky-4.12.11 lib/picky/indexers/base.rb
picky-4.12.10 lib/picky/indexers/base.rb
picky-4.12.8 lib/picky/indexers/base.rb
picky-4.12.7 lib/picky/indexers/base.rb
picky-4.12.6 lib/picky/indexers/base.rb
picky-4.12.5 lib/picky/indexers/base.rb
picky-4.12.4 lib/picky/indexers/base.rb
picky-4.12.3 lib/picky/indexers/base.rb
picky-4.12.2 lib/picky/indexers/base.rb