Class: Construi::Target

Inherits:
Object
  • Object
show all
Defined in:
lib/construi/target.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, config) ⇒ Target

Returns a new instance of Target.



8
9
10
11
# File 'lib/construi/target.rb', line 8

def initialize(name, config)
  @name = name
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



6
7
8
# File 'lib/construi/target.rb', line 6

def config
  @config
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/construi/target.rb', line 6

def name
  @name
end

Instance Method Details

#commandsObject



13
14
15
# File 'lib/construi/target.rb', line 13

def commands
  @config.commands
end

#initial_imageObject



29
30
31
# File 'lib/construi/target.rb', line 29

def initial_image
  return Image.from(@config)
end

#runObject



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/construi/target.rb', line 17

def run
  puts "Running #{name}...".green

  final_image = IntermediateImage.seed(initial_image).reduce(commands) do |image, command|
    puts
    puts " > #{command}".green
    image.run(command, @config.env)
  end

  final_image.delete
end