<?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>File: p4table.rb</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="fileHeader"> <h1>p4table.rb</h1> <table class="header-table"> <tr class="top-aligned-row"> <td><strong>Path:</strong></td> <td>p4table.rb </td> </tr> <tr class="top-aligned-row"> <td><strong>Last Update:</strong></td> <td>Tue Dec 07 12:17:00 GMT 2004</td> </tr> </table> </div> <!-- banner header --> <div id="bodyContent"> <div id="contextContent"> <div id="description"> <h1>Introduction</h1> <p> Classes implementing a generic database model on top of plain text files stored in Perforce. </p> <p> Every record consists of fields/values and may have associated files. The data for each record is stored as both a job and a text file. The text file is always called <id>/record and any associated files are also stored alongside the record file. i.e. <id>/file1 <id>/file2. </p> <p> Each table name is a folder name and all records for that table are stored in text files under that folder. i.e. <table>/<id>/record </p> <p> All column names must also be fields in the jobspec so you can search for records using "p4 jobs -e". </p> <table> <tr><td valign="top"><b>NOTE</b>:</td><td>When creating your jobspec, make sure that <b>ALL</b> field names are in lowercase. Ruby likes method names to be lowercase and it fits better as well as reducing scope for errors. </td></tr> </table> <p> The job version of any record contains only the latest version of that record for searching purposes. </p> <table> <tr><td valign="top"><b>WARNING</b>:</td><td>This software is designed to have its OWN Perforce server to work with. <b>DO NOT USE IT AGAINST AN EXISTING PERFORCE SERVER.</b> </td></tr> </table> <p> For a quick start, take a look at the <a href="../classes/P4Table.html">P4Table</a> class as all your tables should be derived from it and the Jobspec rules below. </p> <h1>Jobspec Rules</h1> <p> When creating your jobspec observe the following rules for any chance of success. </p> <ul> <li>All fieldnames <b>must</b> be lowercase </li> <li>The jobspec must contain a field called "job" </li> <li>The jobspec <b>must</b> contain a field called "files" of type "text" </li> <li>Make most fields optional - especially if you have more than one table </li> <li>Do not use invalid preset values in your jobspec. i.e. a field which may only contain certain values but is deliberately initialised to an invalid value to force users to change it. P4/Ruby can’t handle jobspecs like this at the moment. </li> </ul> <h1>Jobspec Example</h1> <p> Below is the jobspec used for a FAX tracking application based on P4Ruby which should give you some idea of the possibilities. </p> <pre> # A Perforce Job Spec Specification. # # Updating this form can be dangerous! # See 'p4 help jobspec' for proper directions. Fields: 101 job word 32 required 102 status select 10 required 103 owner word 32 required 104 modified_date date 20 always 105 note text 0 optional 106 sender line 32 optional 107 fax_number line 32 optional 108 files text 80 optional 109 date_received date 20 once 110 date_closed date 20 optional Values: status open/closed Presets: status open owner $user modified_date $now date_received $now Comments: </pre> </div> <div id="requires-list"> <h2 class="section-bar">Required files</h2> <div class="name-list"> P4 </div> </div> <div id="constants-list"> <h2 class="section-bar">Constants</h2> <div class="name-list"> <table summary="Constants"> <tr class="top-aligned-row context-row"> <td class="context-item-name">SEP</td> <td>=</td> <td class="context-item-value">"\\"</td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">NL</td> <td>=</td> <td class="context-item-value">"\r\n"</td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">SEP</td> <td>=</td> <td class="context-item-value">"/"</td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">NL</td> <td>=</td> <td class="context-item-value">"\n"</td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">DEPOT_ROOT_PATH</td> <td>=</td> <td class="context-item-value">"//depot"</td> </tr> </table> </div> </div> <div id="class-list"> <h2 class="section-bar">Classes and Modules</h2> Class <a href="../classes/P4Global.html" class="link">P4Global</a><br /> Class <a href="../classes/P4RecFile.html" class="link">P4RecFile</a><br /> Class <a href="../classes/P4RecId.html" class="link">P4RecId</a><br /> Class <a href="../classes/P4Record.html" class="link">P4Record</a><br /> Class <a href="../classes/P4Table.html" class="link">P4Table</a><br /> </div> </div> <!-- if includes --> <!-- if method_list --> </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. |