Element/Block.pm

filter: Statementstmt 86.6% 26 / 30 Branchbran 33.3% 2 / 6 Conditioncond 0.0% 0 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 80.0% 4 / 5 Podpod 0.0% 0 / 2 totaltotal 59.2% 32 / 54 SCAR 22.1
CC
7
Cov
65%
element_as_string
42.0
BUILD
2.0
BEGIN
1.0
CRAP 9.1
« Element/Table.pm ↑ Summary Element/Text.pm »
1 package Org::Element::Block;
2  
3 4 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use locale;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 extends 'Org::Element';
8 4 with 'Org::ElementRole';
9 4 with 'Org::ElementRole::Block';
10  
11 4 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
12 4 our $DATE = '2023-08-05'; # DATE
13 4 our $DIST = 'Org-Parser'; # DIST
14 4 our $VERSION = '0.560'; # VERSION
15  
16 4 has name => (is => 'rw');
17 4 has args => (is => 'rw');
18 4 has raw_content => (is => 'rw');
19 4 has begin_indent => (is => 'rw');
20 4 has end_indent => (is => 'rw');
21  
22 4 my @known_blocks = qw(
23 ASCII CENTER COMMENT EXAMPLE HTML
24 LATEX QUOTE SRC VERSE
25 );
26  
27 sub BUILD {
28 3 ▶ my ($self, $args) = @_;
Subroutine BUILD: called CC=2 SCAR=6.9
Pod undocumented
29 3 $self->name(uc $self->name);
30 3 ▶ (grep { $_ eq $self->name } @known_blocks)
Branch: 1 branch
BranchTrueFalseTotal
grep {$_ eq $self->name;} @known_blocks or $self->die('Unknown block name: ' . $self->name) 1 2 3
31 or $self->die("Unknown block name: ".$self->name);
32 }
33  
34 sub element_as_string {
35 0 ▶ my ($self) = @_;
Subroutine element_as_string: not called CC=6 SCAR=37.4
Pod undocumented
36 0 ▶ return $self->_str if defined $self->_str;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->_str 0 0 0
37 join("",
38 $self->begin_indent // "",
39 "#+BEGIN_".uc($self->name),
40 0 ▶ $self->args && @{$self->args} ?
Branch: 1 branch
BranchTrueFalseTotal
$self->args && @{$self->args;} ? : 0 0 0
Condition0%0/7
$self->begin_indent // ""
l!l
00
$self->args and @{$self->args;}
!ll&&!rl&&r
000
$self->end_indent // ""
l!l
00
MC/DC0%0/1
$self->begin_indent // ""
$self->begin_indent
MC/DC0%0/2
$self->args and @{$self->args;}
$self->args @{$self->args;}
MC/DC0%0/1
$self->end_indent // ""
$self->end_indent
Truth table0%0/2
A
A= $self->begin_indent
Aresult
11
00
Truth table0%0/3
A and B
A= $self->argsB= @{$self->args;}
ABresult
0X0
100
111
Truth table0%0/2
A
A= $self->end_indent
Aresult
11
00
41 " ".Org::Document::__format_args($self->args) : "",
42 "\n",
43 $self->raw_content,
44 $self->end_indent // "",
45 "#+END_".uc($self->name)."\n");
46 }
47  
48 4 1;
49 # ABSTRACT: Represent Org block
50  
51 __END__
52  
53 =pod
54  
55 =encoding UTF-8
56  
57 =head1 NAME
58  
59 Org::Element::Block - Represent Org block
60  
61 =head1 VERSION
62  
63 This document describes version 0.560 of Org::Element::Block (from Perl distribution Org-Parser), released on 2023-08-05.
64  
65 =head1 DESCRIPTION
66  
67 Derived from L<Org::Element>.
68  
69 =for Pod::Coverage element_as_string BUILD
70  
71 =head1 ATTRIBUTES
72  
73 =head2 name => STR
74  
75 Block name. For example, #+begin_src ... #+end_src is an 'SRC' block.
76  
77 =head2 args => ARRAY
78  
79 =head2 raw_content => STR
80  
81 =head2 begin_indent => STR
82  
83 Indentation on begin line (before C<#+BEGIN>), or empty string if none.
84  
85 =head2 end_indent => STR
86  
87 Indentation on end line (before C<#+END>), or empty string if none.
88  
89 =head1 METHODS
90  
91 =head1 HOMEPAGE
92  
93 Please visit the project's homepage at L<https://metacpan.org/release/Org-Parser>.
94  
95 =head1 SOURCE
96  
97 Source repository is at L<https://github.com/perlancar/perl-Org-Parser>.
98  
99 =head1 AUTHOR
100  
101 perlancar <perlancar@cpan.org>
102  
103 =head1 CONTRIBUTING
104  
105  
106 To contribute, you can send patches by email/via RT, or send pull requests on
107 GitHub.
108  
109 Most of the time, you don't need to build the distribution yourself. You can
110 simply modify the code, then test via:
111  
112 % prove -l
113  
114 If you want to build the distribution (e.g. to try to install it locally on your
115 system), you can install L<Dist::Zilla>,
116 L<Dist::Zilla::PluginBundle::Author::PERLANCAR>,
117 L<Pod::Weaver::PluginBundle::Author::PERLANCAR>, and sometimes one or two other
118 Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond
119 that are considered a bug and can be reported to me.
120  
121 =head1 COPYRIGHT AND LICENSE
122  
123 This software is copyright (c) 2023, 2022, 2021, 2020, 2019, 2017, 2016, 2015, 2014, 2013, 2012, 2011 by perlancar <perlancar@cpan.org>.
124  
125 This is free software; you can redistribute it and/or modify it under
126 the same terms as the Perl 5 programming language system itself.
127  
128 =head1 BUGS
129  
130 Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Org-Parser>
131  
132 When submitting a bug or request, please include a test-file or a
133 patch to an existing test-file that illustrates the bug or desired
134 feature.
135  
136 =cut
« Element/Table.pm ↑ Summary Element/Text.pm »