class Kameleon::Microstep
Attributes
Public Class Methods
Source
# File lib/kameleon/step.rb, line 111 def initialize(string_or_hash) @identifier = nil @has_checkpoint_ahead = false @in_checkpoint_window = true @on_checkpoint = "use_cache" @commands = [] @name, cmd_list = string_or_hash.first cmd_list.each do |cmd_hash| if cmd_hash.kind_of? Command @commands.push cmd_hash else if cmd_hash.kind_of?(Hash) && cmd_hash.keys.first == "on_checkpoint" @on_checkpoint = cmd_hash["on_checkpoint"] else @commands.push Command.new(cmd_hash, @name) end end end rescue fail RecipeError, "Syntax error for microstep #{name}" end
Public Instance Methods
Source
# File lib/kameleon/step.rb, line 149 def calculate_identifier(salt) commands_str = @commands.map { |cmd| cmd.string_cmd.to_s } content_id = commands_str.join(' ') + salt @identifier = "#{ Digest::SHA1.hexdigest content_id }"[0..11] @commands.each do |cmd| map_id = cmd.string_cmd.to_s + @identifier cmd.identifier = "#{ Digest::SHA1.hexdigest map_id }"[0..11] end @identifier end
Source
# File lib/kameleon/step.rb, line 137 def gsub!(arg1, arg2) @commands.each {|cmd| cmd.gsub!(arg1, arg2) } end
Source
# File lib/kameleon/step.rb, line 133 def resolve! @commands.each {|cmd| cmd.resolve! } end
Source
# File lib/kameleon/step.rb, line 160 def to_array microstep_array = @commands.map do |cmd| cmd.to_array end return microstep_array end
Source
# File lib/kameleon/step.rb, line 141 def unshift(cmd_list) cmd_list.reverse.each {|cmd| @commands.unshift cmd} end