Sha256: 2bf872c41a5a869a03885e35f24bfa4fce62b16405676735487293aa2dba065c

Contents?: true

Size: 1.08 KB

Versions: 1

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
        check_source
        categories.empty
        process 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
        timed_exclaim %Q{  "#{@index_or_category.identifier}": Tokenized -> #{prepared_file.path.gsub("#{PICKY_ROOT}/", '')}.}
      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
picky-4.0.0pre2 lib/picky/indexers/base.rb