Diff/Command.pm

filter: Statementstmt 33.3% 1 / 3 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 1 / 1 Podpod n/a totaltotal 50.0% 2 / 4 CC 1 SCAR 2.6
CC
1
Cov
33%
BEGIN
1.3
CRAP 1.3
↑ Summary Diff.pm »
1 package YAML::Diff::Command;
2 1 ▶use Mo;
Subroutine BEGIN: called CC=1 SCAR=2.6
3  
4 has args => ();
5  
6 use YAML::XS;
7 use IO::All;
8  
9 sub run {
10 my ($self) = @_;
11  
12 my $args = $self->args;
13 @$args == 2 or die 'Command requires 2 YAML file paths';
14  
15 my ($file1, $file2) = @$args;
16  
17 my $yaml1 = YAML::XS::Dump(YAML::XS::LoadFile($file1));
18 my $yaml2 = YAML::XS::Dump(YAML::XS::LoadFile($file2));
19  
20 (my $tmp1 = $file1) =~ s!.*/!!;
21 (my $tmp2 = $file2) =~ s!.*/!!;
22 $tmp1 = "/tmp/$tmp1";
23 $tmp2 = "/tmp/$tmp2";
24  
25 if ($yaml1 eq $yaml2) {
26 print "Matched\n";
27 }
28 else {
29 io($tmp1)->print($yaml1);
30 io($tmp2)->print($yaml2);
31 system "diff -u $tmp1 $tmp2";
32 }
33 }
34  
35 1;
↑ Summary Diff.pm »