checktype_rb.html #2

  • //
  • guest/
  • tony_smith/
  • perforce/
  • P4Rubylib/
  • triggers/
  • doc/
  • files/
  • checktype_rb.html
  • View
  • Commits
  • Open Download .zip Download (4 KB)
<?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: checktype.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>checktype.rb</h1>
		<table class="header-table">
		<tr class="top-aligned-row">
			<td><strong>Path:</strong></td>
			<td>checktype.rb
			</td>
		</tr>
		<tr class="top-aligned-row">
			<td><strong>Last Update:</strong></td>
			<td>Fri Sep 26 16:43:30 BST 2003</td>
		</tr>
		</table>
	</div>
  <!-- banner header -->

	<div id="bodyContent">


	<div id="contextContent">

		<div id="description">
			<h1>Introduction</h1>
<h2>Name: checktype.rb</h2>
<h2>Author: Tony Smith &lt;tony@perforce.com&gt;</h2>
<h2>Description</h2>
<pre>
     Example trigger to enforce a rule &quot;files of suffix .x need
     to be added as type Z&quot;. (For example, &quot;.jpg&quot; files must
     always be &quot;binary&quot; and &quot;.sh&quot; files should always be &quot;text&quot;.)

     This script is mostly a reimplentation of Jeff Bowles
     and Wed Peters' Perl binary.pl using P4Ruby but it uses
     a more generalised trigger execution framework to make
     it easier to concentrate on the nuts and bolts of what
     your trigger does.
</pre>
<h2>Requires</h2>
<pre>
     Ruby
     P4Ruby
     P4Triggers module
</pre>
<h2>Example &#8216;triggers&#8217; section:</h2>
<pre>
     Note: since this is applicable to only filenames with certain suffixes,
     you might want to restrict the trigger to run when those files are
     submitted. So, if this is looking at .cpp/.h/.txt/.html lines, you might
     want to have it run only on those files.)

     Triggers:
       exampleB  //.../*.jpg  &quot;ruby whatever/checktype.rb %changelist%&quot;
       exampleB  //.../*.bmp  &quot;ruby whatever/checktype.rb %changelist%&quot;
       exampleB  //.../*.sh   &quot;ruby whatever/checktype.rb %changelist%&quot;
</pre>
<h2>Note</h2>
<pre>
     For triggers I recommend you use a P4CONFIG file rather than hard coding
     username/password in the script itself. This script assumes you've taken
     that advice.
</pre>

		</div>

		<div id="requires-list">
			<h2 class="section-bar">Required files</h2>

			<div class="name-list">
			<a href="../classes/P4.html">P4</a>&nbsp;&nbsp;
			<a href="P4Triggers_rb.html">P4Triggers</a>&nbsp;&nbsp;
			</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">TYPEMAP</td>
					<td>=</td>
					<td class="context-item-value">Hash.new</td>
				</tr>
				<tr class="top-aligned-row context-row">
					<td>&nbsp;</td>
					<td colspan="2" class="context-item-desc">
These are the file extensions and the Perforce types we want to enforce.
For each one we specify a regular expression for matching the valid
filetypes for the extension and a corresponding textual description of the
match (so we can tell the user what we&#8217;re looking for.

</td>
				</tr>
				</table>
			</div>
		</div>



			
		<div id="class-list">
			<h2 class="section-bar">Classes and Modules</h2>

			Class <a href="../classes/TypeTrigger.html" class="link">TypeTrigger</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
#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.