Sha256: be98e82f98902f0291e43508cb843c3a6a7c189950e49f673900ed48f5ad5fee

Contents?: true

Size: 1.61 KB

Versions: 9

Compression:

Stored size: 1.61 KB

Contents

# TODO Move to the API.
#
module Internals

  module Indexing

    class Index

      attr_reader :name, :source, :categories, :after_indexing

      # Delegators for indexing.
      #
      delegate :connect_backend,
               :to => :source

      delegate :index,
               :cache,
               :generate_caches,
               :backup_caches,
               :restore_caches,
               :check_caches,
               :clear_caches,
               :create_directory_structure,
               :to => :categories

      def initialize name, source, options = {}
        @name   = name
        @source = source

        @after_indexing = options[:after_indexing]
        @bundle_class   = options[:indexing_bundle_class] # TODO This should actually be a fixed parameter.

        @categories = Categories.new
      end

      # TODO Spec. Doc.
      #
      def define_category category_name, options = {}
        options = default_category_options.merge options

        new_category = Category.new category_name, self, options
        categories << new_category
        new_category
      end

      # By default, the category uses
      # * the index's source.
      # * the index's bundle type.
      #
      def default_category_options
        {
          :source => @source,
          :indexing_bundle_class => @bundle_class
        }
      end

      # Indexing.
      #
      def take_snapshot
        source.take_snapshot self
      end

      def to_s
        <<-INDEX
Indexing(#{name}):
#{"source: #{source}".indented_to_s}
#{"Categories:\n#{categories.indented_to_s}".indented_to_s}
INDEX
      end

    end

  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
picky-2.1.2 lib/picky/internals/indexing/index.rb
picky-2.1.1 lib/picky/internals/indexing/index.rb
picky-2.1.0 lib/picky/internals/indexing/index.rb
picky-2.0.0 lib/picky/internals/indexing/index.rb
picky-2.0.0.pre3 lib/picky/internals/indexing/index.rb
picky-2.0.0.pre2 lib/picky/internals/indexing/index.rb
picky-2.0.0.pre1 lib/picky/internals/indexing/index.rb
picky-1.5.4 lib/picky/internals/indexing/index.rb
picky-1.5.3 lib/picky/internals/indexing/index.rb