Class: Performa::Stage

Inherits:
Object
  • Object
show all
Defined in:
lib/performa/stage.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, commands:) ⇒ Stage

Returns a new instance of Stage.



20
21
22
23
24
# File 'lib/performa/stage.rb', line 20

def initialize(name:, commands:)
  @name = name
  @commands = commands
  @hash = Digest::SHA1.hexdigest(@name + @commands.map(&:hash).join)
end

Instance Attribute Details

#commandsObject (readonly)

Returns the value of attribute commands.



18
19
20
# File 'lib/performa/stage.rb', line 18

def commands
  @commands
end

#hashObject (readonly)

Returns the value of attribute hash.



18
19
20
# File 'lib/performa/stage.rb', line 18

def hash
  @hash
end

#nameObject (readonly)

Returns the value of attribute name.



18
19
20
# File 'lib/performa/stage.rb', line 18

def name
  @name
end

Class Method Details

.from_config(config_stage, image:) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/performa/stage.rb', line 7

def self.from_config(config_stage, image:)
  hash = Digest::SHA1.hexdigest(image)

  commands = config_stage[1].map do |config_command|
    hash = Digest::SHA1.hexdigest(hash + config_command)
    StageCommand.new(config_command, hash: hash)
  end

  new(name: config_stage[0], commands: commands)
end