File Coverage

blib/lib/JSON/Karabiner/Manipulator/Conditions/Keyboard_type_if.pm
Criterion Covered Total %
statement 32 32 100.0
branch 2 4 50.0
condition 1 2 50.0
subroutine 9 9 100.0
pod 0 4 0.0
total 44 51 86.2


line stmt bran cond sub pod time code
1             package JSON::Karabiner::Manipulator::Conditions::Keyboard_type_if ;
2             $JSON::Karabiner::Manipulator::Conditions::Keyboard_type_if::VERSION = '0.016';
3 1     1   8 use strict;
  1         2  
  1         32  
4 1     1   5 use warnings;
  1         2  
  1         24  
5 1     1   6 use JSON;
  1         2  
  1         5  
6 1     1   112 use Carp;
  1         3  
  1         55  
7 1     1   6 use parent 'JSON::Karabiner::Manipulator::Conditions';
  1         2  
  1         6  
8              
9             sub new {
10 1     1 0 3 my $class = shift;
11 1         12 my ($type, $value) = @_;
12 1         7 my $obj = $class->SUPER::new($type, $value);
13 1   50     12 $obj->{data} = $value || {},
14             return $obj;
15             }
16              
17             sub add_keyboard_types {
18 1     1 0 356 my $s = shift;
19 1         4 my @values = @_;
20 1 50       4 croak 'A list of keyboard types is required' unless @values;
21 1         4 $s->{data}{keyboard_types} = \@values ;
22             }
23              
24             sub add_description {
25 1     1 0 330 my $s = shift;
26 1         9 my $desc = shift;
27 1 50       3 croak ('No description passed.') unless $desc;
28 1         5 $s->{data}{description} = $desc;
29              
30             }
31              
32             sub TO_JSON {
33 1     1 0 4 my $obj = shift;
34 1         3 my $name = $obj->{def_name};
35 1         1 my $value = $obj->{data};
36 1         4 my %super_hash = (%$value, type => $name);
37 1         9 return { %super_hash };
38              
39             }
40             #ABSTRACT: definition for keyboard_type_if condition
41              
42             1;
43              
44             __END__