Class: BuildpackSupport::Repository::ConfiguredItem

Inherits:
Object
  • Object
show all
Defined in:
lib/buildpack_support/repository/configured_item.rb

Overview

A class encapsulating details of a file stored in a versioned repository.

Instance Method Summary collapse

Constructor Details

#initialize(version_resolver = WildcardVersionResolver.new) ⇒ ConfiguredItem

Creates a new instance



30
31
32
# File 'lib/buildpack_support/repository/configured_item.rb', line 30

def initialize(version_resolver = WildcardVersionResolver.new)
  @version_resolver = version_resolver
end

Instance Method Details

#find_item(component_name, configuration) {|version| ... } ⇒ String, TokenizedVersion

Finds an instance of the file based on the configuration and wraps any exceptions to identify the component.

Options Hash (configuration):

  • :repository_root (String)

    the root directory of the repository

  • :version (String)

    the version of the file to resolve

Yields:

  • the version to a block for validation. An error should be raised if the version is not valid

Yield Parameters:



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/buildpack_support/repository/configured_item.rb', line 45

def find_item(component_name, configuration)
  repository_root = repository_root(configuration)
  version         = version(configuration)

  yield version if block_given?

  index = index(repository_root)
  index.find_item version
rescue => e
  raise RuntimeError, "#{component_name} error: #{e.message}", e.backtrace
end