| 1 | package App::JESP::Plan; | ||||||||||
| 2 | 8 | $App::JESP::Plan::VERSION = '0.016'; | |||||||||
| 3 | 8 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 8 | ▶ | use File::Slurp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 8 | ▶ | use App::JESP::Patch; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | =head1 NAME | ||||||||||
| 9 | |||||||||||
| 10 | App::JESP::Plan - Represents a patching plan | ||||||||||
| 11 | |||||||||||
| 12 | =cut | ||||||||||
| 13 | |||||||||||
| 14 | 8 | has 'jesp' => ( is => 'ro' , isa => 'App::JESP', required => 1, weak_ref => 1); | |||||||||
| 15 | |||||||||||
| 16 | 8 | has 'file' => ( is => 'ro', isa => 'Str', required => 1 ); | |||||||||
| 17 | 8 | has 'patches' => ( is => 'ro' , isa => 'ArrayRef[App::JESP::Patch]', lazy_build => 1 ); | |||||||||
| 18 | |||||||||||
| 19 | 8 | has 'raw_data' => ( is => 'ro', isa => 'HashRef' , lazy_build => 1); | |||||||||
| 20 | |||||||||||
| 21 | 3 | ▶ | sub _build_raw_data{ | ||||||||
|
Subroutine
_build_raw_data: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 3 | my ($self) = @_; | |||||||||
| 23 | 3 | my $content = File::Slurp::read_file( $self->file() ); | |||||||||
| 24 | 3 | return $self->jesp->json->decode( $content ); | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | 3 | ▶ | sub _build_patches{ | ||||||||
|
Subroutine
_build_patches: called CC=3 SCAR=11.2
| |||||||||||
| 28 | 3 | my ($self) = @_; | |||||||||
| 29 | 3 | ▶ | unless( $self->raw_data()->{patches} ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | 0 | die "Missing 'patches' in plan file ".$self->file()."\n"; | |||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 3 | my @patches = (); | |||||||||
| 34 | 3 | foreach my $raw_patch ( @{ $self->raw_data()->{patches} } ){ | |||||||||
| 35 | 11 | push @patches , App::JESP::Patch->new({ | |||||||||
| 36 | %$raw_patch, | ||||||||||
| 37 | jesp => $self->jesp() | ||||||||||
| 38 | }); | ||||||||||
| 39 | } | ||||||||||
| 40 | 3 | return \@patches; | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 8 | __PACKAGE__->meta->make_immutable(); | |||||||||
| 44 | 8 | 1; | |||||||||