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.017';
3 1     1   7 use strict;
  1         2  
  1         31  
4 1     1   5 use warnings;
  1         2  
  1         24  
5 1     1   5 use JSON;
  1         2  
  1         7  
6 1     1   113 use Carp;
  1         2  
  1         67  
7 1     1   8 use parent 'JSON::Karabiner::Manipulator::Conditions';
  1         2  
  1         5  
8              
9             sub new {
10 1     1 0 3 my $class = shift;
11 1         3 my ($type, $value) = @_;
12 1         7 my $obj = $class->SUPER::new($type, $value);
13 1   50     11 $obj->{data} = $value || {},
14             return $obj;
15             }
16              
17             sub add_keyboard_types {
18 1     1 0 344 my $s = shift;
19 1         4 my @values = @_;
20 1 50       3 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 355 my $s = shift;
26 1         2 my $desc = shift;
27 1 50       5 croak ('No description passed.') unless $desc;
28 1         5 $s->{data}{description} = $desc;
29              
30             }
31              
32             sub TO_JSON {
33 1     1 0 2 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         8 return { %super_hash };
38              
39             }
40             #ABSTRACT: definition for keyboard_type_if condition
41              
42             1;
43              
44             __END__