module Nucleus::Adapters::BuildpackTranslator

The {BuildpackTranslator} provides convenience methods for the user to handle the installation of application runtimes. Common runtime names can be applied and are automatically translated to a platform native runtime name / url (if applicable).

Constants

PUBLIC_BUILDPACKS

List of common buildpacks that are available GitHub. However, they are not guaranteed to work with every platform that utilized buildpacks.

Public Instance Methods

find_runtime(name) click to toggle source

Search the list of known buildpacks, both vendor specific and public, to match the desires runtime name. @param [String] name of the runtime to look out for @return [Boolean] returns true if a vendor specific or public buildpack was found for the runtime

# File lib/nucleus/adapters/buildpack_translator.rb, line 54
def find_runtime(name)
  if respond_to? :vendor_specific_runtimes
    runtime = vendor_specific_runtimes[name.downcase.underscore]
    return runtime unless runtime.nil?
  end

  # if no vendor specific runtime was found, use the general definitions
  PUBLIC_BUILDPACKS[name.downcase.underscore]
end
native_runtime?(name) click to toggle source

Checks if the name of the runtime is matching a vendor specific runtime / buildpack. @param [String] name of the runtime for which to check if it matches a vendor specific runtime @return [Boolean] returns true if the name matches a vendor specific runtime, false otherwise

# File lib/nucleus/adapters/buildpack_translator.rb, line 67
def native_runtime?(name)
  if respond_to? :vendor_specific_runtimes
    # case A: name is a key
    return true if vendor_specific_runtimes.keys.include? name
    # case B: name is a specific runtime name or a URL and one of the values
    return vendor_specific_runtimes.values.include? name
  end
  # cant be native if there are no vendor specific runtimes
  false
end