Class: BuildpackSupport::Component::BaseDroplet
- Inherits:
-
Object
- Object
- BuildpackSupport::Component::BaseDroplet
- Extended by:
- DirectoryFinder
- Defined in:
- lib/buildpack_support/component/base_droplet.rb
Overview
An abstraction around the droplet that will be created and used at runtime. This abstraction is intended to hide the work done by components within their own sandboxes, while exposing changes made to the user’s application. Think of this as a mutable representation of a component’s sandbox and the application that was uploaded.
A new instance of this type should be created for each component.
Instance Attribute Summary collapse
-
#component_id ⇒ String
readonly
The id of component using this droplet.
-
#root ⇒ BuildpackSupport::FilteringPathname
readonly
The root of the droplet’s fileystem filtered so that it excludes files in the sandboxes of other components.
-
#sandbox ⇒ Pathname
readonly
The root of the component’s sandbox.
Instance Method Summary collapse
-
#copy_resources(target_directory = @sandbox) ⇒ Void
Copy resources from a components resources directory to a directory.
-
#initialize(component_id, root) ⇒ BaseDroplet
constructor
Creates a new instance of the droplet abstraction.
Methods included from DirectoryFinder
Constructor Details
#initialize(component_id, root) ⇒ BaseDroplet
Creates a new instance of the droplet abstraction
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/buildpack_support/component/base_droplet.rb', line 51 def initialize(component_id, root) @component_id = component_id @logger = BuildpackSupport::Logging::LoggerFactory.instance.get_logger self.class buildpack_root = root + '.buildpack' sandbox_root = buildpack_root + component_id @sandbox = BuildpackSupport::FilteringPathname.new(sandbox_root, ->(path) { in?(path, sandbox_root) }, true) @root = BuildpackSupport::FilteringPathname.new(root, ->(path) { !in?(path, buildpack_root) || in?(path, @sandbox) }, true) end |
Instance Attribute Details
#component_id ⇒ String (readonly)
Returns the id of component using this droplet.
36 37 38 |
# File 'lib/buildpack_support/component/base_droplet.rb', line 36 def component_id @component_id end |
#root ⇒ BuildpackSupport::FilteringPathname (readonly)
Returns the root of the droplet’s fileystem filtered so that it excludes files in the sandboxes of other components.
41 42 43 |
# File 'lib/buildpack_support/component/base_droplet.rb', line 41 def root @root end |
#sandbox ⇒ Pathname (readonly)
Returns the root of the component’s sandbox.
45 46 47 |
# File 'lib/buildpack_support/component/base_droplet.rb', line 45 def sandbox @sandbox end |
Instance Method Details
#copy_resources(target_directory = @sandbox) ⇒ Void
Copy resources from a components resources directory to a directory
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/buildpack_support/component/base_droplet.rb', line 68 def copy_resources(target_directory = @sandbox) resources = RESOURCES_DIRECTORY + @component_id if resources.exist? FileUtils.mkdir_p target_directory FileUtils.cp_r("#{resources}/.", target_directory) @logger.debug { "Resources #{resources} found" } else @logger.debug { "No resources #{resources} found" } end end |