File Coverage

blib/lib/Org/Element/Block.pm
Criterion Covered Total %
statement 14 17 82.3
branch 2 6 33.3
condition 0 7 0.0
subroutine 5 6 83.3
pod 0 2 0.0
total 21 38 55.2


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