File Coverage

blib/lib/Org/Element/Drawer.pm
Criterion Covered Total %
statement 23 23 100.0
branch 4 6 66.6
condition 1 2 50.0
subroutine 7 7 100.0
pod 1 2 50.0
total 36 40 90.0


line stmt bran cond sub pod time code
1              
2             use 5.010;
3 7     7   1331 use locale;
  7         22  
4 7     7   33 use Moo;
  7         12  
  7         47  
5 7     7   199 use experimental 'smartmatch';
  7         21  
  7         41  
6 7     7   2304 extends 'Org::Element';
  7         12  
  7         53  
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 properties => (is => 'rw');
17              
18             my ($self, $args) = @_;
19             my $doc = $self->document;
20 15     15 0 8086 my $pass = $args->{pass} // 1;
21 15         91  
22 15   50     43 if ($pass == 2) {
23             die "Unknown drawer name: ".$self->name
24 15 50       45 unless $self->name ~~ @{$doc->drawer_names};
25             }
26 15 100       36 }
  15         165  
27              
28             my ($self, $raw_content) = @_;
29             $self->properties({}) unless $self->properties;
30             while ($raw_content =~ /^[ \t]*:(\w+):[ \t]+
31 14     14   28 ($Org::Document::args_re)[ \t]*(?:\R|\z)/mxg) {
32 14 50       63 $self->properties->{$1} = $2;
33 14         502 }
34             }
35 14         133  
36             my ($self) = @_;
37             join("",
38             ":", $self->name, ":\n",
39             $self->children_as_string,
40 16     16 1 27 ":END:");
41 16         42 }
42              
43             1;
44             # ABSTRACT: Represent Org drawer
45              
46              
47             =pod
48              
49             =encoding UTF-8
50              
51             =head1 NAME
52              
53             Org::Element::Drawer - Represent Org drawer
54              
55             =head1 VERSION
56              
57             This document describes version 0.558 of Org::Element::Drawer (from Perl distribution Org-Parser), released on 2022-06-23.
58              
59             =head1 DESCRIPTION
60              
61             Derived from L<Org::Element>.
62              
63             Example of a drawer in an Org document:
64              
65             * A heading
66             :SOMEDRAWER:
67             some text
68             more text ...
69             :END:
70              
71             A special drawer named C<PROPERTIES> is used to store a list of properties:
72              
73             * A heading
74             :PROPERTIES:
75             :Title: the title
76             :Publisher: the publisher
77             :END:
78              
79             =for Pod::Coverage BUILD as_string
80              
81             =head1 ATTRIBUTES
82              
83             =head2 name => STR
84              
85             Drawer name.
86              
87             =head2 properties => HASH
88              
89             Collected properties in the drawer. In the example properties drawer above,
90             C<properties()> will result in:
91              
92             {
93             Title => "the title",
94             Publisher => "the publisher",
95             }
96              
97             =head1 METHODS
98              
99             =head1 HOMEPAGE
100              
101             Please visit the project's homepage at L<https://metacpan.org/release/Org-Parser>.
102              
103             =head1 SOURCE
104              
105             Source repository is at L<https://github.com/perlancar/perl-Org-Parser>.
106              
107             =head1 AUTHOR
108              
109             perlancar <perlancar@cpan.org>
110              
111             =head1 CONTRIBUTING
112              
113              
114             To contribute, you can send patches by email/via RT, or send pull requests on
115             GitHub.
116              
117             Most of the time, you don't need to build the distribution yourself. You can
118             simply modify the code, then test via:
119              
120             % prove -l
121              
122             If you want to build the distribution (e.g. to try to install it locally on your
123             system), you can install L<Dist::Zilla>,
124             L<Dist::Zilla::PluginBundle::Author::PERLANCAR>, and sometimes one or two other
125             Dist::Zilla plugin and/or Pod::Weaver::Plugin. Any additional steps required
126             beyond that are considered a bug and can be reported to me.
127              
128             =head1 COPYRIGHT AND LICENSE
129              
130             This software is copyright (c) 2022, 2021, 2020, 2019, 2017, 2016, 2015, 2014, 2013, 2012, 2011 by perlancar <perlancar@cpan.org>.
131              
132             This is free software; you can redistribute it and/or modify it under
133             the same terms as the Perl 5 programming language system itself.
134              
135             =head1 BUGS
136              
137             Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Org-Parser>
138              
139             When submitting a bug or request, please include a test-file or a
140             patch to an existing test-file that illustrates the bug or desired
141             feature.
142              
143             =cut