Element/Setting.pm

filter: Statementstmt 100% 73 / 73 Branchbran 85.4% 41 / 48 Conditioncond 61.5% 8 / 13 MC/DCmcdc 28.5% 2 / 7 Subroutinesub 100% 7 / 7 Podpod 66.6% 2 / 3 totaltotal 88.0% 133 / 151 CC 33 SCAR 31.8
CC
33
Cov
91%
BUILD
30.4
as_string
5.0
BEGIN
1.0
CRAP 24.1
« Parser.pm ↑ Summary Element/Block.pm »
1 package Org::Element::Setting;
2  
3 10 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use locale;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 10 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 10 extends 'Org::Element';
8 10 with 'Org::ElementRole';
9 10 with 'Org::ElementRole::Block';
10  
11 10 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
12 10 our $DATE = '2026-07-21'; # DATE
13 10 our $DIST = 'Org-Parser'; # DIST
14 10 our $VERSION = '0.563'; # VERSION
15  
16 10 our @known_settings = qw(
17 ARCHIVE
18 ASCII
19 ATTR_ASCII
20 ATTR_BEAMER
21 ATTR_HTML
22 ATTR_LATEX
23 ATTR_ODT
24 AUTHOR
25 BABEL
26 BEAMER
27 BEAMER_COLOR_THEME
28 BEAMER_FONT_THEME
29 BEAMER_INNER_THEME
30 BEAMER_OUTER_THEME
31 BEAMER_THEME
32 BEGIN
33 BEGIN_ASCII
34 BEGIN_BEAMER
35 BEGIN_CENTER
36 BEGIN_COMMENT
37 BEGIN_EXAMPLE
38 BEGIN_HTML
39 BEGIN_LATEX
40 BEGIN_QUOTE
41 BEGIN_SRC
42 BEGIN_SRC
43 BEGIN_VERSE
44 BIND
45 CALL
46 CAPTION
47 CATEGORY
48 COLUMNS
49 CONSTANTS
50 DATE
51 DESCRIPTION
52 DRAWERS
53 EMAIL
54 EXPORT_EXCLUDE_TAGS
55 EXPORT_INCLUDE_TAGS
56 FILETAGS
57 HEADER
58 HEADERS
59 HTML
60 HTML_HEAD
61 HTML_HEAD_EXTRA
62 HTML_INCLUDE_STYLE
63 INCLUDE
64 INDEX
65 INFOJS_OPT
66 KEYWORDS
67 LABEL
68 LANGUAGE
69 LAST_MOBILE_CHANGE
70 LATEX
71 LATEX_CLASS
72 LATEX_CLASS_OPTIONS
73 LATEX_HEADER
74 LATEX_HEADER_EXTRA
75 LINK
76 LINK_HOME
77 LINK_UP
78 MACRO
79 NAME
80 ODT_STYLES_FILE
81 OPTIONS
82 ORGLST
83 ORGTBL
84 PLOT
85 POSTID
86 PRIORITIES
87 PROPERTY
88 RESULTS
89 SEQ_TODO
90 SETUPFILE
91 SRCNAME
92 STARTUP
93 STYLE
94 TAGS
95 TBLFM
96 TEXT
97 TITLE
98 TOC
99 TODO
100 TYP_TODO
101 XSLT
102 );
103  
104 10 has name => (is => 'rw');
105 10 has raw_arg => (is => 'ro');
106 10 has args => (is => 'rw');
107 10 has indent => (is => 'rw');
108  
109 # static method
110 8 ▶sub indentable_settings {
Subroutine indentable_settings: called CC=1 SCAR=0.0
Pod documented
111 8 state $data = [qw/TBLFM/];
112 8 $data;
113 }
114  
115 54 ▶sub BUILD {
Subroutine BUILD: called CC=30 SCAR=34.2
Pod undocumented
116 54 require Org::Document;
117 54 my ($self, $build_args) = @_;
118 54 my $doc = $self->document;
119 54 ▶ my $pass = $build_args->{pass} // 1;
Condition50%1/2
$build_args->{"pass"} // 1
l!l
540
MC/DC0%0/1
$build_args->{"pass"} // 1
$build_args->{"pass"}
Truth table50%1/2
A
A= $build_args->{"pass"}
Aresult
11
00
120  
121 54 my $name = uc $self->name;
122 54 $self->name($name);
123  
124 54 my $args = $self->args;
125 54 ▶ if ($name eq 'DRAWERS') {
Branch: 5 branches
BranchTrueFalseTotal
if ($name eq 'DRAWERS') { } 2 52 54
elsif ($name eq 'FILETAGS') { } 5 47 52
elsif ($name eq 'PRIORITIES') { } 8 39 47
elsif ($name eq 'PROPERTY') { } 4 35 39
elsif ($name =~ /^(SEQ_TODO|TODO|TYP_TODO)$/l) { } 26 9 35
126 2 ▶ if ($pass == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pass == 1) 1 1 2
127 1 for my $arg (@$args) {
128 2 push @{ $doc->drawer_names }, $arg
129 2 ▶ unless grep { $_ eq $arg } @{ $doc->drawer_names };
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $arg;} @{$doc->drawer_names;} 2 0 2
130 }
131 }
132 } elsif ($name eq 'FILETAGS') {
133 5 ▶ if ($pass == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pass == 1) 3 2 5
134 10 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
135 3 ▶ $args->[0] =~ /^$Org::Document::tags_re$/ or
Branch: 1 branch
BranchTrueFalseTotal
$args->[0] =~ /^$Org::Document::tags_re$/l or $self->die("Invalid argument for FILETAGS: $args->[0]") 2 1 3
136 $self->die("Invalid argument for FILETAGS: $args->[0]");
137 2 for my $tag (split /:/, $args->[0]) {
138 7 ▶ next unless length $tag;
Branch: 1 branch
BranchTrueFalseTotal
unless length $tag 2 5 7
139 5 push @{ $doc->tags }, $tag
140 5 ▶ unless grep { $_ eq $tag } @{ $doc->tags };
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $tag;} @{$doc->tags;} 5 0 5
141 }
142 }
143 } elsif ($name eq 'PRIORITIES') {
144 8 ▶ if ($pass == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pass == 1) 4 4 8
145 4 for (@$args) {
146 17 push @{ $doc->priorities }, $_;
147 }
148 }
149 } elsif ($name eq 'PROPERTY') {
150 4 ▶ if ($pass == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pass == 1) 2 2 4
151 2 ▶ @$args >= 2 or $self->die("Not enough argument for PROPERTY, minimum 2");
Branch: 1 branch
BranchTrueFalseTotal
@$args >= 2 or $self->die("Not enough argument for PROPERTY, minimum 2") 2 0 2
152 2 my $name = shift @$args;
153 2 ▶ $doc->properties->{$name} = @$args > 1 ? [@$args] : $args->[0];
Branch: 1 branch
BranchTrueFalseTotal
@$args > 1 ? : 0 2 2
154 }
155 } elsif ($name =~ /^(SEQ_TODO|TODO|TYP_TODO)$/) {
156 26 ▶ if ($pass == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pass == 1) 13 13 26
157 13 my $done;
158 13 ▶ for (my $i=0; $i<@$args; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$args) 50 13 63
159 50 my $arg = $args->[$i];
160 50 ▶ if ($arg eq '|') { $done++; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($arg eq "|") 12 38 50
161 38 ▶ $done++ if !$done && @$args > 1 && $i == @$args-1;
Branch: 1 branch
BranchTrueFalseTotal
if not $done and @$args > 1 and $i == @$args - 1 1 37 38
Condition83%5/6
not $done and @$args > 1 and $i == @$args - 1
!ll&&!rl&&r
15221
not $done and @$args > 1
!ll&&!rl&&r
15023
MC/DC66%2/3
not $done and @$args > 1 and $i == @$args - 1
not $done @$args > 1 $i == @$args - 1
Truth table75%3/4
not(A) and B and C
A= not $doneB= @$args > 1C= $i == @$args - 1
ABCresult
0XX0
10X0
1100
1111
162 38 ▶ my $ary = $done ? $doc->done_states : $doc->todo_states;
Branch: 1 branch
BranchTrueFalseTotal
$done ? : 16 22 38
163 38 ▶ push @$ary, $arg unless grep { $_ eq $arg } @$ary;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $arg;} @$ary 38 0 38
164 }
165 }
166 } else {
167 9 ▶ unless ($self->document->ignore_unknown_settings) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->document->ignore_unknown_settings) 9 0 9
168 9 ▶ $self->die("Unknown setting $name") unless grep { $_ eq $name } @known_settings;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $name;} @Org::Element::Setting::known_settings 1 8 9
169 }
170 }
171 }
172  
173 2 ▶sub as_string {
Subroutine as_string: called CC=4 SCAR=16.1
Pod documented
174 2 my ($self) = @_;
175 join("",
176 $self->indent // "",
177 "#+".uc($self->name), ":",
178 2 ▶ $self->args && @{$self->args} ?
Branch: 1 branch
BranchTrueFalseTotal
$self->args && @{$self->args;} ? : 2 0 2
Condition40%2/5
$self->indent // ""
l!l
20
$self->args and @{$self->args;}
!ll&&!rl&&r
002
MC/DC0%0/1
$self->indent // ""
$self->indent
MC/DC0%0/2
$self->args and @{$self->args;}
$self->args @{$self->args;}
Truth table50%1/2
A
A= $self->indent
Aresult
11
00
Truth table33%1/3
A and B
A= $self->argsB= @{$self->args;}
ABresult
0X0
100
111
179 " ".Org::Document::__format_args($self->args) : "",
180 "\n"
181 );
182 }
183  
184 10 1;
185 # ABSTRACT: Represent Org in-buffer settings
186  
187 __END__
« Parser.pm ↑ Summary Element/Block.pm »