| 1 | package OrePAN2::CLI::Inject; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use Getopt::Long (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use OrePAN2 (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use OrePAN2::Repository (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use Pod::Usage qw( pod2usage ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 3 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 13 | 3 | my $class = shift; | |||||||||||||||||||||||||||
| 14 | 3 | bless {}, $class; | |||||||||||||||||||||||||||
| 15 | } | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 3 | ▶ | sub run { | ||||||||||||||||||||||||||
|
Subroutine
run: called CC=14 SCAR=32.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 18 | 3 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 3 | my $version; | |||||||||||||||||||||||||||
| 21 | 3 | my $generate_index = 1; | |||||||||||||||||||||||||||
| 22 | 3 | my $author = 'DUMMY'; | |||||||||||||||||||||||||||
| 23 | 3 | my $author_subdir = q{}; | |||||||||||||||||||||||||||
| 24 | 3 | my $simple; | |||||||||||||||||||||||||||
| 25 | my $text; | ||||||||||||||||||||||||||||
| 26 | 3 | my $enable_cache = 0; | |||||||||||||||||||||||||||
| 27 | 3 | my $p = Getopt::Long::Parser->new( | |||||||||||||||||||||||||||
| 28 | config => [qw(posix_default no_ignore_case auto_help)] ); | ||||||||||||||||||||||||||||
| 29 | 3 | $p->getoptions( | |||||||||||||||||||||||||||
| 30 | 'version!' => \$version, | ||||||||||||||||||||||||||||
| 31 | 'generate-index!' => \$generate_index, | ||||||||||||||||||||||||||||
| 32 | 'author=s' => \$author, | ||||||||||||||||||||||||||||
| 33 | 'author_subdir=s' => \$author_subdir, | ||||||||||||||||||||||||||||
| 34 | 'simple!' => \$simple, | ||||||||||||||||||||||||||||
| 35 | 'text!' => \$text, | ||||||||||||||||||||||||||||
| 36 | 'cache!' => \$enable_cache, | ||||||||||||||||||||||||||||
| 37 | ); | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 3 | ▶ | if ($version) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 0 | print "orepan2: $OrePAN2::VERSION\n"; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | 3 | ▶ | my $directory = pop @ARGV or pod2usage( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | -input => $0, | ||||||||||||||||||||||||||||
| 44 | ); | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 3 | my $repository = OrePAN2::Repository->new( | |||||||||||||||||||||||||||
| 47 | directory => $directory, | ||||||||||||||||||||||||||||
| 48 | compress_index => !$text, | ||||||||||||||||||||||||||||
| 49 | simple => $simple, | ||||||||||||||||||||||||||||
| 50 | ); | ||||||||||||||||||||||||||||
| 51 | 3 | ▶ | if (@ARGV) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 3 | for (@ARGV) { | |||||||||||||||||||||||||||
| 53 | 3 | ▶ | next unless /\S/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | 3 | ▶ | next if $enable_cache && $repository->has_cache($_); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$enable_cache and $repository->has_cache($_)
MC/DC100%2/2
$enable_cache and $repository->has_cache($_)
$enable_cache
$repository->has_cache($_)
Truth table100%3/3
A and B
A= $enable_cacheB= $repository->has_cache($_)
| |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 2 | my $tarpath = $repository->inject( | |||||||||||||||||||||||||||
| 57 | $_, | ||||||||||||||||||||||||||||
| 58 | { author => $author, author_subdir => $author_subdir } | ||||||||||||||||||||||||||||
| 59 | ); | ||||||||||||||||||||||||||||
| 60 | 2 | print "Wrote $tarpath from $_\n"; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | else { | ||||||||||||||||||||||||||||
| 64 | 0 | ▶ | while (<>) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | 0 | chomp; | |||||||||||||||||||||||||||
| 66 | 0 | ▶ | next unless /\S/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 0 | ▶ | next if $enable_cache && $repository->has_cache($_); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$enable_cache and $repository->has_cache($_)
MC/DC0%0/2
$enable_cache and $repository->has_cache($_)
$enable_cache
$repository->has_cache($_)
Truth table0%0/3
A and B
A= $enable_cacheB= $repository->has_cache($_)
| |||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 0 | my $tarpath = $repository->inject( | |||||||||||||||||||||||||||
| 70 | $_, | ||||||||||||||||||||||||||||
| 71 | { author => $author, author_subdir => $author_subdir } | ||||||||||||||||||||||||||||
| 72 | ); | ||||||||||||||||||||||||||||
| 73 | 0 | print "Wrote $tarpath from $_\n"; | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 3 | ▶ | return unless $repository->cache->is_dirty; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 2 | $repository->save_cache; | |||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 2 | ▶ | if ($generate_index) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | 2 | $repository->make_index(); | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 3 | 1; | |||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||