<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: P4Change</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<h1>P4Change <sup class="type-note">(Class)</sup></h1>
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../files/P4Triggers_rb.html">
P4Triggers.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Object
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
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.
</p>
</div>
<div id="method-list">
<h2 class="section-bar">Methods</h2>
<div class="name-list">
<a href="#M000010">each_file</a>
<a href="#M000011">each_job</a>
<a href="#M000009">new</a>
</div>
</div>
<div id="attribute-list">
<h2 class="section-bar">Attributes</h2>
<div class="name-list">
<table>
<tr class="top-aligned-row context-row">
<td class="context-item-name">change</td>
<td class="context-item-value"> [R] </td>
<td class="context-item-desc"></td>
</tr>
<tr class="top-aligned-row context-row">
<td class="context-item-name">client</td>
<td class="context-item-value"> [R] </td>
<td class="context-item-desc"></td>
</tr>
<tr class="top-aligned-row context-row">
<td class="context-item-name">desc</td>
<td class="context-item-value"> [R] </td>
<td class="context-item-desc"></td>
</tr>
<tr class="top-aligned-row context-row">
<td class="context-item-name">files</td>
<td class="context-item-value"> [R] </td>
<td class="context-item-desc"></td>
</tr>
<tr class="top-aligned-row context-row">
<td class="context-item-name">jobs</td>
<td class="context-item-value"> [R] </td>
<td class="context-item-desc"></td>
</tr>
<tr class="top-aligned-row context-row">
<td class="context-item-name">status</td>
<td class="context-item-value"> [R] </td>
<td class="context-item-desc"></td>
</tr>
<tr class="top-aligned-row context-row">
<td class="context-item-name">time</td>
<td class="context-item-value"> [R] </td>
<td class="context-item-desc"></td>
</tr>
<tr class="top-aligned-row context-row">
<td class="context-item-name">user</td>
<td class="context-item-value"> [R] </td>
<td class="context-item-desc"></td>
</tr>
</table>
</div>
</div>
</div>
<!-- if includes -->
<!-- if method_list -->
<div id="methods">
<h2 class="section-bar">Public Class methods</h2>
<div id="method-M000009" class="method-detail">
<a name="M000009"></a>
<div class="method-heading">
<a href="#M000009" class="method-signature">
<span class="method-name">new</span><span class="method-args">( hash )</span>
</a>
</div>
<div class="method-description">
<p>
Constructor. Pass the hash returned by <a
href="P4.html#M000012">P4#run_describe</a>( "-s" ) in tagged
mode.
</p>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000009-source">
<pre>
<span class="ruby-comment cmt"># File P4Triggers.rb, line 47</span>
47: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>( <span class="ruby-identifier">hash</span> )
48: <span class="ruby-ivar">@change</span> = <span class="ruby-identifier">hash</span>[ <span class="ruby-value str">"change"</span> ]
49: <span class="ruby-ivar">@user</span> = <span class="ruby-identifier">hash</span>[ <span class="ruby-value str">"user"</span> ]
50: <span class="ruby-ivar">@client</span> = <span class="ruby-identifier">hash</span>[ <span class="ruby-value str">"client"</span> ]
51: <span class="ruby-ivar">@desc</span> = <span class="ruby-identifier">hash</span>[ <span class="ruby-value str">"desc"</span> ]
52: <span class="ruby-ivar">@time</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">at</span>( <span class="ruby-identifier">hash</span>[ <span class="ruby-value str">"time"</span> ].<span class="ruby-identifier">to_i</span> )
53:
54: <span class="ruby-ivar">@status</span> = <span class="ruby-identifier">hash</span>[ <span class="ruby-value str">"status"</span> ]
55: <span class="ruby-ivar">@files</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
56: <span class="ruby-ivar">@jobs</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>
57:
58: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">has_key?</span>( <span class="ruby-value str">"depotFile"</span> ) )
59: <span class="ruby-identifier">hash</span>[ <span class="ruby-value str">"depotFile"</span> ].<span class="ruby-identifier">each_index</span> <span class="ruby-keyword kw">do</span>
60: <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
61: <span class="ruby-identifier">name</span> = <span class="ruby-identifier">hash</span>[ <span class="ruby-value str">"depotFile"</span> ][ <span class="ruby-identifier">i</span> ]
62: <span class="ruby-identifier">type</span> = <span class="ruby-identifier">hash</span>[ <span class="ruby-value str">"type"</span> ][ <span class="ruby-identifier">i</span> ]
63: <span class="ruby-identifier">rev</span> = <span class="ruby-identifier">hash</span>[ <span class="ruby-value str">"rev"</span> ][ <span class="ruby-identifier">i</span> ]
64: <span class="ruby-identifier">act</span> = <span class="ruby-identifier">hash</span>[ <span class="ruby-value str">"action"</span> ][ <span class="ruby-identifier">i</span> ]
65:
66: <span class="ruby-identifier">df</span> = <span class="ruby-constant">P4DepotFile</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">name</span> )
67: <span class="ruby-identifier">dr</span> = <span class="ruby-identifier">df</span>.<span class="ruby-identifier">new_revision</span>
68:
69: <span class="ruby-identifier">dr</span>.<span class="ruby-identifier">type</span> = <span class="ruby-identifier">type</span>
70: <span class="ruby-identifier">dr</span>.<span class="ruby-identifier">revno</span> = <span class="ruby-identifier">rev</span>.<span class="ruby-identifier">to_i</span>
71: <span class="ruby-identifier">dr</span>.<span class="ruby-identifier">action</span> = <span class="ruby-identifier">act</span>
72:
73: <span class="ruby-ivar">@files</span>.<span class="ruby-identifier">push</span>( <span class="ruby-identifier">df</span> )
74: <span class="ruby-keyword kw">end</span>
75: <span class="ruby-keyword kw">end</span>
76:
77: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">has_key?</span>( <span class="ruby-value str">"job"</span> ) )
78: <span class="ruby-identifier">hash</span>[ <span class="ruby-value str">"job"</span> ].<span class="ruby-identifier">each_index</span> <span class="ruby-keyword kw">do</span>
79: <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
80: <span class="ruby-identifier">job</span> = <span class="ruby-identifier">hash</span>[ <span class="ruby-value str">"job"</span> ][ <span class="ruby-identifier">i</span> ]
81: <span class="ruby-identifier">status</span> = <span class="ruby-identifier">hash</span>[ <span class="ruby-value str">"jobstat"</span> ][ <span class="ruby-identifier">i</span> ]
82: <span class="ruby-ivar">@jobs</span>[ <span class="ruby-identifier">job</span> ] = <span class="ruby-identifier">status</span>
83: <span class="ruby-keyword kw">end</span>
84: <span class="ruby-keyword kw">end</span>
85: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<h2 class="section-bar">Public Instance methods</h2>
<div id="method-M000010" class="method-detail">
<a name="M000010"></a>
<div class="method-heading">
<a href="#M000010" class="method-signature">
<span class="method-name">each_file</span><span class="method-args">( &block ) {|f| ...}</span>
</a>
</div>
<div class="method-description">
<p>
Shorthand iterator for looking at the files in the change
</p>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000010-source">
<pre>
<span class="ruby-comment cmt"># File P4Triggers.rb, line 90</span>
90: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">each_file</span>( <span class="ruby-operator">&</span><span class="ruby-identifier">block</span> )
91: <span class="ruby-ivar">@files</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-keyword kw">yield</span>( <span class="ruby-identifier">f</span> ) }
92: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000011" class="method-detail">
<a name="M000011"></a>
<div class="method-heading">
<a href="#M000011" class="method-signature">
<span class="method-name">each_job</span><span class="method-args">( &block ) {|j| ...}</span>
</a>
</div>
<div class="method-description">
<p>
Shorthand iterator for looking at the jobs fixed by the change
</p>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000011-source">
<pre>
<span class="ruby-comment cmt"># File P4Triggers.rb, line 95</span>
95: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">each_job</span>( <span class="ruby-operator">&</span><span class="ruby-identifier">block</span> )
96: <span class="ruby-ivar">@jobs</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">j</span><span class="ruby-operator">|</span> <span class="ruby-keyword kw">yield</span>( <span class="ruby-identifier">j</span> ) }
97: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html> | # | Change | User | Description | Committed | |
|---|---|---|---|---|---|
| #3 | 4654 | Tony Smith |
Add an example spec trigger to show how you might restrict the default view for all new clients to a pre-defined set of mappings. |
||
| #2 | 4640 | Tony Smith |
Add a sample post-commit trigger that can be used to keep a master and slave branch in sync. |
||
| #1 | 3637 | Tony Smith | Add RDoc documentation to the sample triggers. |