MyCPAN::Indexer::Reporter::AsYAML - Save the result as a YAML file


MyCPAN-Indexer documentation Contained in the MyCPAN-Indexer distribution.

Index


Code Index:

NAME

Top

MyCPAN::Indexer::Reporter::AsYAML - Save the result as a YAML file

SYNOPSIS

Top

Use this in backpan_indexer.pl by specifying it as the reporter class:

	# in backpan_indexer.config
	reporter_class  MyCPAN::Indexer::Reporter::AsYAML

DESCRIPTION

Top

This class takes the result of examining a distribution and saves it.

Methods

get_reporter( $Notes )

get_reporter sets the reporter key in the $Notes hash reference. The value is a code reference that takes the information collected about a distribution and dumps it as a YAML file.

See MyCPAN::Indexer::Tutorial for details about what get_reporter expects and should do.

get_report_file_extension

Returns the extension for reports from this reporter. Since we're making YAML files, that's yml.

final_words( $Notes )

Right before backpan_indexer.pl is about to finish, it calls this method to give the reporter a chance to do something at the end. In this case it does nothing.

TO DO

Top

SOURCE AVAILABILITY

Top

This code is in Github:

	git://github.com/briandfoy/mycpan-indexer.git

AUTHOR

Top

brian d foy, <bdfoy@cpan.org>

COPYRIGHT AND LICENSE

Top


MyCPAN-Indexer documentation Contained in the MyCPAN-Indexer distribution.
package MyCPAN::Indexer::Reporter::AsYAML;
use strict;
use warnings;

use base qw(MyCPAN::Indexer::Reporter::Base);
use vars qw($VERSION $logger);
$VERSION = '1.28';

use Carp;
use File::Basename;
use File::Spec::Functions qw(catfile);
use Log::Log4perl;
use YAML;

BEGIN {
	$logger = Log::Log4perl->get_logger( 'Reporter' );
	}

sub component_type { $_[0]->reporter_type }

sub get_reporter
	{
	#TRACE( sub { get_caller_info } );

	my( $self ) = @_;

	my $reporter = sub {
		my( $info ) = @_;

		unless( defined $info )
			{
			$logger->error( "info is undefined!" );
			return;
			}

		my $out_path = $self->get_report_path( $info );

		open my($fh), ">", $out_path or $logger->fatal( "Could not open $out_path: $!" );
		print $fh Dump( $info );

		$logger->error( "$out_path is missing!" ) unless -e $out_path;

		1;
		};

	$self->set_note( 'reporter', $reporter );
	1;
	}

sub get_report_file_extension { 'yml' }

sub final_words { 1 };

1;