Sha256: bc10a0e9840f4375f4dac4fc46eba1a57cb100f083ead41a2e86def35d0569e9

Contents?: true

Size: 1.41 KB

Versions: 3

Compression:

Stored size: 1.41 KB

Contents

module Configuration # :nodoc:all

  # Holds the configuration for a
  # index/category combination.
  #
  class Index

    attr_reader :index, :category

    def initialize index, category
      @index       = index
      @category    = category
    end

    def index_name
      @index_name ||= index.name
    end
    def category_name
      @category_name ||= category.name
    end

    #
    #
    def index_path bundle_name, name
      "#{index_directory}/#{category_name}_#{bundle_name}_#{name}"
    end

    # Was: search_index_file_name
    #
    def prepared_index_path
      @prepared_index_path ||= "#{index_directory}/prepared_#{category_name}_index"
    end
    def prepared_index_file &block
      @prepared_index_file ||= Internals::Index::File::Text.new prepared_index_path
      @prepared_index_file.open_for_indexing &block
    end

    # Identifier for internal use.
    #
    def identifier
      @identifier ||= "#{index_name}:#{category_name}"
    end

    def to_s
      "#{index_name} #{category_name}"
    end

    def self.index_root
      @index_root ||= "#{PICKY_ROOT}/index"
    end
    def index_root
      self.class.index_root
    end
    # Was: cache_directory
    #
    def index_directory
      @index_directory ||= "#{index_root}/#{PICKY_ENVIRONMENT}/#{index_name}"
    end
    # Was: prepare_cache_directory
    #
    def prepare_index_directory
      FileUtils.mkdir_p index_directory
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
picky-2.1.2 lib/picky/internals/configuration/index.rb
picky-2.1.1 lib/picky/internals/configuration/index.rb
picky-2.1.0 lib/picky/internals/configuration/index.rb