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