ASPEER-MakeMaker-Markdown-Publish

 view release on metacpan or  search on metacpan

cpanfile  view on Meta::CPAN

requires 'Cwd';
requires 'File::Basename';
requires 'File::Spec';
requires 'JSON::PP';
requires 'MIME::Base64';
requires 'Exporter';
requires 'strict';
requires 'vars';
requires 'warnings';
requires 'perl', '5.010';
on configure => sub {
    requires 'ExtUtils::MakeMaker';
    requires 'perl', '5.010';
    requires 'version';
};
on test => sub {
    requires 'Config';
    requires 'File::Path';
    requires 'File::Temp';
    requires 'Test::More';
};

lib/ASPEER/MakeMaker/Markdown/Publish.pm  view on Meta::CPAN

chomp($VERSION_GIT_SHA) if defined($VERSION_GIT_SHA);


#  Done
#
1;


#======================================================================================================================

sub import {


    #  Install documentation maintenance before wrapping the same MakeMaker
    #  sections with publication targets.
    #
    my ($class, @section)=@_;
    ASPEER::MakeMaker::Markdown::Pod->import(@section);
    return ASPEER::MakeMaker::import($class, @section);

}

lib/ASPEER/MakeMaker/Markdown/Publish/MM.pm  view on Meta::CPAN

$VERSION='1.004';


#  Done
#
1;


#======================================================================================================================

sub const_config {


    #  Retain the common MakeMaker behavior before adding this plugin's live
    #  x_documentation configuration to its private macro namespace.
    #
    my ($self, $mm_or, @param)=@_;
    my $const_config=ASPEER::MakeMaker::MM::Import::const_config(
        $self,
        $mm_or,
        @param

lib/ASPEER/MakeMaker/Markdown/Publish/MM.pm  view on Meta::CPAN

    if (defined($publish_hr) && ref($publish_hr) ne 'HASH') {
        die "META_MERGE.x_documentation.publish must be a hash reference\n";
    }
    $publish_hr={} unless defined($publish_hr);
    $mm_or->{'macro'}{'PUBLISH_CONFIG'}=encode_base64(encode_json($publish_hr), '');
    return $const_config;

}


sub publish {


    #  Decode the Makefile-safe metadata payload and delegate the requested
    #  action without re-running Makefile.PL.
    #
    my ($self, $param_hr)=(shift(), arg(@_));
    my ($encoded, $action)=@{$param_hr->{'ARGV_AR'}};
    die "publication configuration unavailable\n"
        unless defined($encoded) && length($encoded);
    my $publish_hr=decode_json(decode_base64($encoded));

t/01-targets.t  view on Meta::CPAN

use Cwd qw(abs_path getcwd);
use File::Path qw(make_path);
use File::Temp qw(tempdir);
use JSON::PP qw(decode_json);
use MIME::Base64 qw(decode_base64);
use Test::More;

use ASPEER::MakeMaker::Markdown::Publish::MM;


sub blurp {

    my ($fn, $text)=@_;
    open(my $output_fh, '>', $fn) || die "unable to write $fn: $!";
    print {$output_fh} $text;
    close($output_fh) || die "unable to close $fn: $!";
    return 1;

}


sub slurp {

    my ($fn)=@_;
    open(my $input_fh, '<', $fn) || die "unable to read $fn: $!";
    local $/=undef;
    my $text=<$input_fh>;
    close($input_fh) || die "unable to close $fn: $!";
    return $text;

}

t/01-targets.t  view on Meta::CPAN

chdir($temporary_dn) || die "unable to chdir $temporary_dn: $!";
make_path('lib/Sample', 'doc', 'local lib/Markdown');
my $local_lib_dn=abs_path('local lib');


#  The runtime publisher stub records exactly what the generated target passes
#
blurp('local lib/Markdown/Publish.pm', <<'PUBLISH_STUB');
package Markdown::Publish;
use JSON::PP qw(encode_json);
sub new {my ($class, $config_hr)=@_; return bless({config => $config_hr}, $class)}
sub run {
    my ($self, $action)=@_;
    open(my $output_fh, '>>', 'target.log') || die "unable to write target log: $!";
    print {$output_fh} encode_json({config => $self->{'config'}, action => $action}), "\n";
    close($output_fh) || die "unable to close target log: $!";
    return 1;
}
1;
PUBLISH_STUB
blurp('lib/Sample.pm', "package Sample;\nour \$VERSION='0.001';\n1;\n");
blurp('lib/Sample.pm.md', "# NAME\n\nSample - generated documentation target fixture\n");



( run in 1.841 second using v1.01-cache-2.11-cpan-0e0213f3164 )