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;
2             # ABSTRACT: a =command paragraph
3             $Pod::Elemental::Command::VERSION = '0.103005';
4 15     15   9941 use Moose::Role 0.90;
  15         10472  
  15         112  
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 82 my ($self) = @_;
22              
23 32         1021 my $content = $self->content;
24              
25 32 100       1015 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.103005
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 AUTHOR
60              
61             Ricardo SIGNES <rjbs@cpan.org>
62              
63             =head1 COPYRIGHT AND LICENSE
64              
65             This software is copyright (c) 2020 by Ricardo SIGNES.
66              
67             This is free software; you can redistribute it and/or modify it under
68             the same terms as the Perl 5 programming language system itself.
69              
70             =cut