Karabiner/Manipulator/Actions.pm

filter: Statementstmt 89.4% 34 / 38 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.0% 9 / 10 Podpod 100% 4 / 4 totaltotal 87.9% 51 / 58 CC 4 SCAR 4.4
CC
4
Cov
86%
add_pointing_button
2.0
_is_exclusive
2.0
add_consumer_key_code
2.0
CRAP 1.5
« Karabiner/Manipulator/Conditions/Frontmost_application_if.pm ↑ Summary Karabiner/Manipulator/Conditions/Keyboard_type_if.pm »
1 package JSON::Karabiner::Manipulator::Actions ;
2 11 $JSON::Karabiner::Manipulator::Actions::VERSION = '0.011';
3 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 11 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 11 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 sub new {
9 25 ▶ my $class = shift;
Subroutine new: called CC=1 SCAR=0.0
Pod documented
10 25 my $type = shift;
11  
12 25 my $self = {
13 def_name => $type,
14 consumer_key_code => 0,
15 pointing_button => 0,
16 key_code => 0,
17 any => 0,
18 last_key_code => '',
19  
20 };
21 25 bless $self, $class;
22 {
23 11 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
24 25 $main::current_action = $self;
25 }
26 25 return $self;
27 }
28  
29 sub add_consumer_key_code {
30 9 ▶ my $s = shift;
Subroutine add_consumer_key_code: called CC=2 SCAR=6.9
Pod documented
31 9 ▶ croak 'You must pass a value' if !$_[0];
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0] 1 8 9
32 8 $s->add_key_code(@_, 'consumer_key_code');
33 }
34  
35 sub add_pointing_button {
36 7 ▶ my $s = shift;
Subroutine add_pointing_button: called CC=2 SCAR=7.1
Pod documented
37 7 ▶ croak 'You must pass a value' if !$_[0];
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0] 0 7 7
38 7 $s->add_key_code(@_, 'pointing_button');
39 }
40  
41 sub _is_exclusive {
42 101 ▶ my $s = shift;
Subroutine _is_exclusive: called CC=2 SCAR=7.0
43 101 my $property = shift;
44 101 ▶ croak 'No property passed' unless $property;
Branch: 1 branch
BranchTrueFalseTotal
unless $property 0 101 101
45 # my $is_exclusive = !grep { !$s->{$_} unless $_ eq $property } qw(shell_command select_input_source set_variable mouse_key consumer_key_code pointing_button key_code);
46 # croak 'Property already set that conflicts with the propert you are trying to set' unless $is_exclusive;
47 101 $s->{$property} = 1;
48 }
49  
50 sub TO_JSON {
51 0 ▶ my $obj = shift;
Subroutine TO_JSON: not called CC=1 SCAR=6.9
Pod documented
52 0 my $name = $obj->{def_name};
53 0 my $value = $obj->{data};
54 0 return { $name => $value };
55  
56 # return { %{ shift() } };
57 }
58  
59 # ABSTRACT: parent class for action classes
60  
61 11 1;
62  
63 __END__
« Karabiner/Manipulator/Conditions/Frontmost_application_if.pm ↑ Summary Karabiner/Manipulator/Conditions/Keyboard_type_if.pm »