line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSON::Karabiner::Manipulator::Conditions::Variable_if ; |
2
|
|
|
|
|
|
|
$JSON::Karabiner::Manipulator::Conditions::Variable_if::VERSION = '0.017'; |
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
5
|
1
|
|
|
1
|
|
4
|
use JSON; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
6
|
1
|
|
|
1
|
|
96
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
50
|
|
7
|
1
|
|
|
1
|
|
5
|
use parent 'JSON::Karabiner::Manipulator::Conditions'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
2
|
|
|
2
|
0
|
5
|
my $class = shift; |
11
|
2
|
|
|
|
|
5
|
my ($type, $value) = @_; |
12
|
2
|
|
|
|
|
10
|
my $obj = $class->SUPER::new($type, $value); |
13
|
2
|
|
50
|
|
|
24
|
$obj->{data} = $value || {}, |
14
|
|
|
|
|
|
|
return $obj; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub add_variable { |
18
|
1
|
|
|
1
|
0
|
345
|
my $s = shift; |
19
|
1
|
|
|
|
|
2
|
my $name = shift; |
20
|
1
|
|
|
|
|
2
|
my $value = shift; |
21
|
1
|
50
|
|
|
|
4
|
croak 'A variable name is required' unless $name; |
22
|
1
|
50
|
|
|
|
2
|
croak 'A value for the varaible name is required' unless $value; |
23
|
|
|
|
|
|
|
#TODO: Validates keys |
24
|
1
|
50
|
|
|
|
5
|
if ($value =~ /^\d+$/) { |
25
|
0
|
|
|
|
|
0
|
$value = $value + 0; |
26
|
|
|
|
|
|
|
} |
27
|
1
|
|
|
|
|
3
|
$s->{data}{name} = $name; |
28
|
1
|
|
|
|
|
4
|
$s->{data}{value} = $value; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub add_description { |
33
|
0
|
|
|
0
|
0
|
0
|
my $s = shift; |
34
|
0
|
|
|
|
|
0
|
my $desc = shift; |
35
|
0
|
0
|
|
|
|
0
|
croak ('No description passed.') unless $desc; |
36
|
0
|
|
|
|
|
0
|
$s->{data}{description} = $desc; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub TO_JSON { |
41
|
2
|
|
|
2
|
0
|
5
|
my $obj = shift; |
42
|
2
|
|
|
|
|
3
|
my $name = $obj->{def_name}; |
43
|
2
|
|
|
|
|
3
|
my $value = $obj->{data}; |
44
|
2
|
|
|
|
|
7
|
my %super_hash = (%$value, type => $name); |
45
|
2
|
|
|
|
|
26
|
return { %super_hash }; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
# ABSTRACT: definition for Frontmost_application_if condition |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |