Class: BuildpackSupport::Component::VersionedDependencyComponent

Inherits:
BaseComponent
  • Object
show all
Includes:
VersionedDownloads
Defined in:
lib/buildpack_support/component/versioned_dependency_component.rb

Overview

A convenience base class for all components that have a versioned dependency. In addition to the functionality inherited from BaseComponent this class also ensures that managed dependencies are handled in a uniform manner.

Instance Method Summary collapse

Methods included from VersionedDownloads

#download_tar, #download_zip

Methods included from Downloads

#download, #download_tar, #download_zip

Methods included from WithTiming

#with_timing

Methods included from Shell

#shell

Methods inherited from BaseComponent

#compile, #release

Constructor Details

#initialize(context, configured_item = BuildpackSupport::Repository::ConfiguredItem.new, &version_validator) ⇒ VersionedDependencyComponent

Creates an instance. In addition to the functionality inherited from BaseComponent, @version and @uri instance variables are exposed.

Parameters:

  • context (Hash)

    a collection of utilities used by components

  • version_validator (Block, nil)

    an optional version validation block



37
38
39
40
41
42
43
44
45
46
# File 'lib/buildpack_support/component/versioned_dependency_component.rb', line 37

def initialize(context, configured_item = BuildpackSupport::Repository::ConfiguredItem.new, &version_validator)
  super(context)

  if supports?
    @version, @uri = configured_item.find_item(@component_name, @configuration, &version_validator)
  else
    @version = nil
    @uri     = nil
  end
end

Instance Method Details

#detectArray<String>, ...

If the component should be used when staging an application

Returns:

  • (Array<String>, String, nil)

    If the component should be used when staging the application, a String or an Array<String> that uniquely identifies the component (e.g. open_jdk=1.7.0_40). Otherwise, nil.



49
50
51
# File 'lib/buildpack_support/component/versioned_dependency_component.rb', line 49

def detect
  @version ? id(@version) : nil
end