blib/lib/Venus/Task/Venus/Set.pm

filter: Statementstmt 90.4% 38 / 42 Branchbran 50.0% 2 / 4 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 80.0% 8 / 10 Podpod 100% 3 / 3 totaltotal 81.2% 52 / 64 CC 4 SCAR 7.8
CC
4
Cov
84%
perform
4.4
name
2.0
footer
2.0
CRAP 2.2
« blib/lib/Venus/Args.pm ↑ Summary blib/lib/Venus/Role/Explainable.pm »
1 package Venus::Task::Venus::Set;
2  
3 2 ▶use 5.018;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use Venus::Class 'base';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 # IMPORTS
11  
12 2 ▶use Venus::Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use Venus::Hash;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 # INHERITS
16  
17 2 base 'Venus::Task::Venus';
18  
19 # REQUIRES
20  
21 2 require Venus;
22  
23 # METHODS
24  
25 0 ▶sub name {
Subroutine name: not called CC=1 SCAR=6.9
Pod documented
26 0 'vns set'
27 }
28  
29 0 ▶sub footer {
Subroutine footer: not called CC=1 SCAR=6.9
Pod documented
30  
31 0 return <<"EOF";
32 Copyright 2022-2023, Vesion $Venus::VERSION, The Venus "AUTHOR" and "CONTRIBUTORS"
33  
34 More information on "vns" and/or the "Venus" standard library, visit
35 https://p3rl.org/vns.
36 EOF
37 }
38  
39 2 ▶sub perform {
Subroutine perform: called CC=4 SCAR=14.8
40 2 my ($self) = @_;
41  
42 2 my $file = $self->file;
43  
44 2 my $path = $self->argument_value('path');
45  
46 2 my $config = Venus::Hash->new(Venus::Config->read_file($file)->value);
47  
48 2 my ($value) = $config->gets($path);
49  
50 2 ▶ if (defined $value && ref $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value and ref $value) 0 2 2
Condition33%1/3
defined $value and ref $value
!ll&&!rl&&r
020
MC/DC0%0/2
defined $value and ref $value
defined $value ref $value
Truth table33%1/3
A and B
A= defined $valueB= ref $value
ABresult
0X0
100
111
51 0 $self->log_error("invalid path \"$path\"");
52  
53 0 return $self;
54 }
55  
56 2 $value = $self->argument_value('value');
57  
58 2 ▶ if (defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 2 0 2
59 2 $config->sets($path, $value);
60  
61 2 Venus::Config->new($config->value)->write_file($file);
62  
63 2 $self->log_info($value);
64 }
65  
66 2 return $self;
67 }
68  
69 3 ▶sub prepare {
Subroutine prepare: called CC=1 SCAR=0.0
Pod documented
70 3 my ($self) = @_;
71  
72 3 $self->summary('set values in the Venus configuration file');
73  
74 # path
75 3 $self->argument('path', {
76 name => 'path',
77 help => 'Value path. Use dot-natotion. E.g. "perl.repl".',
78 range => '0',
79 multiples => 0,
80 required => 1,
81 type => 'string',
82 wants => 'string',
83 });
84  
85 # value
86 3 $self->argument('value', {
87 name => 'value',
88 help => 'Path value. E.g. "perl -Ilib -dE0".',
89 range => '1',
90 multiples => 0,
91 required => 1,
92 type => 'string',
93 wants => 'string',
94 });
95  
96 # help
97 3 $self->option('help', {
98 name => 'help',
99 help => 'Display the help text.',
100 multiples => 0,
101 required => 0,
102 type => 'boolean',
103 wants => 'boolean',
104 });
105  
106 3 return $self;
107 }
108  
109 2 1;
110  
111  
112 =head1 NAME
113  
114 Venus::Task::Venus::Set - vns set
115  
116 =cut
117  
118 =head1 ABSTRACT
119  
120 Task Class for Venus CLI
121  
122 =cut
123  
124 =head1 SYNOPSIS
125  
126 use Venus::Task::Venus::Set;
127  
128 my $task = Venus::Task::Venus::Set->new;
129  
130 # bless(..., "Venus::Task::Venus::Set")
131  
132 =cut
133  
134 =head1 DESCRIPTION
135  
136 This package is a task class for the C<vns-set> CLI, and C<vns set>
137 sub-command.
138  
139 =cut
140  
141 =head1 INHERITS
142  
143 This package inherits behaviors from:
144  
145 L<Venus::Task::Venus>
146  
147 =cut
148  
149 =head1 METHODS
150  
151 This package provides the following methods:
152  
153 =cut
154  
155 =head2 new
156  
157 new(any @args) (Venus::Task::Venus::Set)
158  
159 The new method constructs an instance of the package.
160  
161 I<Since C<4.15>>
162  
163 =over 4
164  
165 =item new example 1
166  
167 package main;
168  
169 use Venus::Task::Venus::Set;
170  
171 my $task = Venus::Task::Venus::Set->new;
172  
173 # bless({...}, 'Venus::Task::Venus::Set')
174  
175 =back
176  
177 =cut
178  
179 =head2 perform
180  
181 perform() (Venus::Task::Venus::Set)
182  
183 The perform method executes the CLI logic.
184  
185 I<Since C<4.15>>
186  
187 =over 4
188  
189 =item perform example 1
190  
191 # given: synopsis
192  
193 package main;
194  
195 $task->prepare;
196  
197 $task->parse('perl.perl', '$PERL');
198  
199 my $perform = $task->perform;
200  
201 # bless(.., 'Venus::Task::Venus::Set')
202  
203 =back
204  
205 =over 4
206  
207 =item perform example 2
208  
209 # given: synopsis
210  
211 package main;
212  
213 $task->prepare;
214  
215 $task->parse('perl.prove', '$PROVE');
216  
217 my $perform = $task->perform;
218  
219 # bless(.., 'Venus::Task::Venus::Set')
220  
221 =back
222  
223 =cut
224  
225 =head1 AUTHORS
226  
227 Awncorp, C<awncorp@cpan.org>
228  
229 =cut
230  
231 =head1 LICENSE
232  
233 Copyright (C) 2022, Awncorp, C<awncorp@cpan.org>.
234  
235 This program is free software, you can redistribute it and/or modify it under
236 the terms of the Apache license version 2.0.
237  
238 =cut
« blib/lib/Venus/Args.pm ↑ Summary blib/lib/Venus/Role/Explainable.pm »