Sha256: 849a126990358f3574ec23cec4da9145a4f97fe6cb0c0779793a580791d528c3

Contents?: true

Size: 1.15 KB

Versions: 13

Compression:

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

    end

  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
picky-4.1.0 lib/picky/indexers/base.rb
picky-4.0.9 lib/picky/indexers/base.rb
picky-4.0.8 lib/picky/indexers/base.rb
picky-4.0.7 lib/picky/indexers/base.rb
picky-4.0.6 lib/picky/indexers/base.rb
picky-4.0.5 lib/picky/indexers/base.rb
picky-4.0.4 lib/picky/indexers/base.rb
picky-4.0.3 lib/picky/indexers/base.rb
picky-4.0.1 lib/picky/indexers/base.rb
picky-4.0.0 lib/picky/indexers/base.rb
picky-4.0.0pre6 lib/picky/indexers/base.rb
picky-4.0.0pre5 lib/picky/indexers/base.rb
picky-4.0.0pre3 lib/picky/indexers/base.rb