Class: BuildpackSupport::BaseBuildpack

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

Overview

A base class for all buildpack implementations to extend from. This implementation provides a number of utility methods for dealing with components.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.with_buildpack(app_dir, message) {|Buildpack| ... } ⇒ Object

Main entry to the buildpack. Initializes the buildpack and all of its dependencies and yields a new instance to any given block. Any exceptions thrown as part of the buildpack setup or execution are handled

Parameters:

  • app_dir (String)

    the path of the application directory

  • message (String)

    an error message with an insert for the reason for failure

Yields:

  • (Buildpack)

    the buildpack to work with

Returns:

  • (Object)

    the return value from the given block



139
140
141
142
143
144
145
146
147
# File 'lib/buildpack_support/base_buildpack.rb', line 139

def with_buildpack(app_dir, message)
  app_dir     = Pathname.new(File.expand_path(app_dir))
  application = Component::Application.new(app_dir)
  Logging::LoggerFactory.instance.setup app_dir

  yield new(app_dir, application) if block_given?
rescue => e
  handle_error(e, message)
end

Instance Method Details

#compileVoid

Transforms the application directory such that the engine, and frameworks can run the application

Returns:

  • (Void)


40
41
42
# File 'lib/buildpack_support/base_buildpack.rb', line 40

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

#detectArray<String>

Iterates over all of the components to detect if this buildpack can be used to run an application

Returns:

  • (Array<String>)

    An array of strings that identify the components and versions that will be used to run this application. If no container can run the application, the array will be empty ([]).



33
34
35
# File 'lib/buildpack_support/base_buildpack.rb', line 33

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

#releaseString

Generates the payload required to run the application. The payload format is defined by the Heroku Buildpack API.

Returns:

  • (String)

    The payload required to run the application.



48
49
50
# File 'lib/buildpack_support/base_buildpack.rb', line 48

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