Sha256: 66459c5edbbf7a424085db9cb93011de6c2c406ec930c418b774d29c96619b69

Contents?: true

Size: 1.56 KB

Versions: 11

Compression:

Stored size: 1.56 KB

Contents

module Configuration # :nodoc:all
  
  # Holds the configuration for a
  # index/category combination.
  #
  # TODO Rename paths?
  #
  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
    
    # def file_name
    #   @file_name ||= "#{@index_name}_#{@category_name}"
    # 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

11 entries across 11 versions & 1 rubygems

Version Path
picky-2.0.0 lib/picky/internals/configuration/index.rb
picky-2.0.0.pre3 lib/picky/internals/configuration/index.rb
picky-2.0.0.pre2 lib/picky/internals/configuration/index.rb
picky-2.0.0.pre1 lib/picky/internals/configuration/index.rb
picky-1.5.4 lib/picky/internals/configuration/index.rb
picky-1.5.3 lib/picky/internals/configuration/index.rb
picky-1.5.2 lib/picky/internals/configuration/index.rb
picky-1.5.1 lib/picky/internals/configuration/index.rb
picky-1.5.0 lib/picky/internals/configuration/index.rb
picky-1.4.3 lib/picky/internals/configuration/index.rb
picky-1.4.2 lib/picky/internals/configuration/index.rb