File Coverage

blib/lib/Pod/Elemental/Command.pm
Criterion Covered Total %
statement 6 9 66.6
branch 2 2 100.0
condition n/a
subroutine 2 3 66.6
pod 0 2 0.0
total 10 16 62.5


line stmt bran cond sub pod time code
1             package Pod::Elemental::Command 0.103006;
2             # ABSTRACT: a =command paragraph
3              
4 15     15   8457 use Moose::Role 0.90;
  15         9416  
  15         107  
5             with 'Pod::Elemental::Paragraph' => { -excludes => [ 'as_pod_string' ] };
6              
7             #pod =head1 OVERVIEW
8             #pod
9             #pod This is a role to be included by paragraph classes that represent Pod commands.
10             #pod It defines C<as_pod_string> and C<as_debug_string> methods. Most code looking
11             #pod for commands will check for the inclusion of this role, so be sure to use it
12             #pod even if you override the provided methods. Classes implementing this role must
13             #pod also provide a C<command> method. Generally this method will implemented by
14             #pod an attribute, but this is not necessary.
15             #pod
16             #pod =cut
17              
18             requires 'command';
19              
20             sub as_pod_string {
21 32     32 0 81 my ($self) = @_;
22              
23 32         841 my $content = $self->content;
24              
25 32 100       1073 sprintf "=%s%s", $self->command, ($content =~ /\S/ ? " $content" : $content);
26             }
27              
28             sub as_debug_string {
29 0     0 0   my ($self) = @_;
30 0           my $str = $self->_summarize_string($self->content);
31 0           return sprintf '=%s %s', $self->command, $str;
32             }
33              
34             1;
35              
36             __END__
37              
38             =pod
39              
40             =encoding UTF-8
41              
42             =head1 NAME
43              
44             Pod::Elemental::Command - a =command paragraph
45              
46             =head1 VERSION
47              
48             version 0.103006
49              
50             =head1 OVERVIEW
51              
52             This is a role to be included by paragraph classes that represent Pod commands.
53             It defines C<as_pod_string> and C<as_debug_string> methods. Most code looking
54             for commands will check for the inclusion of this role, so be sure to use it
55             even if you override the provided methods. Classes implementing this role must
56             also provide a C<command> method. Generally this method will implemented by
57             an attribute, but this is not necessary.
58              
59             =head1 PERL VERSION
60              
61             This library should run on perls released even a long time ago. It should work
62             on any version of perl released in the last five years.
63              
64             Although it may work on older versions of perl, no guarantee is made that the
65             minimum required version will not be increased. The version may be increased
66             for any reason, and there is no promise that patches will be accepted to lower
67             the minimum required perl.
68              
69             =head1 AUTHOR
70              
71             Ricardo SIGNES <cpan@semiotic.systems>
72              
73             =head1 COPYRIGHT AND LICENSE
74              
75             This software is copyright (c) 2022 by Ricardo SIGNES.
76              
77             This is free software; you can redistribute it and/or modify it under
78             the same terms as the Perl 5 programming language system itself.
79              
80             =cut