<?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: P4RecFile</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>P4RecFile <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/p4table_rb.html"> p4table.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> ******************************************************************************* </p> <pre> Class for representing files that are versioned in the depot. </pre> <p> ******************************************************************************* </p> </div> <div id="method-list"> <h2 class="section-bar">Methods</h2> <div class="name-list"> <a href="#M000016">add</a> <a href="#M000018">delete</a> <a href="#M000013">depot_path</a> <a href="#M000012">depot_path=</a> <a href="#M000017">edit</a> <a href="#M000015">exists=</a> <a href="#M000014">exists?</a> <a href="#M000021">mkdir</a> <a href="#M000010">new</a> <a href="#M000019">read</a> <a href="#M000022">to_s</a> <a href="#M000020">write</a> <a href="#M000011">ws_path</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">name</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">p4</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">rec</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-M000010" class="method-detail"> <a name="M000010"></a> <div class="method-heading"> <a href="#M000010" class="method-signature"> <span class="method-name">new</span><span class="method-args">( p4, name, rec )</span> </a> </div> <div class="method-description"> <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 p4table.rb, line 122</span> 122: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>( <span class="ruby-identifier">p4</span>, <span class="ruby-identifier">name</span>, <span class="ruby-identifier">rec</span> ) 123: <span class="ruby-ivar">@p4</span> = <span class="ruby-identifier">p4</span> 124: <span class="ruby-ivar">@name</span> = <span class="ruby-identifier">name</span> 125: <span class="ruby-ivar">@rec</span> = <span class="ruby-identifier">rec</span> 126: <span class="ruby-ivar">@exists</span> = <span class="ruby-keyword kw">false</span> 127: <span class="ruby-ivar">@depot_path</span> = <span class="ruby-keyword kw">nil</span> 128: <span class="ruby-ivar">@ws_path</span> = <span class="ruby-keyword kw">nil</span> 129: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <h2 class="section-bar">Public Instance methods</h2> <div id="method-M000016" class="method-detail"> <a name="M000016"></a> <div class="method-heading"> <a href="#M000016" class="method-signature"> <span class="method-name">add</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p><a class="source-toggle" href="#" onclick="toggleCode('M000016-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000016-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 181</span> 181: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add</span> 182: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">exists?</span> ) 183: <span class="ruby-identifier">raise</span>( <span class="ruby-constant">RuntimeError</span>, <span class="ruby-value str">"Can't open existing file for add"</span>, <span class="ruby-identifier">caller</span> ) 184: <span class="ruby-keyword kw">end</span> 185: <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">run_add</span>( <span class="ruby-identifier">ws_path</span>() ) 186: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div id="method-M000018" class="method-detail"> <a name="M000018"></a> <div class="method-heading"> <a href="#M000018" class="method-signature"> <span class="method-name">delete</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p><a class="source-toggle" href="#" onclick="toggleCode('M000018-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000018-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 203</span> 203: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete</span> 204: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span> <span class="ruby-identifier">exists?</span> ) 205: <span class="ruby-identifier">raise</span>( <span class="ruby-constant">RuntimeError</span>, <span class="ruby-value str">"Can't delete non-existent file"</span>, <span class="ruby-identifier">caller</span> ) 206: <span class="ruby-keyword kw">end</span> 207: 208: <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">run_sync</span>( <span class="ruby-identifier">depot_path</span>() ) 209: <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">run_delete</span>( <span class="ruby-identifier">depot_path</span>() ) 210: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div id="method-M000013" class="method-detail"> <a name="M000013"></a> <div class="method-heading"> <a href="#M000013" class="method-signature"> <span class="method-name">depot_path</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p><a class="source-toggle" href="#" onclick="toggleCode('M000013-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000013-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 158</span> 158: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">depot_path</span> 159: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@depot_path</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@depot_path</span> 160: <span class="ruby-identifier">table_path</span> = <span class="ruby-ivar">@rec</span>.<span class="ruby-identifier">table</span>.<span class="ruby-identifier">storage_map</span>( <span class="ruby-ivar">@rec</span> ).<span class="ruby-identifier">join</span>( <span class="ruby-value str">"/"</span> ) 161: <span class="ruby-ivar">@depot_path</span> = [ <span class="ruby-constant">DEPOT_ROOT_PATH</span>, <span class="ruby-identifier">table_path</span>, <span class="ruby-ivar">@rec</span>.<span class="ruby-identifier">id</span>.<span class="ruby-identifier">seq_str</span>, <span class="ruby-ivar">@name</span> ].<span class="ruby-identifier">join</span>( <span class="ruby-value str">"/"</span> ) 162: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div id="method-M000012" class="method-detail"> <a name="M000012"></a> <div class="method-heading"> <a href="#M000012" class="method-signature"> <span class="method-name">depot_path=</span><span class="method-args">( path )</span> </a> </div> <div class="method-description"> <p><a class="source-toggle" href="#" onclick="toggleCode('M000012-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000012-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 151</span> 151: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">depot_path=</span>( <span class="ruby-identifier">path</span> ) 152: <span class="ruby-ivar">@depot_path</span> = <span class="ruby-identifier">path</span> 153: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div id="method-M000017" class="method-detail"> <a name="M000017"></a> <div class="method-heading"> <a href="#M000017" class="method-signature"> <span class="method-name">edit</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p><a class="source-toggle" href="#" onclick="toggleCode('M000017-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000017-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 191</span> 191: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">edit</span> 192: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span> <span class="ruby-identifier">exists?</span> ) 193: <span class="ruby-identifier">raise</span>( <span class="ruby-constant">RuntimeError</span>,<span class="ruby-value str">"Can't open non-existent file for edit"</span>, <span class="ruby-identifier">caller</span>) 194: <span class="ruby-keyword kw">end</span> 195: 196: <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">run_sync</span>( <span class="ruby-identifier">depot_path</span>() ) 197: <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">run_edit</span>( <span class="ruby-identifier">depot_path</span>() ) 198: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div id="method-M000015" class="method-detail"> <a name="M000015"></a> <div class="method-heading"> <a href="#M000015" class="method-signature"> <span class="method-name">exists=</span><span class="method-args">( bool )</span> </a> </div> <div class="method-description"> <p><a class="source-toggle" href="#" onclick="toggleCode('M000015-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000015-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 174</span> 174: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">exists=</span>( <span class="ruby-identifier">bool</span> ) 175: <span class="ruby-ivar">@exists</span> = <span class="ruby-identifier">bool</span> 176: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div id="method-M000014" class="method-detail"> <a name="M000014"></a> <div class="method-heading"> <a href="#M000014" class="method-signature"> <span class="method-name">exists?</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p><a class="source-toggle" href="#" onclick="toggleCode('M000014-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000014-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 167</span> 167: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">exists?</span> 168: <span class="ruby-ivar">@exists</span> 169: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div id="method-M000021" class="method-detail"> <a name="M000021"></a> <div class="method-heading"> <a href="#M000021" class="method-signature"> <span class="method-name">mkdir</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p><a class="source-toggle" href="#" onclick="toggleCode('M000021-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000021-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 235</span> 235: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">mkdir</span> 236: <span class="ruby-identifier">dirs</span> = <span class="ruby-identifier">ws_path</span>.<span class="ruby-identifier">split</span>( <span class="ruby-constant">SEP</span> ) 237: <span class="ruby-identifier">dirs</span>.<span class="ruby-identifier">pop</span> 238: <span class="ruby-identifier">dir</span> = <span class="ruby-value str">""</span> 239: <span class="ruby-identifier">dirs</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> 240: <span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span> 241: <span class="ruby-identifier">dir</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">d</span> <span class="ruby-operator">+</span> <span class="ruby-constant">SEP</span> 242: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">mkdir</span>( <span class="ruby-identifier">dir</span> ) <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>( <span class="ruby-identifier">dir</span> ) 243: <span class="ruby-keyword kw">end</span> 244: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div id="method-M000019" class="method-detail"> <a name="M000019"></a> <div class="method-heading"> <a href="#M000019" class="method-signature"> <span class="method-name">read</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p><a class="source-toggle" href="#" onclick="toggleCode('M000019-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000019-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 215</span> 215: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">read</span> 216: <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">run_sync</span>( <span class="ruby-identifier">depot_path</span>() ) 217: <span class="ruby-identifier">f</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>( <span class="ruby-identifier">ws_path</span>, <span class="ruby-value str">"r"</span> ) 218: <span class="ruby-identifier">buf</span> = <span class="ruby-identifier">f</span>.<span class="ruby-identifier">read</span> 219: <span class="ruby-identifier">f</span>.<span class="ruby-identifier">close</span> 220: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">buf</span> 221: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div id="method-M000022" class="method-detail"> <a name="M000022"></a> <div class="method-heading"> <a href="#M000022" class="method-signature"> <span class="method-name">to_s</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p><a class="source-toggle" href="#" onclick="toggleCode('M000022-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000022-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 249</span> 249: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span> 250: <span class="ruby-identifier">depot_file</span> 251: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div id="method-M000020" class="method-detail"> <a name="M000020"></a> <div class="method-heading"> <a href="#M000020" class="method-signature"> <span class="method-name">write</span><span class="method-args">( string )</span> </a> </div> <div class="method-description"> <p><a class="source-toggle" href="#" onclick="toggleCode('M000020-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000020-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 226</span> 226: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">write</span>( <span class="ruby-identifier">string</span> ) 227: <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">run_sync</span>( <span class="ruby-identifier">depot_path</span>() ) 228: <span class="ruby-identifier">mkdir</span>() 229: <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>( <span class="ruby-identifier">ws_path</span>, <span class="ruby-value str">"w"</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">write</span>( <span class="ruby-identifier">string</span> ) } 230: <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">ws_path</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <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 p4table.rb, line 137</span> 137: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ws_path</span> 138: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@ws_path</span> <span class="ruby-keyword kw">if</span> ( <span class="ruby-ivar">@ws_path</span> ) 139: 140: <span class="ruby-identifier">root</span> = <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">fetch_client</span>[ <span class="ruby-value str">"Root"</span> ] 141: <span class="ruby-identifier">path</span> = <span class="ruby-identifier">depot_path</span>.<span class="ruby-identifier">sub</span>( <span class="ruby-constant">DEPOT_ROOT_PATH</span>, <span class="ruby-identifier">root</span> ) 142: <span class="ruby-ivar">@ws_path</span> = <span class="ruby-identifier">path</span>.<span class="ruby-identifier">gsub!</span>( <span class="ruby-value str">"/"</span>, <span class="ruby-constant">SEP</span> ) 143: <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 | |
---|---|---|---|---|---|
#2 | 4678 | Tony Smith |
Update p4table.rb to use the new spec parsing and formatting features of P4Ruby. This means we now only need one Perforce client instance to handle specs in both hash form and text form. |
||
#1 | 4677 | Tony Smith |
Move P4table.rb to the P4Ruby library and rename it to p4table.rb instead. There's an update coming so this is just the move. |