Ricardo SIGNES > Metabase-Fact-0.001 > Metabase::Report

Download:
Metabase-Fact-0.001.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.001   Source   Latest Release: Metabase-Fact-0.024

NAME ^

Metabase::Report - a base class for collections of Metabase facts

SYNOPSIS ^

  package MyReport;

  use base 'Metabase::Report';
  __PACKAGE__->load_fact_classes;

  sub report_spec {
    return {
      'Fact::One' => 1,     # one of Fact::One
      'Fact::Two' => "0+",  # zero or more of Fact::Two
    }
  }

DESCRIPTION ^

Metabase is a system for associating metadata with CPAN distributions. The metabase can be used to store test reports, reviews, coverage analysis reports, reports on static analysis of coding style, or anything else for which datatypes are constructed.

Metabase::Report is a base class for collections of Metabase::Fact objects that can be sent to or retrieved from a Metabase system.

Metabase::Report is itself a subclass of Metabase::Fact and offers the same API, except as described below.

SUBCLASSING ^

A subclass of Metabase::Report only requires one method, "report_spec".

ATTRIBUTES ^

content

The content attribute of a Report must be a reference to an array of Metabase::Fact subclass objects.

METHODS ^

In addition to the standard new constructor, the following open, add and close methods may be used to construct a report piecemeal, instead.

open

  $report = Report::Subclass->open(
    id => 'AUTHORID/Foo-Bar-1.23.tar.gz',
  );

Constructs a new, empty report. The 'id' attribute is required. The 'refers_to' attribute is optional. The 'content' attribute may be provided, but see add below. No other attributes may be provided to new.

add

  $report->add( 'Fact::Subclass' => $content );

Using the 'id' attribute of the report, this method constructs a new Fact from a class and a content argument. The resulting Fact is appended to the Report's content array.

close

  $report->close;

This method validates the report based on all Facts added so far.

facts

This method returns a list of all the facts in the report. In scalar context, it returns the number of facts in the report.

CLASS METHODS ^

fact_classes

load_fact_classes

Loads each class listed in the report spec.

ABSTRACT METHODS ^

Methods marked as 'required' must be implemented by a report subclass. (The version in Metabase::Report will die with an error if called.)

In the documentation below, the terms 'must, 'must not', 'should', etc. have their usual RFC 2119 meanings.

Methods MUST throw an exception if an error occurs.

report_spec

required

  $spec = Report::Subclass->report_spec;

The report_spec method MUST return a hash reference that defines how many Facts of which types must be in the report for it to be considered valid. Keys MUST be class names. Values MUST be non-negative integers that indicate the number of Facts of that type that must be present for a report to be valid, optionally followed by a '+' character to indicate that the report may contain more than the given number.

For example:

  {
    Fact::One => 1,     # one of Fact::One
    Fact::Two => "0+",  # zero or more of Fact::Two
  }

BUGS ^

Please report any bugs or feature using the CPAN Request Tracker. Bugs can be submitted through the web interface at http://rt.cpan.org/Dist/Display.html?Queue=Metabase-Fact

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHOR ^

COPYRIGHT AND LICENSE ^

  Portions copyright (c) 2008 by David A. Golden
  Portions copyright (c) 2008 by Ricardo J. B. Signes

Licensed under the same terms as Perl itself (the "License"). You may not use this file except in compliance with the License. A copy of the License was distributed with this file or you may obtain a copy of the License from http://dev.perl.org/licenses/

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

syntax highlighting: