| 1 | package TaskPipe::Template_Config; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use YAML::XS 'Dump'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use TaskPipe::Tool::Options; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Hash::Merge; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | extends 'TaskPipe::Template'; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | has options => (is => 'rw', isa => 'TaskPipe::Tool::Options', default => sub{ | ||||||||||||||||||||||||||||
| 10 | 5 | ▶ | TaskPipe::Tool::Options->new; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | }); | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 1 | has dir_label => (is => 'ro', isa => 'Str', default => 'conf'); | |||||||||||||||||||||||||||
| 14 | 1 | has filename_label => (is => 'ro', isa => 'Str', default => 'conf'); | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | sub deploy{ | ||||||||||||||||||||||||||||
| 17 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
deploy: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 0 | my @specs = @{$self->option_specs}; | |||||||||||||||||||||||||||
| 20 | 0 | for my $i ( 0..$#specs ){ | |||||||||||||||||||||||||||
| 21 | 0 | ▶ | $specs[$i] = {module => $specs[$i]} if ref $specs[$i] eq ref ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | 0 | ▶ | $specs[$i]{section} = 'METHODS' unless $specs[$i]{section}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 0 | $self->options->add_specs( \@specs ); | |||||||||||||||||||||||||||
| 26 | 0 | ▶ | $self->fine_tune if $self->can('adjustments') && $self->adjustments; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->can("adjustments") and $self->adjustments
MC/DC0%0/2
$self->can("adjustments") and $self->adjustments
$self->can("adjustments")
$self->adjustments
Truth table0%0/3
A and B
A= $self->can("adjustments")B= $self->adjustments
| |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 0 | $self->write_file( +Dump( $self->options->specs_by_module ) ); | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | sub fine_tune{ | ||||||||||||||||||||||||||||
| 33 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
fine_tune: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | my $merger = Hash::Merge->new('LEFT_PRECEDENT'); | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 0 | $self->options->specs_by_module( $merger->merge( | |||||||||||||||||||||||||||
| 38 | $self->adjustments, | ||||||||||||||||||||||||||||
| 39 | $self->options->specs_by_module | ||||||||||||||||||||||||||||
| 40 | )); | ||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | # foreach my $module ( keys %{$self->adjustments} ){ | ||||||||||||||||||||||||||||
| 45 | # foreach my $method ( keys %{$self->adjustments->{$module}} ){ | ||||||||||||||||||||||||||||
| 46 | # $self->options->specs_by_module->{ $module }{ $method } = $new_val; | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | =head1 NAME | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | TaskPipe::Template_Config | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | Inherit from this class to create a config file template (ie for deployment to the global config directory. See e.g. L<TaskPipe::Template_Config_Global> and L<TaskPipe::Template_Config_Project> for examples of how to do this | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | Tom Gracey <tomgracey@gmail.com> | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | Copyright (c) Tom Gracey 2018 | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | TaskPipe is free software, licensed under | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | The GNU Public License Version 3 | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | =cut | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 71 | 1 | 1; | |||||||||||||||||||||||||||