Karabiner/Manipulator/Conditions/Variable_if.pm

filter: Statementstmt 87.1% 34 / 39 Branchbran 37.5% 3 / 8 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 88.8% 8 / 9 Podpod 0.0% 0 / 4 totaltotal 73.0% 46 / 63 CC 6 SCAR 10.3
CC
6
Cov
78%
add_description
6.0
add_variable
4.3
new
2.0
CRAP 2.8
« Karabiner/Manipulator/Conditions/Input_source_if.pm ↑ Summary Karabiner/Manipulator/Conditions/Device_unless.pm »
1 package JSON::Karabiner::Manipulator::Conditions::Variable_if ;
2 1 $JSON::Karabiner::Manipulator::Conditions::Variable_if::VERSION = '0.018';
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use parent 'JSON::Karabiner::Manipulator::Conditions';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
Pod undocumented
10 2 my $class = shift;
11 2 my ($type, $value) = @_;
12 2 my $obj = $class->SUPER::new($type, $value);
13 2 ▶ $obj->{data} = $value || {},
Condition50%1/2
$value || {}
l!l
02
MC/DC0%0/1
$value || {}
$value
Truth table50%1/2
A
A= $value
Aresult
11
00
14 return $obj;
15 }
16  
17 1 ▶sub add_variable {
Subroutine add_variable: called CC=4 SCAR=14.6
Pod undocumented
18 1 my $s = shift;
19 1 my $name = shift;
20 1 my $value = shift;
21 1 ▶ croak 'A variable name is required' unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 1 1
22 1 ▶ croak 'A value for the varaible name is required' unless $value;
Branch: 1 branch
BranchTrueFalseTotal
unless $value 0 1 1
23 #TODO: Validates keys
24 1 ▶ if ($value =~ /^\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /^\d+$/) 0 1 1
25 0 $value = $value + 0;
26 }
27 1 $s->{data}{name} = $name;
28 1 $s->{data}{value} = $value;
29  
30 }
31  
32 0 ▶sub add_description {
Subroutine add_description: not called CC=2 SCAR=17.9
Pod undocumented
33 0 my $s = shift;
34 0 my $desc = shift;
35 0 ▶ croak ('No description passed.') unless $desc;
Branch: 1 branch
BranchTrueFalseTotal
unless $desc 0 0 0
36 0 $s->{data}{description} = $desc;
37  
38 }
39  
40 2 ▶sub TO_JSON {
Subroutine TO_JSON: called CC=1 SCAR=0.0
Pod undocumented
41 2 my $obj = shift;
42 2 my $name = $obj->{def_name};
43 2 my $value = $obj->{data};
44 2 my %super_hash = (%$value, type => $name);
45 2 return { %super_hash };
46  
47 }
48 # ABSTRACT: definition for Frontmost_application_if condition
49  
50 1 1;
51  
52 __END__
« Karabiner/Manipulator/Conditions/Input_source_if.pm ↑ Summary Karabiner/Manipulator/Conditions/Device_unless.pm »