| 1 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # This file is part of ASPEER::MakeMaker::Markdown::Publish. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # This software is copyright (c) 2026 by Andrew Speer <andrew.speer@isolutions.com.au>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # Full license text is available at: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # <http://dev.perl.org/licenses/> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | package ASPEER::MakeMaker::Markdown::Publish::MM; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # Compiler pragma and package variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | use strict qw(vars); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | use vars qw($VERSION @ISA); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # Shared MakeMaker implementation and configuration | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | use ASPEER::MakeMaker::MM (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | use ASPEER::MakeMaker::MM::Import (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | use ASPEER::MakeMaker::MM::Util; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | use ASPEER::MakeMaker::Markdown::Publish::MM::Constant (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | @ISA=qw(ASPEER::MakeMaker::MM); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # Configuration serialization stays inside the MakeMaker layer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | use JSON::PP qw(decode_json encode_json); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | use MIME::Base64 qw(decode_base64 encode_base64); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # Version information | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | $VERSION='1.004'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | # Done | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | #====================================================================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | sub const_config { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | # Retain the common MakeMaker behavior before adding this plugin's live | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | # x_documentation configuration to its private macro namespace. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 2 | ▶ | my ($self, $mm_or, @param)=@_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
const_config: called CC=8 SCAR=29.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 2 | my $const_config=ASPEER::MakeMaker::MM::Import::const_config( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | $self, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | $mm_or, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | @param | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 2 | ▶ | my $meta_hr=$mm_or->{'META_MERGE'} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$mm_or->{'META_MERGE'} || {}
MC/DC0%0/1
$mm_or->{'META_MERGE'} || {}
$mm_or->{'META_MERGE'}
Truth table0%0/2
A
A= $mm_or->{'META_MERGE'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 2 | my $documentation_hr=$meta_hr->{'x_documentation'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 2 | ▶ | if (defined($documentation_hr) && ref($documentation_hr) ne 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $documentation_hr and ref $documentation_hr ne "HASH"
MC/DC0%0/2
defined $documentation_hr and ref $documentation_hr ne "HASH"
defined $documentation_hr
ref $documentation_hr ne "HASH"
Truth table0%0/3
A and B
A= defined $documentation_hrB= ref $documentation_hr ne "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 2 | die "META_MERGE.x_documentation must be a hash reference\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 2 | ▶ | $documentation_hr={} unless defined($documentation_hr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 2 | my $publish_hr=$documentation_hr->{'publish'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 2 | ▶ | if (defined($publish_hr) && ref($publish_hr) ne 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $publish_hr and ref $publish_hr ne "HASH"
MC/DC0%0/2
defined $publish_hr and ref $publish_hr ne "HASH"
defined $publish_hr
ref $publish_hr ne "HASH"
Truth table0%0/3
A and B
A= defined $publish_hrB= ref $publish_hr ne "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 2 | die "META_MERGE.x_documentation.publish must be a hash reference\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 2 | ▶ | $publish_hr={} unless defined($publish_hr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 2 | $mm_or->{'macro'}{'PUBLISH_CONFIG'}=encode_base64(encode_json($publish_hr), ''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 2 | return $const_config; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | sub publish { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | # Decode the Makefile-safe metadata payload and delegate the requested | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | # action without re-running Makefile.PL. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 2 | ▶ | my ($self, $param_hr)=(shift(), arg(@_)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
publish: called CC=8 SCAR=31.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 2 | my ($encoded, $action)=@{$param_hr->{'ARGV_AR'}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 2 | ▶ | die "publication configuration unavailable\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $encoded and length $encoded
MC/DC0%0/2
defined $encoded and length $encoded
defined $encoded
length $encoded
Truth table0%0/3
A and B
A= defined $encodedB= length $encoded
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | unless defined($encoded) && length($encoded); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 2 | my $publish_hr=decode_json(decode_base64($encoded)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 2 | ▶ | die "publication configuration must decode to a hash reference\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | unless ref($publish_hr) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 2 | ▶ | if (!exists($publish_hr->{'name'}) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
not exists $publish_hr->{"name"} || exists $publish_hr->{"config_file"} and defined $param_hr->{"NAME"} and length $param_hr->{"NAME"}
not exists $publish_hr->{"name"} || exists $publish_hr->{"config_file"} and defined $param_hr->{"NAME"}
exists $publish_hr->{'name'} || exists $publish_hr->{'config_file'}
MC/DC0%0/4
not exists $publish_hr->{"name"} || exists $publish_hr->{"config_file"} and defined $param_hr->{"NAME"} and length $param_hr->{"NAME"}
exists $publish_hr->{'name'}
exists $publish_hr->{'config_file'}
defined $param_hr->{"NAME"}
length $param_hr->{"NAME"}
Truth table0%0/5
not(A || B) and C and D
A= exists $publish_hr->{'name'}B= exists $publish_hr->{'config_file'}C= defined $param_hr->{"NAME"}D= length $param_hr->{"NAME"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | !exists($publish_hr->{'config_file'}) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | defined($param_hr->{'NAME'}) && length($param_hr->{'NAME'})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 2 | $publish_hr->{'name'}=$param_hr->{'NAME'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 2 | require Markdown::Publish; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 2 | my $publish_or=Markdown::Publish->new($publish_hr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 2 | return $publish_or->run($action); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||