File Coverage

blib/lib/Catmandu/Cmd/compile.pm
Criterion Covered Total %
statement 25 27 92.5
branch 1 2 50.0
condition n/a
subroutine 7 7 100.0
pod 2 2 100.0
total 35 38 92.1


line stmt bran cond sub pod time code
1              
2             use Catmandu::Sane;
3 14     14   259128  
  14         32  
  14         106  
4             our $VERSION = '1.2018';
5              
6             use parent 'Catmandu::Cmd';
7 14     14   103 use Catmandu;
  14         29  
  14         82  
8 14     14   1037 use Data::Dumper;
  14         27  
  14         87  
9 14     14   3495 use namespace::clean;
  14         30  
  14         667  
10 14     14   78  
  14         27  
  14         101  
11             (
12             ["var=s%", ""],
13             ["preprocess|pp", ""],
14 1     1 1 15 ["fix|fix=s@", "", {hidden => 1}],
15             );
16             }
17              
18             my ($self, $opts, $args) = @_;
19              
20             unless (@$args == 1) {
21 1     1 1 3 say STDERR "usage: $0 compile <FILE>|<FIX> [<FILE>|<FIX> [...]]\n";
22             exit 1;
23 1 50       4 }
24 0         0  
25 0         0 $opts->{fix} = $args;
26              
27             my $fixer = $self->_build_fixer($opts);
28 1         3 my $fixes = $fixer->emit;
29             my $captures = Dumper($fixer->_captures);
30 1         16  
31 1         1571 $captures =~ s/^\$VAR1/\$_[1]/;
32 1         21  
33             print $captures;
34 1         109 print $fixes;
35             }
36 1         93  
37 1         45 1;
38              
39              
40             =pod
41              
42             =head1 NAME
43              
44             Catmandu::Cmd::compile - compile a Fix into Perl (for debugging)
45              
46             =head1 EXAMPLES
47              
48             catmandu compile <FILE>|<FIX> [<FILE>|<FIX> [...]]
49              
50             catmandu compile 'add_field(foo,bar.$append)' | perltidy -utf8 -npro -st -se
51              
52             =cut