blib/lib/Getopt/EX/termcolor/iTerm.pm

filter: Statementstmt 62.8% 22 / 35 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 6 / 10 Podpod 0.0% 0 / 3 totaltotal 50.0% 28 / 56 SCAR 20.7
CC
5
Cov
51%
background_rgb
12.0
get_colors
6.0
get_color
6.0
CRAP 7.9
« blib/lib/Getopt/EX/termcolor/XTerm.pm ↑ Summary blib/lib/Getopt/EX/termcolor/Apple_Terminal.pm »
1 =head1 NAME
2  
3 Getopt::EX::termcolor::iTerm
4  
5 =head1 SYNOPSIS
6  
7 command -Mtermcolor::iTerm
8  
9 =head1 DESCRIPTION
10  
11 This is a L<Getopt::EX::termcolor> module for iTerm.
12  
13 =head1 SEE ALSO
14  
15 L<Getopt::EX::termcolor>
16  
17 =cut
18  
19 package Getopt::EX::termcolor::iTerm;
20  
21 1 ▶use v5.14;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 {
26 1 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
27 1 ▶ use Getopt::EX::Colormap;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 1 $Getopt::EX::Colormap::RGB24 = 1;
29 }
30  
31 1 our $debug = 0;
32  
33 sub get_colors {
34 map {
35 0 ▶ my @rgb = get_color($_);
Subroutine get_colors: not called CC=2 SCAR=17.9
Pod undocumented
36 0 ▶ @rgb ? undef : [ @rgb ];
Branch: 1 branch
BranchTrueFalseTotal
@rgb ? : 0 0 0
37 } @_;
38 }
39  
40 sub get_color {
41 0 ▶ my $cat = lc shift;
Subroutine get_color: not called CC=2 SCAR=17.9
Pod undocumented
42 0 ▶ if ($cat eq 'background') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cat eq "background") 0 0 0
43 0 return background_rgb();
44 }
45 0 ();
46 }
47  
48 1 my %script = (
49  
50 'background' => <<END,
51 tell application "iTerm"
52 tell current session of current window
53 background color
54 end tell
55 end tell
56 END
57  
58 );
59  
60 1 ▶use Capture::Tiny ':all';
Subroutine BEGIN: called CC=1 SCAR=0.0
61  
62 sub background_rgb {
63 0 ▶ my $script = $script{background};
Subroutine background_rgb: not called CC=3 SCAR=24.8
Pod undocumented
64 my($stdout, $stderr, $exit) = capture {
65 0 ▶ system 'osascript', '-e', $script;
Subroutine __ANON__: not called CC=1 SCAR=6.9
66 0 };
67 0 ▶ $exit == 0 or return;
Branch: 1 branch
BranchTrueFalseTotal
$exit == 0 or return 0 0 0
68 0 my @rgb = $stdout =~ /(\d+)/g;
69 0 ▶ @rgb == 3 ? ( { max => 65535 }, @rgb) : ();
Branch: 1 branch
BranchTrueFalseTotal
@rgb == 3 ? : 0 0 0
70 }
71  
72 1 1;
73  
74 __DATA__
« blib/lib/Getopt/EX/termcolor/XTerm.pm ↑ Summary blib/lib/Getopt/EX/termcolor/Apple_Terminal.pm »