In: |
P4Triggers.rb
|
Parent: | Object |
A class for holding info about a change. This is intended to be populated be the output of "p4 describe" rather than "p4 change -o". The difference is mostly in the case of the hash keys, but that’s significant enough.
change | [R] | |
client | [R] | |
desc | [R] | |
files | [R] | |
jobs | [R] | |
status | [R] | |
time | [R] | |
user | [R] |
Constructor. Pass the hash returned by P4#run_describe( "-s" ) in tagged mode.
# File P4Triggers.rb, line 47 47: def initialize( hash ) 48: @change = hash[ "change" ] 49: @user = hash[ "user" ] 50: @client = hash[ "client" ] 51: @desc = hash[ "desc" ] 52: @time = Time.at( hash[ "time" ].to_i ) 53: 54: @status = hash[ "status" ] 55: @files = Array.new 56: @jobs = Hash.new 57: 58: if ( hash.has_key?( "depotFile" ) ) 59: hash[ "depotFile" ].each_index do 60: |i| 61: name = hash[ "depotFile" ][ i ] 62: type = hash[ "type" ][ i ] 63: rev = hash[ "rev" ][ i ] 64: act = hash[ "action" ][ i ] 65: 66: df = P4DepotFile.new( name ) 67: dr = df.new_revision 68: 69: dr.type = type 70: dr.revno = rev.to_i 71: dr.action = act 72: 73: @files.push( df ) 74: end 75: end 76: 77: if ( hash.has_key?( "job" ) ) 78: hash[ "job" ].each_index do 79: |i| 80: job = hash[ "job" ][ i ] 81: status = hash[ "jobstat" ][ i ] 82: @jobs[ job ] = status 83: end 84: end 85: end
Shorthand iterator for looking at the files in the change
# File P4Triggers.rb, line 90 90: def each_file( &block ) 91: @files.each { |f| yield( f ) } 92: end