Class P4Change
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.

Methods
each_file    each_job    new   
Attributes
change  [R] 
client  [R] 
desc  [R] 
files  [R] 
jobs  [R] 
status  [R] 
time  [R] 
user  [R] 
Public Class methods
new( hash )

Constructor. Pass the hash returned by P4#run_describe( "-s" ) in tagged mode.

# File P4Triggers.rb, line 47
    def initialize( hash )
        @change = hash[ "change"  ]
        @user  = hash[ "user"    ]
        @client = hash[ "client"  ]
        @desc  = hash[ "desc"    ]
        @time  = Time.at( hash[ "time" ].to_i )

        @status        = hash[ "status"  ]
        @files = Array.new
        @jobs = Hash.new

        if ( hash.has_key?( "depotFile" ) )
            hash[ "depotFile" ].each_index do
                |i|
                name = hash[ "depotFile"      ][ i ]
                type = hash[ "type"           ][ i ]
                rev    = hash[ "rev"            ][ i ]
                act    = hash[ "action" ][ i ]

                df = P4DepotFile.new( name )
                dr = df.new_revision

                dr.type       = type
                dr.revno      = rev.to_i
                dr.action     = act

                @files.push( df )
            end
        end

        if ( hash.has_key?( "job" ) )
            hash[ "job" ].each_index do
                |i|
                job   = hash[ "job"      ][ i ]
                status        = hash[ "jobstat" ][ i ]
                @jobs[ job ] = status
            end
        end
    end
Public Instance methods
each_file( &block ) {| f | ...}

Shorthand iterator for looking at the files in the change

# File P4Triggers.rb, line 90
    def each_file( &block )
        @files.each { |f| yield( f ) }
    end
each_job( &block ) {| j | ...}

Shorthand iterator for looking at the jobs fixed by the change

# File P4Triggers.rb, line 95
    def each_job( &block )
        @jobs.each { |j| yield( j ) }
    end