Class: BuildpackSupport::Component::BaseComponent

Inherits:
Object
  • Object
show all
Includes:
Downloads
Defined in:
lib/buildpack_support/component/base_component.rb

Overview

A convenience base class for all components in the buildpack. This base class ensures that the contents of the context are assigned to instance variables matching their keys. It also ensures that all contract methods are implemented.

Direct Known Subclasses

VersionedDependencyComponent

Instance Method Summary collapse

Methods included from Downloads

#download, #download_tar, #download_zip

Methods included from WithTiming

#with_timing

Methods included from Shell

#shell

Constructor Details

#initialize(context) ⇒ BaseComponent

Creates an instance. The contents of context are assigned to the instance variables matching their keys.

Parameters:

  • context (Hash)

    a collection of utilities used by components

Options Hash (context):



38
39
40
41
42
43
# File 'lib/buildpack_support/component/base_component.rb', line 38

def initialize(context)
  @application    = context[:application]
  @component_name = self.class.to_s.space_case
  @configuration  = context[:configuration]
  @droplet        = context[:droplet]
end

Instance Method Details

#compileVoid

Modifies the application’s file system. The component is expected to transform the application’s file system in whatever way is necessary (e.g. downloading files or creating symbolic links) to support the function of the component. Status output written to STDOUT is expected as part of this invocation.

Returns:

  • (Void)


59
60
61
# File 'lib/buildpack_support/component/base_component.rb', line 59

def compile
  fail "Method 'compile' must be defined"
end

#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.



50
51
52
# File 'lib/buildpack_support/component/base_component.rb', line 50

def detect
  fail "Method 'detect' must be defined"
end

#releasevoid, String

Modifies the application’s runtime configuration. The component is expected to transform members of the context (e.g. @java_home, @java_opts, etc.) in whatever way is necessary to support the function of the component.

Container components are also expected to create the command required to run the application. These components are expected to read the context values and take them into account when creating the command.

Returns:

  • (void, String)

    components other than containers are not expected to return any value. Container components are expected to return the command required to run the application.



71
72
73
# File 'lib/buildpack_support/component/base_component.rb', line 71

def release
  fail "Method 'release' must be defined"
end