Karabiner/Manipulator/Conditions/Device_if.pm

filter: Statementstmt 100% 36 / 36 Branchbran 50.0% 2 / 4 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 4 totaltotal 85.7% 48 / 56 CC 4 SCAR 4.1
CC
4
Cov
93%
new
2.0
add_description
2.0
add_identifier
2.0
CRAP 1.5
« Karabiner/Manipulator/Conditions/Keyboard_type_if.pm ↑ Summary Karabiner/Manipulator/Actions.pm »
1 package JSON::Karabiner::Manipulator::Conditions::Device_if ;
2 2 $JSON::Karabiner::Manipulator::Conditions::Device_if::VERSION = '0.018';
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶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}{identifiers} = $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 2 ▶sub add_identifier {
Subroutine add_identifier: called CC=2 SCAR=7.0
Pod undocumented
18 2 my $s = shift;
19 2 my @values = @_;
20 2 ▶ croak 'A value for the identifier name is required' unless @values;
Branch: 1 branch
BranchTrueFalseTotal
unless @values 0 2 2
21 2 my $hash = { @values };
22 #TODO: Validates keys
23 2 push @{$s->{data}{identifiers}}, $hash;
24  
25 }
26  
27 1 ▶sub add_description {
Subroutine add_description: called CC=2 SCAR=7.0
Pod undocumented
28 1 my $s = shift;
29 1 my $desc = shift;
30 1 ▶ croak ('No description passed.') unless $desc;
Branch: 1 branch
BranchTrueFalseTotal
unless $desc 0 1 1
31 1 $s->{data}{description} = $desc;
32  
33 }
34  
35 4 ▶sub TO_JSON {
Subroutine TO_JSON: called CC=1 SCAR=0.0
Pod undocumented
36 4 my $obj = shift;
37 4 my $name = $obj->{def_name};
38 4 my $value = $obj->{data};
39 4 my %super_hash = (%$value, type => $name);
40 4 return { %super_hash };
41  
42 }
43 # ABSTRACT: definition for Frontmost_application_if condition
44  
45 2 1;
46  
47 __END__
« Karabiner/Manipulator/Conditions/Keyboard_type_if.pm ↑ Summary Karabiner/Manipulator/Actions.pm »