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.018';
3 1     1   8 use strict;
  1         2  
  1         31  
4 1     1   6 use warnings;
  1         2  
  1         23  
5 1     1   4 use JSON;
  1         2  
  1         5  
6 1     1   107 use Carp;
  1         3  
  1         52  
7 1     1   5 use parent 'JSON::Karabiner::Manipulator::Conditions';
  1         2  
  1         5  
8              
9             sub new {
10 1     1 0 4 my $class = shift;
11 1         4 my ($type, $value) = @_;
12 1         7 my $obj = $class->SUPER::new($type, $value);
13 1   50     10 $obj->{data} = $value || {},
14             return $obj;
15             }
16              
17             sub add_keyboard_types {
18 1     1 0 338 my $s = shift;
19 1         3 my @values = @_;
20 1 50       4 croak 'A list of keyboard types is required' unless @values;
21 1         5 $s->{data}{keyboard_types} = \@values ;
22             }
23              
24             sub add_description {
25 1     1 0 327 my $s = shift;
26 1         3 my $desc = shift;
27 1 50       4 croak ('No description passed.') unless $desc;
28 1         4 $s->{data}{description} = $desc;
29              
30             }
31              
32             sub TO_JSON {
33 1     1 0 3 my $obj = shift;
34 1         2 my $name = $obj->{def_name};
35 1         2 my $value = $obj->{data};
36 1         3 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__