| 1 | 4 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 4 | ▶ | use warnings FATAL => 'recursion'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 4 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 4 | ▶ | use Daiku::Task; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 4 | ▶ | use Daiku::File; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 4 | ▶ | use Daiku::SuffixRule; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 4 | ▶ | use Parse::CommandLine (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 4 | ▶ | use Tie::IxHash; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | package Daiku::Registry; | ||||||||||
| 13 | 4 | ▶ | use Mouse; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | has tasks => ( | ||||||||||
| 16 | is => 'rw', | ||||||||||
| 17 | isa => 'HashRef', | ||||||||||
| 18 | 2 | ▶ | default => sub { tie my %h, "Tie::IxHash"; \%h }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 4 | ); | |||||||||
| 20 | |||||||||||
| 21 | 4 | has temporary_desc => ( | |||||||||
| 22 | is => 'rw', | ||||||||||
| 23 | isa => 'Str', | ||||||||||
| 24 | clearer => 'clear_temporary_desc', | ||||||||||
| 25 | ); | ||||||||||
| 26 | |||||||||||
| 27 | has namespaces => ( | ||||||||||
| 28 | is => 'rw', | ||||||||||
| 29 | isa => 'ArrayRef', | ||||||||||
| 30 | 2 | ▶ | default => sub { [] }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 31 | 4 | ); | |||||||||
| 32 | |||||||||||
| 33 | sub register { | ||||||||||
| 34 | 7 | ▶ | my ($self, $task) = (shift, shift); | ||||||||
|
Subroutine
register: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 35 | 7 | my $orig = $self->find_task($task->dst); | |||||||||
| 36 | 7 | ▶ | $task->merge($orig) if $orig; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | 7 | $self->tasks->{$task->dst} = $task; | |||||||||
| 38 | 7 | $task->registry($self); | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | sub build { | ||||||||||
| 42 | 2 | ▶ | my ($self, $target) = @_; | ||||||||
|
Subroutine
build: called CC=4 SCAR=15.0
Pod
documented
| |||||||||||
| 43 | 2 | ▶ | if (!defined $target) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | 0 | die "Missing target\n"; | |||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | # parsing 'task_name[arg1 arg2]' | ||||||||||
| 48 | 2 | ($target, my $argument) = $target =~ /\A([^\[]+)(?:\[(.*)\])?\z/ms; | |||||||||
| 49 | 2 | my @args; | |||||||||
| 50 | 2 | ▶ | @args = Parse::CommandLine::parse_command_line($argument) if defined $argument; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 51 | |||||||||||
| 52 | 2 | my $task = $self->find_task($target); | |||||||||
| 53 | 2 | ▶ | if ($task) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 54 | 2 | return $task->build($target, @args); | |||||||||
| 55 | } else { | ||||||||||
| 56 | 0 | die "There is no rule to build '$target'\n"; | |||||||||
| 57 | } | ||||||||||
| 58 | } | ||||||||||
| 59 | |||||||||||
| 60 | sub find_task { | ||||||||||
| 61 | 14 | ▶ | my ($self, $target) = @_; | ||||||||
|
Subroutine
find_task: called CC=4 SCAR=14.1
Pod
undocumented
| |||||||||||
| 62 | 14 | for my $task (values %{$self->{tasks}}) { | |||||||||
| 63 | 37 | ▶ | return $task if $task->match($target); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 64 | } | ||||||||||
| 65 | 7 | ▶ | if ( -f $target ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 66 | 0 | return Daiku::File->new( dst => $target ); | |||||||||
| 67 | } | ||||||||||
| 68 | 7 | return undef; | |||||||||
| 69 | } | ||||||||||
| 70 | |||||||||||
| 71 | 4 | ▶ | no Mouse; __PACKAGE__->meta->make_immutable; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 72 | |||||||||||
| 73 | __END__ | ||||||||||