Class: BoringBuilder::Artifact
- Inherits:
-
Object
- Object
- BoringBuilder::Artifact
- Defined in:
- lib/boringbuilder/artifact.rb
Defined Under Namespace
Classes: Entry
Instance Attribute Summary collapse
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #directory(source, at: source) ⇒ Object
- #empty? ⇒ Boolean
- #export_directory(client, container) ⇒ Object
- #file(source, at: source) ⇒ Object
- #full_container_root? ⇒ Boolean
- #host_path(source, at:) ⇒ Object
-
#initialize(root: Dir.pwd) ⇒ Artifact
constructor
A new instance of Artifact.
- #to_a ⇒ Object
Constructor Details
Instance Attribute Details
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
13 14 15 |
# File 'lib/boringbuilder/artifact.rb', line 13 def entries @entries end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
13 14 15 |
# File 'lib/boringbuilder/artifact.rb', line 13 def root @root end |
Instance Method Details
#directory(source, at: source) ⇒ Object
20 21 22 |
# File 'lib/boringbuilder/artifact.rb', line 20 def directory(source, at: source) add(:container, :directory, source, at) end |
#empty? ⇒ Boolean
36 37 38 |
# File 'lib/boringbuilder/artifact.rb', line 36 def empty? entries.empty? end |
#export_directory(client, container) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/boringbuilder/artifact.rb', line 45 def export_directory(client, container) return container.directory("/") if full_container_root? entries.reduce(client.directory) do |directory, entry| destination = entry.destination.delete_prefix("/") source = source_for(entry, client, container) if entry.kind == :file directory.with_file(destination, source) else directory.with_directory(destination, source) end end end |
#file(source, at: source) ⇒ Object
24 25 26 |
# File 'lib/boringbuilder/artifact.rb', line 24 def file(source, at: source) add(:container, :file, source, at) end |
#full_container_root? ⇒ Boolean
40 41 42 43 |
# File 'lib/boringbuilder/artifact.rb', line 40 def full_container_root? entries.one? && entries.first.origin == :container && entries.first.kind == :directory && entries.first.source == "/" && entries.first.destination == "/" end |
#host_path(source, at:) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/boringbuilder/artifact.rb', line 28 def host_path(source, at:) path = Pathname.new(source).(root) kind = path.file? ? :file : :directory raise ConfigurationError, "Host artifact path does not exist: #{path}" unless path.exist? add(:host, kind, path, at) end |
#to_a ⇒ Object
60 61 62 |
# File 'lib/boringbuilder/artifact.rb', line 60 def to_a entries.map(&:to_h) end |