Class: BuildpackSupport::Repository::RepositoryIndex
- Inherits:
-
Object
- Object
- BuildpackSupport::Repository::RepositoryIndex
- Defined in:
- lib/buildpack_support/repository/repository_index.rb
Overview
A repository index represents the index of repository containing various versions of a file.
Instance Method Summary collapse
-
#find_item(version) ⇒ TokenizedVersion, String
Finds a version of the file matching the given, possibly wildcarded, version.
-
#initialize(repository_root, version_resolver = WildcardVersionResolver.new) ⇒ RepositoryIndex
constructor
Creates a new repository index, populating it with values from an index file.
Constructor Details
#initialize(repository_root, version_resolver = WildcardVersionResolver.new) ⇒ RepositoryIndex
Creates a new repository index, populating it with values from an index file.
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/buildpack_support/repository/repository_index.rb', line 34 def initialize(repository_root, version_resolver = WildcardVersionResolver.new) @logger = BuildpackSupport::Logging::LoggerFactory.instance.get_logger RepositoryIndex @version_resolver = version_resolver default_repository_root = BuildpackSupport::ConfigurationUtils.new.load('repository')['default_repository_root'].chomp('/') cache.get("#{canonical default_repository_root, repository_root}#{INDEX_PATH}") do |file| @index = YAML.load_file(file) @logger.debug { @index } end end |
Instance Method Details
#find_item(version) ⇒ TokenizedVersion, String
Finds a version of the file matching the given, possibly wildcarded, version.
50 51 52 53 54 |
# File 'lib/buildpack_support/repository/repository_index.rb', line 50 def find_item(version) version = @version_resolver.resolve(version, @index.keys) uri = @index[version.to_s] [version, uri] end |