| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package App::JESP::Plan; | 
| 2 |  |  |  |  |  |  | $App::JESP::Plan::VERSION = '0.014'; | 
| 3 | 8 |  |  | 8 |  | 47 | use Moose; | 
|  | 8 |  |  |  |  | 13 |  | 
|  | 8 |  |  |  |  | 38 |  | 
| 4 | 8 |  |  | 8 |  | 49757 | use File::Slurp; | 
|  | 8 |  |  |  |  | 87655 |  | 
|  | 8 |  |  |  |  | 494 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 | 8 |  |  | 8 |  | 2147 | use App::JESP::Patch; | 
|  | 8 |  |  |  |  | 31 |  | 
|  | 8 |  |  |  |  | 2205 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | =head1 NAME | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | App::JESP::Plan - Represents a patching plan | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | =cut | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | has 'jesp' => ( is => 'ro' , isa => 'App::JESP', required => 1, weak_ref => 1); | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | has 'file' => ( is => 'ro', isa => 'Str', required => 1 ); | 
| 17 |  |  |  |  |  |  | has 'patches' => ( is => 'ro' , isa => 'ArrayRef[App::JESP::Patch]', lazy_build => 1 ); | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | has 'raw_data' => ( is => 'ro', isa => 'HashRef' , lazy_build => 1); | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | sub _build_raw_data{ | 
| 22 | 3 |  |  | 3 |  | 7 | my ($self) = @_; | 
| 23 | 3 |  |  |  |  | 62 | my $content = File::Slurp::read_file( $self->file() ); | 
| 24 | 3 |  |  |  |  | 260 | return $self->jesp->json->decode( $content ); | 
| 25 |  |  |  |  |  |  | } | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | sub _build_patches{ | 
| 28 | 3 |  |  | 3 |  | 7 | my ($self) = @_; | 
| 29 | 3 | 50 |  |  |  | 73 | unless( $self->raw_data()->{patches} ){ | 
| 30 | 0 |  |  |  |  | 0 | die "Missing 'patches' in plan file ".$self->file()."\n"; | 
| 31 |  |  |  |  |  |  | } | 
| 32 |  |  |  |  |  |  |  | 
| 33 | 3 |  |  |  |  | 9 | my @patches = (); | 
| 34 | 3 |  |  |  |  | 5 | foreach my $raw_patch ( @{ $self->raw_data()->{patches} } ){ | 
|  | 3 |  |  |  |  | 59 |  | 
| 35 | 11 |  |  |  |  | 245 | push @patches , App::JESP::Patch->new({ | 
| 36 |  |  |  |  |  |  | %$raw_patch, | 
| 37 |  |  |  |  |  |  | jesp => $self->jesp() | 
| 38 |  |  |  |  |  |  | }); | 
| 39 |  |  |  |  |  |  | } | 
| 40 | 3 |  |  |  |  | 66 | return \@patches; | 
| 41 |  |  |  |  |  |  | } | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | __PACKAGE__->meta->make_immutable(); | 
| 44 |  |  |  |  |  |  | 1; |