| 1 | #!/usr/bin/perl | ||||||||||
| 2 | |||||||||||
| 3 | package KiokuDB::Cmd::InputHandle; | ||||||||||
| 4 | 1 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use MooseX::Types::Path::Class qw(File); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | use namespace::clean -except => 'meta'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 1 | excludes qw(KiokuDB::Cmd::OutputHandle); | |||||||||
| 11 | |||||||||||
| 12 | 1 | has file => ( | |||||||||
| 13 | traits => [qw(Getopt)], | ||||||||||
| 14 | isa => File, | ||||||||||
| 15 | is => "ro", | ||||||||||
| 16 | coerce => 1, | ||||||||||
| 17 | predicate => "has_file", | ||||||||||
| 18 | cmd_aliases => "i", | ||||||||||
| 19 | documentation => "input file (defaults to STDIN)", | ||||||||||
| 20 | ); | ||||||||||
| 21 | |||||||||||
| 22 | 1 | has input_handle => ( | |||||||||
| 23 | traits => [qw(NoGetopt EarlyBuild)], | ||||||||||
| 24 | isa => "FileHandle", | ||||||||||
| 25 | is => "ro", | ||||||||||
| 26 | lazy_build => 1, | ||||||||||
| 27 | ); | ||||||||||
| 28 | |||||||||||
| 29 | 0 | ▶ | sub _build_input_handle { | ||||||||
|
Subroutine
_build_input_handle: not called CC=2 SCAR=17.9
| |||||||||||
| 30 | 0 | my $self = shift; | |||||||||
| 31 | |||||||||||
| 32 | 0 | ▶ | if ( $self->has_file ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 0 | $self->file->openr; | |||||||||
| 34 | } else { | ||||||||||
| 35 | 0 | \*STDIN; | |||||||||
| 36 | } | ||||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | 1 | __PACKAGE__ | |||||||||
| 40 | |||||||||||
| 41 | __END__ | ||||||||||