package.html

来自「perl教程」· HTML 代码 · 共 277 行

HTML
277
字号
<?xml version="1.0" ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<!-- saved from url=(0017)http://localhost/ -->
<script language="JavaScript" src="../../../displayToc.js"></script>
<script language="JavaScript" src="../../../tocParas.js"></script>
<script language="JavaScript" src="../../../tocTab.js"></script>
<link rel="stylesheet" type="text/css" href="../../../scineplex.css">
<title>ActivePerl::PPM::Package - Package class</title>
<link rel="stylesheet" href="../../../Active.css" type="text/css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:" />
</head>

<body>

<script>writelinks('__top__',3);</script>
<h1><a>ActivePerl::PPM::Package - Package class</a></h1>
<p><a name="__index__"></a></p>

<!-- INDEX BEGIN -->

<ul>

	<li><a href="#name">NAME</a></li>
	<li><a href="#synopsis">SYNOPSIS</a></li>
	<li><a href="#description">DESCRIPTION</a></li>
	<ul>

		<li><a href="#constructors">Constructors</a></li>
		<li><a href="#attributes">Attributes</a></li>
		<li><a href="#comparators">Comparators</a></li>
		<li><a href="#misc_methods">Misc methods</a></li>
	</ul>

	<li><a href="#bugs">BUGS</a></li>
</ul>
<!-- INDEX END -->

<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>ActivePerl::PPM::Package - Package class</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
  <span class="keyword">my</span> <span class="variable">$pkg</span> <span class="operator">=</span> <span class="variable">ActivePerl::PPM::Package</span><span class="operator">-&gt;</span><span class="variable">new</span><span class="operator">(</span><span class="string">name</span> <span class="operator">=&gt;</span> <span class="string">'Foo'</span><span class="operator">,...);</span>
  <span class="comment"># or</span>
  <span class="keyword">my</span> <span class="variable">$pkg</span> <span class="operator">=</span> <span class="variable">ActivePerl::PPM::Package</span><span class="operator">-&gt;</span><span class="variable">new</span><span class="operator">(\</span><span class="variable">%hash</span><span class="operator">);</span>
</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>The <code>ActivePerl::PPM::Package</code> class wraps hashes that describes
packages; the unit that the PPM system manages.</p>
<p>
</p>
<h2><a name="constructors">Constructors</a></h2>
<p>The following constructor methods are provided:</p>
<dl>
<dt><strong><a name="item_new">$pkg = ActivePerl::PPM::Package-&gt;new( %opt );</a></strong>

<dt><strong>$pkg = ActivePerl::PPM::Package-&gt;new( \%self );</strong>

<dd>
<p>The constructor either take key/value pairs or a hash reference as
argument.  The only mandatory field is <a href="#item_name"><code>name</code></a>.  If a hash reference
is passed then it is turned into an <code>ActivePerl::PPM::Package</code> object
and returned; which basically pass ownership of the hash.</p>
</dd>
</li>
<dt><strong><a name="item_clone">$copy = $pkg-&gt;clone</a></strong>

<dd>
<p>Returns a copy of the current package object.  The attributes of the
clone can be modified without changing the original.</p>
</dd>
</li>
<dt><strong><a name="item_new_dbi">ActivePerl::PPM::Package-&gt;new_dbi($dbh, $id);</a></strong>

<dt><strong>ActivePerl::PPM::Package-&gt;new_dbi($dbh, $name, $version);</strong>

<dd>
<p>Read object from a database and return it.  Returns <a href="../../../lib/Pod/perlfunc.html#item_undef"><code>undef</code></a> if no
package with the given key is found.</p>
</dd>
</li>
<dt><strong><a name="item_dbi_store">$pkg-&gt;dbi_store( $dbh )</a></strong>

<dd>
<p>Writes the current package to a database.  If $pkg was constructed by
<a href="#item_new_dbi"><code>new_dbi</code></a> then this updates the package, otherwise this creates a new
package object in the database.</p>
</dd>
<dd>
<p>Returns the $id of the object stored if successful, otherwise <a href="../../../lib/Pod/perlfunc.html#item_undef"><code>undef</code></a>.</p>
</dd>
</li>
</dl>
<p>
</p>
<h2><a name="attributes">Attributes</a></h2>
<p>The attributes of a package can be accessed directly using hash syntax
or by accesor methods.  The most common attributes are described
below, but the set of attributes is extensible.</p>
<dl>
<dt><strong><a name="item_id">$str = $pkg-&gt;id</a></strong>

<dd>
<p>Returns the database id of package.  This attribute is set if the
object exists in a database.</p>
</dd>
</li>
<dt><strong><a name="item_name">$str = $pkg-&gt;name</a></strong>

<dd>
<p>Returns the name of the package.</p>
</dd>
</li>
<dt><strong><a name="item_version">$str = $pkg-&gt;version</a></strong>

<dd>
<p>Returns the version identifier for the package.  This string
can be anything and there is no reliable way to order packages based
on these version strings.</p>
</dd>
</li>
<dt><strong><a name="item_name_version">$str = $pkg-&gt;name_version</a></strong>

