<?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: P4Record</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>P4Record <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> <ul> <li>Main record manipulation class. Handles the loading and saving of record </li> <li>as both jobs and files. </li> </ul> <p> ******************************************************************************* </p> </div> <div id="method-list"> <h2 class="section-bar">Methods</h2> <div class="name-list"> <a href="#M000040">abandon</a> <a href="#M000038">add_file</a> <a href="#M000030">create</a> <a href="#M000043">delete</a> <a href="#M000037">each_file</a> <a href="#M000034">exists=</a> <a href="#M000033">exists?</a> <a href="#M000031">exists?</a> <a href="#M000041">file_list</a> <a href="#M000035">get_file</a> <a href="#M000028">load</a> <a href="#M000036">metafile</a> <a href="#M000045">method_missing</a> <a href="#M000032">new</a> <a href="#M000044">obliterate</a> <a href="#M000029">query</a> <a href="#M000039">rm_file</a> <a href="#M000042">save</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">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">id</td> <td class="context-item-value"> [RW] </td> <td class="context-item-desc"> *************************************************************************** <pre> Instance methods </pre> <p> *************************************************************************** </p> </td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">meta</td> <td class="context-item-value"> [RW] </td> <td class="context-item-desc"> *************************************************************************** <pre> Instance methods </pre> <p> *************************************************************************** </p> </td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">p4</td> <td class="context-item-value"> [RW] </td> <td class="context-item-desc"> *************************************************************************** <pre> Instance methods </pre> <p> *************************************************************************** </p> </td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">seq</td> <td class="context-item-value"> [RW] </td> <td class="context-item-desc"> *************************************************************************** <pre> Instance methods </pre> <p> *************************************************************************** </p> </td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">spec</td> <td class="context-item-value"> [RW] </td> <td class="context-item-desc"> *************************************************************************** <pre> Instance methods </pre> <p> *************************************************************************** </p> </td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">table</td> <td class="context-item-value"> [RW] </td> <td class="context-item-desc"> *************************************************************************** <pre> Instance methods </pre> <p> *************************************************************************** </p> </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-M000030" class="method-detail"> <a name="M000030"></a> <div class="method-heading"> <a href="#M000030" class="method-signature"> <span class="method-name">create</span><span class="method-args">( p4, table )</span> </a> </div> <div class="method-description"> <p><a class="source-toggle" href="#" onclick="toggleCode('M000030-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000030-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 315</span> 315: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">P4Record</span>.<span class="ruby-identifier">create</span>( <span class="ruby-identifier">p4</span>, <span class="ruby-identifier">table</span> ) 316: <span class="ruby-identifier">id</span> = <span class="ruby-constant">P4RecId</span>.<span class="ruby-identifier">next</span>( <span class="ruby-identifier">p4</span>, <span class="ruby-identifier">table</span> ) 317: <span class="ruby-identifier">rec</span> = <span class="ruby-constant">P4Record</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">p4</span>, <span class="ruby-identifier">table</span>, <span class="ruby-identifier">id</span> ) 318: <span class="ruby-identifier">rec</span>.<span class="ruby-identifier">spec</span> = <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">fetch_job</span>( <span class="ruby-identifier">id</span>.<span class="ruby-identifier">to_s</span> ) 319: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">rec</span> 320: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div id="method-M000031" class="method-detail"> <a name="M000031"></a> <div class="method-heading"> <a href="#M000031" class="method-signature"> <span class="method-name">exists?</span><span class="method-args">( p4, id )</span> </a> </div> <div class="method-description"> <p><a class="source-toggle" href="#" onclick="toggleCode('M000031-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000031-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 325</span> 325: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">P4Record</span>.<span class="ruby-identifier">exists?</span>( <span class="ruby-identifier">p4</span>, <span class="ruby-identifier">id</span> ) 326: <span class="ruby-identifier">jobs</span> = <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">run_jobs</span>( <span class="ruby-value str">"-e"</span>, <span class="ruby-value str">"job="</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">id</span>.<span class="ruby-identifier">to_s</span> ) 327: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">jobs</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">></span> <span class="ruby-value">0</span> 328: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div id="method-M000028" class="method-detail"> <a name="M000028"></a> <div class="method-heading"> <a href="#M000028" class="method-signature"> <span class="method-name">load</span><span class="method-args">( p4, table, id )</span> </a> </div> <div class="method-description"> <p><a class="source-toggle" href="#" onclick="toggleCode('M000028-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000028-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 268</span> 268: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">P4Record</span>.<span class="ruby-identifier">load</span>( <span class="ruby-identifier">p4</span>, <span class="ruby-identifier">table</span>, <span class="ruby-identifier">id</span> ) 269: 270: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span> <span class="ruby-constant">P4Record</span>.<span class="ruby-identifier">exists?</span>( <span class="ruby-identifier">p4</span>, <span class="ruby-identifier">id</span> ) ) 271: <span class="ruby-identifier">raise</span>( <span class="ruby-constant">RuntimeError</span>, <span class="ruby-node">"Record #{id.to_s} does not exist"</span>, <span class="ruby-identifier">caller</span> ) 272: <span class="ruby-keyword kw">end</span> 273: 274: <span class="ruby-identifier">rec</span> = <span class="ruby-constant">P4Record</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">p4</span>, <span class="ruby-identifier">table</span>, <span class="ruby-identifier">id</span> ) 275: <span class="ruby-identifier">rec</span>.<span class="ruby-identifier">spec</span> = <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">fetch_job</span>( <span class="ruby-identifier">id</span>.<span class="ruby-identifier">to_s</span> ) 276: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rec</span>.<span class="ruby-identifier">spec</span>.<span class="ruby-identifier">has_key?</span>( <span class="ruby-value str">"files"</span> ) 277: <span class="ruby-identifier">rec</span>.<span class="ruby-identifier">spec</span>[ <span class="ruby-value str">"files"</span> ].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> 278: <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span> 279: <span class="ruby-identifier">name</span> = <span class="ruby-identifier">file</span>.<span class="ruby-identifier">sub</span>( <span class="ruby-regexp re">/.*\//</span>, <span class="ruby-value str">""</span> ).<span class="ruby-identifier">chomp</span> 280: <span class="ruby-identifier">f</span> = <span class="ruby-constant">P4RecFile</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">p4</span>, <span class="ruby-identifier">name</span>, <span class="ruby-identifier">rec</span> ) 281: <span class="ruby-identifier">f</span>.<span class="ruby-identifier">exists</span> = <span class="ruby-keyword kw">true</span> 282: <span class="ruby-identifier">f</span>.<span class="ruby-identifier">depot_path</span> = <span class="ruby-identifier">file</span>.<span class="ruby-identifier">chomp</span> 283: <span class="ruby-identifier">rec</span>.<span class="ruby-identifier">files</span>[ <span class="ruby-identifier">name</span> ] = <span class="ruby-identifier">f</span> 284: <span class="ruby-keyword kw">end</span> 285: <span class="ruby-keyword kw">end</span> 286: <span class="ruby-identifier">rec</span>.<span class="ruby-identifier">exists</span> = <span class="ruby-keyword kw">true</span> 287: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">rec</span> 288: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div id="method-M000032" class="method-detail"> <a name="M000032"></a> <div class="method-heading"> <a href="#M000032" class="method-signature"> <span class="method-name">new</span><span class="method-args">( p4, table, id )</span> </a> </div> <div class="method-description"> <p><a class="source-toggle" href="#" onclick="toggleCode('M000032-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000032-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 333</span> 333: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>( <span class="ruby-identifier">p4</span>, <span class="ruby-identifier">table</span>, <span class="ruby-identifier">id</span> ) 334: <span class="ruby-ivar">@p4</span> = <span class="ruby-identifier">p4</span> 335: <span class="ruby-ivar">@id</span> = <span class="ruby-identifier">id</span> 336: <span class="ruby-ivar">@seq</span> = <span class="ruby-identifier">id</span>.<span class="ruby-identifier">seq</span> 337: <span class="ruby-ivar">@table</span> = <span class="ruby-identifier">table</span> 338: <span class="ruby-ivar">@spec</span> = <span class="ruby-keyword kw">nil</span> 339: <span class="ruby-ivar">@exists</span> = <span class="ruby-keyword kw">false</span> 340: <span class="ruby-ivar">@files</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span> 341: 342: <span class="ruby-ivar">@files</span>[ <span class="ruby-value str">"meta"</span> ] = <span class="ruby-constant">P4RecFile</span>.<span class="ruby-identifier">new</span>( <span class="ruby-ivar">@p4</span>, <span class="ruby-value str">"meta"</span>, <span class="ruby-keyword kw">self</span> ) 343: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div id="method-M000029" class="method-detail"> <a name="M000029"></a> <div class="method-heading"> <a href="#M000029" class="method-signature"> <span class="method-name">query</span><span class="method-args">( p4, table, expr )</span> </a> </div> <div class="method-description"> <p><a class="source-toggle" href="#" onclick="toggleCode('M000029-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000029-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 293</span> 293: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">P4Record</span>.<span class="ruby-identifier">query</span>( <span class="ruby-identifier">p4</span>, <span class="ruby-identifier">table</span>, <span class="ruby-identifier">expr</span> ) 294: <span class="ruby-identifier">expr</span> = <span class="ruby-node">"job=#{table} & ( "</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">expr</span> <span class="ruby-operator">+</span> <span class="ruby-value str">" )"</span> 295: <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">run_jobs</span>( <span class="ruby-value str">"-e"</span>, <span class="ruby-identifier">expr</span> ).<span class="ruby-identifier">collect</span> <span class="ruby-keyword kw">do</span> 296: <span class="ruby-operator">|</span><span class="ruby-identifier">job</span><span class="ruby-operator">|</span> 297: <span class="ruby-identifier">rec</span> = <span class="ruby-constant">P4Record</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">p4</span>, <span class="ruby-identifier">table</span>, <span class="ruby-constant">P4RecId</span>.<span class="ruby-identifier">new_from_job</span>( <span class="ruby-identifier">p4</span>,<span class="ruby-identifier">job</span>[<span class="ruby-value str">"Job"</span>])) 298: <span class="ruby-identifier">rec</span>.<span class="ruby-identifier">spec</span> = <span class="ruby-identifier">job</span> 299: <span class="ruby-identifier">rec</span>.<span class="ruby-identifier">spec</span>[ <span class="ruby-value str">"files"</span> ].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> 300: <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span> 301: <span class="ruby-identifier">name</span> = <span class="ruby-identifier">file</span>.<span class="ruby-identifier">sub</span>( <span class="ruby-regexp re">/.*\//</span>, <span class="ruby-value str">""</span> ).<span class="ruby-identifier">chomp</span> 302: <span class="ruby-identifier">f</span> = <span class="ruby-constant">P4RecFile</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">p4</span>, <span class="ruby-identifier">name</span>, <span class="ruby-identifier">id</span> ) 303: <span class="ruby-identifier">f</span>.<span class="ruby-identifier">exists</span> = <span class="ruby-keyword kw">true</span> 304: <span class="ruby-identifier">f</span>.<span class="ruby-identifier">depot_path</span> = <span class="ruby-identifier">file</span> 305: <span class="ruby-identifier">rec</span>.<span class="ruby-identifier">files</span>[ <span class="ruby-identifier">name</span> ] = <span class="ruby-identifier">f</span> 306: <span class="ruby-keyword kw">end</span> 307: <span class="ruby-identifier">rec</span>.<span class="ruby-identifier">exists</span> = <span class="ruby-keyword kw">true</span> 308: <span class="ruby-identifier">rec</span> 309: <span class="ruby-keyword kw">end</span> 310: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <h2 class="section-bar">Public Instance methods</h2> <div id="method-M000040" class="method-detail"> <a name="M000040"></a> <div class="method-heading"> <a href="#M000040" class="method-signature"> <span class="method-name">abandon</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p><a class="source-toggle" href="#" onclick="toggleCode('M000040-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000040-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 418</span> 418: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">abandon</span> 419: <span class="ruby-identifier">each_file</span> <span class="ruby-keyword kw">do</span> 420: <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> 421: <span class="ruby-identifier">fs</span> = <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">run_fstat</span>( <span class="ruby-identifier">f</span>.<span class="ruby-identifier">ws_path</span> ) 422: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">fs</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">fs</span>[ <span class="ruby-value str">"action"</span> ] <span class="ruby-operator">==</span> <span class="ruby-value str">"add"</span> ) 423: <span class="ruby-constant">File</span>.<span class="ruby-identifier">unlink</span>( <span class="ruby-identifier">f</span>.<span class="ruby-identifier">ws_path</span> ) 424: <span class="ruby-keyword kw">end</span> 425: <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">run_revert</span>( <span class="ruby-identifier">f</span>.<span class="ruby-identifier">depot_path</span> ) 426: <span class="ruby-keyword kw">end</span> 427: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div id="method-M000038" class="method-detail"> <a name="M000038"></a> <div class="method-heading"> <a href="#M000038" class="method-signature"> <span class="method-name">add_file</span><span class="method-args">( name )</span> </a> </div> <div class="method-description"> <p><a class="source-toggle" href="#" onclick="toggleCode('M000038-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000038-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 392</span> 392: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_file</span>( <span class="ruby-identifier">name</span> ) 393: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"meta"</span> ) 394: <span class="ruby-identifier">raise</span>( <span class="ruby-constant">RuntimeError</span>, <span class="ruby-value str">"The meta file already exists."</span>, <span class="ruby-identifier">caller</span> ) 395: <span class="ruby-keyword kw">end</span> 396: 397: <span class="ruby-identifier">nfile</span> = <span class="ruby-constant">P4RecFile</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">p4</span>, <span class="ruby-identifier">name</span>, <span class="ruby-keyword kw">self</span> ) 398: <span class="ruby-identifier">nfile</span>.<span class="ruby-identifier">add</span> 399: <span class="ruby-ivar">@files</span>[ <span class="ruby-value str">"name"</span> ] = <span class="ruby-identifier">nfile</span> 400: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div id="method-M000043" class="method-detail"> <a name="M000043"></a> <div class="method-heading"> <a href="#M000043" class="method-signature"> <span class="method-name">delete</span><span class="method-args">( desc )</span> </a> </div> <div class="method-description"> <p><a class="source-toggle" href="#" onclick="toggleCode('M000043-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000043-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 470</span> 470: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete</span>( <span class="ruby-identifier">desc</span> ) 471: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span> <span class="ruby-identifier">exists?</span> ) 472: <span class="ruby-identifier">raise</span>( <span class="ruby-constant">RuntimeError</span>, <span class="ruby-value str">"Can't delete. Record doesn't exist."</span>, <span class="ruby-identifier">caller</span> ) 473: <span class="ruby-keyword kw">end</span> 474: 475: <span class="ruby-ivar">@files</span>.<span class="ruby-identifier">values</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-identifier">f</span>.<span class="ruby-identifier">delete</span> } 476: <span class="ruby-identifier">change</span> = <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">fetch_change</span> 477: <span class="ruby-identifier">change</span>[ <span class="ruby-value str">"Description"</span> ] = <span class="ruby-identifier">desc</span> 478: <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">submit_spec</span>( <span class="ruby-identifier">change</span> ) 479: <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">run_job</span>( <span class="ruby-value str">"-d"</span>, <span class="ruby-ivar">@spec</span>[ <span class="ruby-value str">"Job"</span> ] ) 480: <span class="ruby-ivar">@files</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span> 481: <span class="ruby-ivar">@spec</span>[ <span class="ruby-value str">"files"</span> ] = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span> 482: <span class="ruby-ivar">@exists</span> = <span class="ruby-keyword kw">false</span> 483: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div id="method-M000037" class="method-detail"> <a name="M000037"></a> <div class="method-heading"> <a href="#M000037" class="method-signature"> <span class="method-name">each_file</span><span class="method-args">() {|f| ...}</span> </a> </div> <div class="method-description"> <p><a class="source-toggle" href="#" onclick="toggleCode('M000037-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000037-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 385</span> 385: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">each_file</span> 386: <span class="ruby-ivar">@files</span>.<span class="ruby-identifier">each_value</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> ) } 387: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div id="method-M000034" class="method-detail"> <a name="M000034"></a> <div class="method-heading"> <a href="#M000034" 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('M000034-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000034-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 362</span> 362: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">exists=</span>( <span class="ruby-identifier">bool</span> ) 363: <span class="ruby-ivar">@exists</span> = <span class="ruby-identifier">bool</span> 364: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div id="method-M000033" class="method-detail"> <a name="M000033"></a> <div class="method-heading"> <a href="#M000033" 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('M000033-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000033-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 355</span> 355: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">exists?</span> 356: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@exists</span> 357: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div id="method-M000041" class="method-detail"> <a name="M000041"></a> <div class="method-heading"> <a href="#M000041" class="method-signature"> <span class="method-name">file_list</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p><a class="source-toggle" href="#" onclick="toggleCode('M000041-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000041-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 432</span> 432: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">file_list</span> 433: <span class="ruby-ivar">@files</span>.<span class="ruby-identifier">values</span>.<span class="ruby-identifier">collect</span> <span class="ruby-keyword kw">do</span> 434: <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> 435: <span class="ruby-identifier">f</span>.<span class="ruby-identifier">depot_path</span> 436: <span class="ruby-keyword kw">end</span>.<span class="ruby-identifier">compact</span>.<span class="ruby-identifier">join</span>( <span class="ruby-value str">"\n"</span> ) 437: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div id="method-M000035" class="method-detail"> <a name="M000035"></a> <div class="method-heading"> <a href="#M000035" class="method-signature"> <span class="method-name">get_file</span><span class="method-args">( name )</span> </a> </div> <div class="method-description"> <p><a class="source-toggle" href="#" onclick="toggleCode('M000035-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000035-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 370</span> 370: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_file</span>( <span class="ruby-identifier">name</span> ) 371: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@files</span>[ <span class="ruby-identifier">name</span> ] <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@files</span>.<span class="ruby-identifier">has_key?</span>( <span class="ruby-identifier">name</span> ) 372: <span class="ruby-identifier">raise</span>( <span class="ruby-constant">RuntimeError</span>, <span class="ruby-node">"Record contains no file called #{name}"</span>, <span class="ruby-identifier">caller</span> ) 373: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div id="method-M000036" class="method-detail"> <a name="M000036"></a> <div class="method-heading"> <a href="#M000036" class="method-signature"> <span class="method-name">metafile</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p><a class="source-toggle" href="#" onclick="toggleCode('M000036-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000036-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 378</span> 378: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">metafile</span> 379: <span class="ruby-identifier">get_file</span>( <span class="ruby-value str">"meta"</span> ) 380: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div id="method-M000045" class="method-detail"> <a name="M000045"></a> <div class="method-heading"> <a href="#M000045" class="method-signature"> <span class="method-name">method_missing</span><span class="method-args">( meth, *args )</span> </a> </div> <div class="method-description"> <p><a class="source-toggle" href="#" onclick="toggleCode('M000045-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000045-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 513</span> 513: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">method_missing</span>( <span class="ruby-identifier">meth</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span> ) 514: <span class="ruby-identifier">meth</span> = <span class="ruby-identifier">meth</span>.<span class="ruby-identifier">to_s</span> 515: <span class="ruby-identifier">raise</span> <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">meth</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">0</span>] <span class="ruby-operator">!=</span> <span class="ruby-value str">"_"</span> ) 516: <span class="ruby-identifier">meth</span> = <span class="ruby-identifier">meth</span>[ <span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span> ] 517: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">meth</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^(.*)=$/</span> ) 518: <span class="ruby-identifier">meth</span> = <span class="ruby-identifier">$1</span> 519: <span class="ruby-ivar">@spec</span>[ <span class="ruby-identifier">meth</span> ] = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">shift</span> 520: <span class="ruby-keyword kw">elsif</span> ( <span class="ruby-identifier">args</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-operator">&&</span> <span class="ruby-ivar">@spec</span>.<span class="ruby-identifier">has_key?</span>( <span class="ruby-identifier">meth</span> ) ) 521: <span class="ruby-ivar">@spec</span>[ <span class="ruby-identifier">meth</span> ] 522: <span class="ruby-keyword kw">else</span> 523: <span class="ruby-value str">""</span> 524: <span class="ruby-keyword kw">end</span> 525: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div id="method-M000044" class="method-detail"> <a name="M000044"></a> <div class="method-heading"> <a href="#M000044" class="method-signature"> <span class="method-name">obliterate</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p><a class="source-toggle" href="#" onclick="toggleCode('M000044-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000044-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 489</span> 489: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">obliterate</span> 490: <span class="ruby-keyword kw">if</span> ( <span class="ruby-operator">!</span> <span class="ruby-identifier">exists?</span> ) 491: <span class="ruby-identifier">raise</span>( <span class="ruby-constant">RuntimeError</span>, <span class="ruby-value str">"Can't oblit. Record doesn't exist."</span>, <span class="ruby-identifier">caller</span> ) 492: <span class="ruby-keyword kw">end</span> 493: 494: <span class="ruby-identifier">args</span> = <span class="ruby-ivar">@files</span>.<span class="ruby-identifier">values</span>.<span class="ruby-identifier">collect</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">depot_path</span> } 495: <span class="ruby-identifier">el</span> = <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">exception_level?</span> 496: <span class="ruby-keyword kw">begin</span> 497: <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">exception_level</span> = <span class="ruby-value">1</span> 498: <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">run_sync</span>( <span class="ruby-identifier">args</span>.<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span> <span class="ruby-identifier">a</span> <span class="ruby-operator">+=</span> <span class="ruby-value str">"#none"</span> } ) 499: <span class="ruby-keyword kw">ensure</span> 500: <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">exception_level</span> = <span class="ruby-identifier">el</span> 501: <span class="ruby-keyword kw">end</span> 502: <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">run_obliterate</span>( <span class="ruby-value str">"-y"</span>, <span class="ruby-identifier">args</span> ) 503: <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">run_job</span>( <span class="ruby-value str">"-d"</span>, <span class="ruby-ivar">@spec</span>[ <span class="ruby-value str">"Job"</span> ] ) 504: <span class="ruby-ivar">@spec</span>[ <span class="ruby-value str">"files"</span> ] = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span> 505: <span class="ruby-ivar">@files</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span> 506: <span class="ruby-ivar">@exists</span> = <span class="ruby-keyword kw">false</span> 507: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div id="method-M000039" class="method-detail"> <a name="M000039"></a> <div class="method-heading"> <a href="#M000039" class="method-signature"> <span class="method-name">rm_file</span><span class="method-args">( file )</span> </a> </div> <div class="method-description"> <p><a class="source-toggle" href="#" onclick="toggleCode('M000039-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000039-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 405</span> 405: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">rm_file</span>( <span class="ruby-identifier">file</span> ) 406: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">file</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"meta"</span> ) 407: <span class="ruby-identifier">raise</span>( <span class="ruby-constant">RuntimeError</span>, <span class="ruby-value str">"You can't delete the meta file"</span>, <span class="ruby-identifier">caller</span> ) 408: <span class="ruby-keyword kw">end</span> 409: 410: <span class="ruby-identifier">f</span> = <span class="ruby-identifier">get_file</span>( <span class="ruby-identifier">file</span> ) 411: <span class="ruby-identifier">f</span>.<span class="ruby-identifier">delete</span> 412: <span class="ruby-ivar">@files</span>.<span class="ruby-identifier">delete</span>( <span class="ruby-identifier">file</span> ) 413: <span class="ruby-keyword kw">end</span> </pre> </div> </div> </div> <div id="method-M000042" class="method-detail"> <a name="M000042"></a> <div class="method-heading"> <a href="#M000042" class="method-signature"> <span class="method-name">save</span><span class="method-args">( desc )</span> </a> </div> <div class="method-description"> <p><a class="source-toggle" href="#" onclick="toggleCode('M000042-source');return false;">[Source]</a></p> <div class="method-source-code" id="M000042-source"> <pre> <span class="ruby-comment cmt"># File p4table.rb, line 443</span> 443: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">save</span>( <span class="ruby-identifier">desc</span> ) 444: <span class="ruby-comment cmt"># First rewrite the files list in case it's been modified</span> 445: <span class="ruby-ivar">@spec</span>[ <span class="ruby-value str">"files"</span> ] = <span class="ruby-identifier">file_list</span> 446: 447: <span class="ruby-comment cmt"># Next update the job with the values in the spec</span> 448: <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">save_job</span>( <span class="ruby-ivar">@spec</span> ) 449: 450: <span class="ruby-comment cmt"># Now update the metafile with the job -o output</span> 451: <span class="ruby-keyword kw">if</span> ( <span class="ruby-identifier">exists?</span> ) 452: <span class="ruby-identifier">metafile</span>.<span class="ruby-identifier">edit</span> 453: <span class="ruby-keyword kw">else</span> 454: <span class="ruby-identifier">metafile</span>.<span class="ruby-identifier">add</span> 455: <span class="ruby-keyword kw">end</span> 456: 457: <span class="ruby-identifier">metafile</span>.<span class="ruby-identifier">write</span>( <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">format_job</span>( <span class="ruby-ivar">@spec</span> ) ) 458: 459: <span class="ruby-comment cmt"># Now submit</span> 460: <span class="ruby-identifier">change</span> = <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">fetch_change</span> 461: <span class="ruby-identifier">change</span>[ <span class="ruby-value str">"Description"</span> ] = <span class="ruby-identifier">desc</span> 462: <span class="ruby-identifier">p4</span>.<span class="ruby-identifier">submit_spec</span>( <span class="ruby-identifier">change</span> ) 463: 464: <span class="ruby-ivar">@exists</span> = <span class="ruby-keyword kw">true</span> 465: <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. |