script/ot

filter: Statementstmt 71.4% 30 / 42 Branchbran 28.5% 4 / 14 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 61.1% 41 / 67 CC 1 SCAR 0.0
CC
1
Cov
59%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/Open/This.pm ↑ Summary
1 #!perl
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use Getopt::Long qw( GetOptions );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 use Open::This qw(
8 editor_args_from_parsed_text
9 maybe_get_url_from_parsed_text
10 parse_text
11 4 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 4 ▶use Path::Tiny qw( path );
Subroutine BEGIN: called CC=1 SCAR=0.0
13 4 ▶use Pod::Usage qw( pod2usage );
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 4 ▶pod2usage("Error: missing argument\n") unless @ARGV;
Branch: 1 branch
BranchTrueFalseTotal
unless @ARGV 0 4 4
16  
17 4 my $browse;
18 my $editor;
19 4 my $print;
20  
21 4 GetOptions(
22 'browse|b' => \$browse,
23 'editor|e=s' => \$editor,
24 'print|p' => \$print,
25 );
26  
27 4 my $parsed = parse_text(@ARGV);
28 4 ▶if ( !$parsed ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($parsed) 0 4 4
29 0 print "Could not locate file\n";
30 0 exit(1);
31 }
32  
33 4 ▶if ($browse) {
Branch: 1 branch
BranchTrueFalseTotal
if ($browse) 0 4 4
34 0 my $url = maybe_get_url_from_parsed_text($parsed);
35 0 ▶ if ( !exists $parsed->{remote_file_url} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $parsed->{"remote_file_url"}) 0 0 0
36 0 print "Could not find remote repository\n";
37 0 exit(1);
38 }
39  
40 # A relative path should be inside our repository
41 0 ▶ if ( path( $parsed->{remote_file_url} )->is_relative ) {
Branch: 1 branch
BranchTrueFalseTotal
if (path($parsed->{"remote_file_url"})->is_relative) 0 0 0
42 0 require Browser::Open;
43 0 Browser::Open::open_browser( $parsed->{remote_file_url} );
44 0 exit(0);
45 }
46 0 return undef;
47 }
48  
49 4 ▶local $ENV{EDITOR} = $editor || $ENV{EDITOR};
Condition33%1/3
$editor || $ENV{'EDITOR'}
l!l&&r!l&&!r
400
MC/DC0%0/2
$editor || $ENV{'EDITOR'}
$editor $ENV{'EDITOR'}
Truth table33%1/3
A || B
A= $editorB= $ENV{'EDITOR'}
ABresult
1X1
011
000
50  
51 4 my @editor_args = editor_args_from_parsed_text($parsed);
52  
53 4 ▶if ($print) {
Branch: 1 branch
BranchTrueFalseTotal
if ($print) 4 0 4
54 4 print STDOUT join( ' ', @editor_args ), "\n";
55 4 exit(0);
56 }
57  
58 $ENV{EDITOR}
59 ? exec $ENV{EDITOR}, @editor_args
60 0 ▶ : die('Please set your $EDITOR env var or use the --editor arg');
Branch: 1 branch
BranchTrueFalseTotal
$ENV{'EDITOR'} ? : 0 0 0
61  
62 # ABSTRACT: parse text and (hopefully) open an editor with the correct arguments
63 # PODNAME: ot
64  
65 __END__
« blib/lib/Open/This.pm ↑ Summary