File Coverage

blib/lib/XML/LibXSLT/Easy/Batch/CLI.pm
Criterion Covered Total %
statement 1 3 33.3
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 2 4 50.0


line stmt bran cond sub pod time code
1             #!/usr/bin/perl
2              
3             package XML::LibXSLT::Easy::Batch::CLI;
4 1     1   4167 use Moose;
  0            
  0            
5              
6             use XML::LibXSLT::Easy::Batch;
7              
8             use Carp qw(croak);
9             use MooseX::Types::Path::Class;
10             use Config::Any;
11              
12             use namespace::clean -except => [qw(meta)];
13              
14             with qw(MooseX::Getopt);
15              
16             has conf_file => (
17             isa => "Path::Class::File",
18             is => "rw",
19             coerce => 1,
20             );
21              
22             has files => (
23             traits => [qw(NoGetopt)],
24             isa => "ArrayRef[HashRef]",
25             is => "ro",
26             lazy_build => 1,
27             );
28              
29             sub _build_files {
30             my $self = shift;
31             my $files = Config::Any->load_files({ files => [ $self->conf_file ], use_ext => 1 });
32             return $files->[0]{$self->conf_file} || croak "conf file could not be loaded";;
33             }
34              
35             has proc => (
36             traits => [qw(NoGetopt)],
37             isa => "XML::LibXSLT::Easy::Batch",
38             is => "rw",
39             lazy_build => 1,
40             );
41              
42             sub _build_proc {
43             my $self = shift;
44             XML::LibXSLT::Easy::Batch->new( files => $self->files );
45             }
46              
47             sub run {
48             my $self = shift;
49             $self = $self->new_with_options( @ARGV == 1 ? ( conf_file => shift @ARGV ) : () ) unless ref $self;
50              
51             $self->proc->process()
52             }
53              
54             __PACKAGE__
55              
56             __END__
57              
58             =pod
59              
60             =head1 NAME
61              
62             XML::LibXSLT::Easy::Batch::CLI -
63              
64             =head1 SYNOPSIS
65              
66             use XML::LibXSLT::Easy::Batch::CLI;
67              
68             =head1 DESCRIPTION
69              
70             =cut
71              
72