Class: BuildpackSupport::Component::Application

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

Overview

An abstraction around the application as uploaded by the user. This abstraction is intended to hide any modifications made to the filesystem by other components. Think of this as an immutable representation of the application as it was uploaded.

A new instance of this type should be created once for the application.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root) ⇒ Application

Create a new instance of the application abstraction

Parameters:

  • root (Pathname)

    the root of the application



52
53
54
55
56
57
58
59
# File 'lib/buildpack_support/component/application.rb', line 52

def initialize(root)
  initial = children(root)
  @root   = BuildpackSupport::FilteringPathname.new(root, ->(path) { initial.member? path }, false)

  @environment = ENV.to_hash
  @details     = parse(@environment.delete('VCAP_APPLICATION'))
  @services    = Services.new(parse(@environment.delete('VCAP_SERVICES')))
end

Instance Attribute Details

#detailsHash (readonly)

Returns the parsed contents of the VCAP_APPLICATION environment variable.

Returns:

  • (Hash)

    the parsed contents of the VCAP_APPLICATION environment variable



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

def details
  @details
end

#environmentHash (readonly)

Returns all environment variables except VCAP_APPLICATION and VCAP_SERVICES. Those values are available separately in parsed form.

Returns:

  • (Hash)

    all environment variables except VCAP_APPLICATION and VCAP_SERVICES. Those values are available separately in parsed form.



38
39
40
# File 'lib/buildpack_support/component/application.rb', line 38

def environment
  @environment
end

#rootBuildpackSupport::FilteringPathname (readonly)

Returns the root of the application’s fileystem filtered so that it only shows files that have been uploaded by the user.

Returns:



43
44
45
# File 'lib/buildpack_support/component/application.rb', line 43

def root
  @root
end

#servicesHash (readonly)

Returns the parsed contents of the VCAP_SERVICES environment variable.

Returns:

  • (Hash)

    the parsed contents of the VCAP_SERVICES environment variable



47
48
49
# File 'lib/buildpack_support/component/application.rb', line 47

def services
  @services
end