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.22.0 lib/picky/indexers/base.rb
picky-4.21.2 lib/picky/indexers/base.rb
picky-4.21.1 lib/picky/indexers/base.rb
picky-4.21.0 lib/picky/indexers/base.rb
picky-4.20.2 lib/picky/indexers/base.rb
picky-4.20.1 lib/picky/indexers/base.rb
picky-4.20.0 lib/picky/indexers/base.rb
picky-4.19.7 lib/picky/indexers/base.rb
picky-4.19.6 lib/picky/indexers/base.rb
picky-4.19.5 lib/picky/indexers/base.rb
picky-4.19.4 lib/picky/indexers/base.rb
picky-4.19.3 lib/picky/indexers/base.rb
picky-4.19.2 lib/picky/indexers/base.rb
picky-4.19.1 lib/picky/indexers/base.rb
picky-4.19.0 lib/picky/indexers/base.rb
picky-4.18.0 lib/picky/indexers/base.rb
picky-4.17.1 lib/picky/indexers/base.rb
picky-4.17.0 lib/picky/indexers/base.rb
picky-4.16.0 lib/picky/indexers/base.rb
picky-4.15.1 lib/picky/indexers/base.rb