<dd>
<p>Returns the name and version concatenated together.  This form might
be handy for display, but there is no reliable way to parse back what
is the name and what is the version identifier.</p>
</dd>
</li>
<dt><strong><a name="item_release_date">$str = $pkg-&gt;release_date</a></strong>

<dd>
<p>Returns the date the package was released on as an ISO 8601 date
(YYYY-MM-DDThh:mm:ss).  For CPAN packages this is the date the package
was uploaded to CPAN.</p>
</dd>
</li>
<dt><strong><a name="item_author">$str = $pkg-&gt;author</a></strong>

<dd>
<p>The name and email address of the current maintainer of the package.</p>
</dd>
</li>
<dt><strong><a name="item_abstract">$str = $pkg-&gt;abstract</a></strong>

<dd>
<p>A short sentence describing the purpose of the package.</p>
</dd>
</li>
<dt><strong><a name="item_ppd_uri">$url = $pkg-&gt;ppd_uri</a></strong>

<dd>
<p>This is the URI for the PPD file itself.</p>
</dd>
</li>
<dt><strong><a name="item_ppd_etag">$str = $pkg-&gt;ppd_etag</a></strong>

<dd>
<p>This is the <code>ETag</code> that the server reported for the PPD last time.</p>
</dd>
</li>
<dt><strong><a name="item_ppd_lastmod">$str = $pkg-&gt;ppd_lastmod</a></strong>

<dd>
<p>This is the <code>Last-Modified</code> field that the server reported for the
PPD last time.</p>
</dd>
</li>
<dt><strong><a name="item_codebase">$url = $pkg-&gt;codebase</a></strong>

<dd>
<p>Returns the URL to implementation; a blib tarball.
Interpret this URL relative to <em>ppd_uri</em>.</p>
</dd>
</li>
<dt><strong><a name="item_provides">%features = $pkg-&gt;provides</a></strong>

<dd>
<p>Returns a list of (feature, version) pairs describing what features
this package provide.  A feature name with a double colon in it
represent a perl module.  A package always provide its own name as a
feature.</p>
</dd>
</li>
<dt><strong><a name="item_requires">%features = $pkg-&gt;requires</a></strong>

<dd>
<p>Returns a list of (feature, version) pairs describing what features
this package require to be installed for it to work properly.  A
feature name with a double colon in it represent a perl module.</p>
</dd>
</li>
</dl>
<p>
</p>
<h2><a name="comparators">Comparators</a></h2>
<p>The following functions/methods can be used to order packages.</p>
<dl>
<dt><strong><a name="item_compare">$pkg-&gt;compare( $other )</a></strong>

<dd>
<p>Returns -1, 0, 1 like perl's builtin <code>cmp</code>.  Return <a href="../../../lib/Pod/perlfunc.html#item_undef"><code>undef</code></a> if no order is defined.</p>
</dd>
</li>
<dt><strong><a name="item_better_than">$pkg-&gt;better_than( $other )</a></strong>

<dd>
<p>Returns TRUE if this package is better than the package passed as
argument.  This method will croak if no order is defined.</p>
</dd>
</li>
<dt><strong><a name="item_best">$pkg-&gt;best( @others )</a></strong>

<dt><strong>ActivePerl::PPM::Package::best( @pkgs )</strong>

<dd>
<p>Returns the best package.  Might croak if no order is defined among
the packages passed in.</p>
</dd>
</li>
</dl>
<p>
</p>
<h2><a name="misc_methods">Misc methods</a></h2>
<dl>
<dt><strong><a name="item_sql_create_tables">ActivePerl::PPM::Package-&gt;sql_create_tables</a></strong>

<dd>
<p>This returns SQL <code>CREATE TABLE</code> statements used to initialize the
database that the <a href="#item_new_dbi"><code>new_dbi</code></a> and <a href="#item_dbi_store"><code>dbi_store</code></a> methods depend on.</p>
</dd>
</li>
<dt><strong><a name="item_features_declared">$bool = $pkg-&gt;features_declared</a></strong>

<dd>
<p>Returns TRUE if this package declare what features it provide.  PPM4
style packages should declare what modules and other features they
provide, but packages from older repositories might not.</p>
</dd>
</li>
<dt><strong><a name="item_has_script">$pkg-&gt;has_script( $kind )</a></strong>

<dd>
<p>Return TRUE if the package has the given $kind of script attached.
The $kind argument should be either &quot;install&quot; or &quot;uninstall&quot;.</p>
</dd>
</li>
<dt><strong><a name="item_run_script">$pkg-&gt;run_script( $kind, $area, $tmpdir, \%pkg_info )</a></strong>

<dd>
<p>Execute the given kind of script for the package.  The $kind argument
should be either &quot;install&quot; or &quot;uninstall&quot;.  The $kind and $area
argument must be provided.</p>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="bugs">BUGS</a></h1>
<p>none.</p>

</body>

</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?