Class: Dash::Dockerfile::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/dash/dockerfile/document.rb

Overview

A parsed Dockerfile: its instructions in file order, grouped into stages.

Named Document rather than File so that File.fnmatch inside Dash::Dockerfile still means the one in Ruby's core library.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(instructions:, stages:, directives: {}) ⇒ Document

Returns a new instance of Document.



8
9
10
11
12
# File 'lib/dash/dockerfile/document.rb', line 8

def initialize(instructions:, stages:, directives: {})
  @instructions = instructions
  @stages = stages
  @directives = directives
end

Instance Attribute Details

#directives ⇒ Object (readonly)

Returns the value of attribute directives.



6
7
8
# File 'lib/dash/dockerfile/document.rb', line 6

def directives
  @directives
end

#instructions ⇒ Object (readonly)

Returns the value of attribute instructions.



6
7
8
# File 'lib/dash/dockerfile/document.rb', line 6

def instructions
  @instructions
end

#stages ⇒ Object (readonly)

Returns the value of attribute stages.



6
7
8
# File 'lib/dash/dockerfile/document.rb', line 6

def stages
  @stages
end

Instance Method Details

#each_instruction(name) ⇒ Object



22
23
24
25
26
27
# File 'lib/dash/dockerfile/document.rb', line 22

def each_instruction(name)
  return to_enum(:each_instruction, name) unless block_given?

  name = name.to_s.upcase
  instructions.each { |instruction| yield instruction if instruction.name == name }
end

#final_stage ⇒ Object



18
19
20
# File 'lib/dash/dockerfile/document.rb', line 18

def final_stage
  stages.last
end

#shipped_stages ⇒ Object



14
15
16
# File 'lib/dash/dockerfile/document.rb', line 14

def shipped_stages
  stages.select(&:shipped?)
end