Sha256: 80532ef1ad5cb44126b6f7f99be8bf620c0643b4903d9671b9fd027c3e11f792

Contents?: true

Size: 1.08 KB

Versions: 10

Compression:

Stored size: 1.08 KB

Contents

# encoding: utf-8
#
module Picky

  module Indexers

    #
    #
    class Base

      attr_reader :index_or_category

      delegate :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 # :nodoc:
        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

10 entries across 10 versions & 1 rubygems

Version Path
picky-4.4.1 lib/picky/indexers/base.rb
picky-4.4.0 lib/picky/indexers/base.rb
picky-4.3.2 lib/picky/indexers/base.rb
picky-4.3.1 lib/picky/indexers/base.rb
picky-4.3.0 lib/picky/indexers/base.rb
picky-4.2.4 lib/picky/indexers/base.rb
picky-4.2.3 lib/picky/indexers/base.rb
picky-4.2.2 lib/picky/indexers/base.rb
picky-4.2.1 lib/picky/indexers/base.rb
picky-4.2.0 lib/picky/indexers/base.rb