File Coverage

blib/lib/Liveman/MinillaPod2Markdown.pm
Criterion Covered Total %
statement 19 21 90.4
branch 1 2 50.0
condition 2 6 33.3
subroutine 5 5 100.0
pod 3 3 100.0
total 30 37 81.0


line stmt bran cond sub pod time code
1             package Liveman::MinillaPod2Markdown;
2:
# Обманка для Minilla, чтобы скопировать Module в README.md 3:
4: use parent qw/Pod::Markdown/;
5:
6: use File::Slurper qw/read_text write_text/;
7:
8: sub new { bless {}, __PACKAGE__ }
9:
10: sub parse_from_file {
11: my ($self, $path) = @_;
12: $self->{pm_path} = $path;
13: $self->{path} = $path =~ s!\.pm$!.md!r;
14: $self
15: }
16:
17: sub as_markdown {
18: my ($self) = @_;
19:
20: my $md = read_text $self->{path};
21: my $pm = read_text $self->{pm_path};
22:
23: my $v = uc "version";
24: my ($md_version) = $md =~ /^#[ \t]+$v\s+([\w.-]{1,32})\s/m;
25: my ($pm_version) = $pm =~ /^our\s+\$$v\s*=\s*["']?([\w.-]{1,32})/m;
26:
27: if(defined $pm_version and defined $md_version and $pm_version ne $md_version) {
28: $md =~ s/(#[ \t]+$v\s+)([\w.-]{1,32})(\s)/$1$pm_version$3/;
29: write_text $self->{path}, $md;
30: }
31:
32: $md
33: }
34:
35: 1;
36:
37: __END__
38:
39: =encoding utf-8
40:
41: =head1 NAME
42:
43: Liveman::MinillaPod2Markdown - bung for Minilla. It not make README.md
44:
45: =head1 SYNOPSIS
46:
47: use Liveman::MinillaPod2Markdown;
48:
49: my $mark = Liveman::MinillaPod2Markdown->new;
50:
51: $mark->isa("Pod::Markdown") # -> 1
52:
53: use File::Slurper qw/write_text/;
54: write_text "X.md", "hi!";
55: write_text "X.pm", "our \$VERSION = 1.0;";
56:
57: $mark->parse_from_file("X.pm");
58: $mark->{path} # => X.md
59:
60: $mark->as_markdown # => hi!
61:
62: =head1 DESCRIPION
63:
64: Add C<markdown_maker = "Liveman::MinillaPod2Markdown"> to C<minil.toml>, and Minilla do'nt make README.md.
65:
66: =head1 SUBROUTINES
67:
68: =head2 as_markdown ()
69:
70: The bung.
71:
72: =head2 new ()
73:
74: The constructor.
75:
76: =head2 parse_from_file ($path)
77:
78: The bung.
79:
80: =head1 INSTALL
81:
82: For install this module in your system run next LL<https://metacpan.org/pod/App::cpm>:
83:
84: sudo cpm install -gvv Liveman::MinillaPod2Markdown
85:
86: =head1 AUTHOR
87:
88: Yaroslav O. Kosmina LL<mailto:dart@cpan.org>
89:
90: =head1 LICENSE
91:
92: ⚖ B<GPLv3>
93:
94: =head1 COPYRIGHT
95:
96: The Liveman::MinillaPod2Markdown module is copyright © 2023 Yaroslav O. Kosmina. Rusland. All rights reserved.
97: