| line | stmt | bran | cond | sub | pod | time | code | 
| 1 | 5 |  |  | 5 |  | 16205 | use strict; | 
|  | 5 |  |  |  |  | 9 |  | 
|  | 5 |  |  |  |  | 199 |  | 
| 2 | 5 |  |  | 5 |  | 28 | use warnings; | 
|  | 5 |  |  |  |  | 8 |  | 
|  | 5 |  |  |  |  | 284 |  | 
| 3 |  |  |  |  |  |  |  | 
| 4 |  |  |  |  |  |  | package App::Embra::Plugin::WrapZillaPlugin; | 
| 5 |  |  |  |  |  |  | $App::Embra::Plugin::WrapZillaPlugin::VERSION = '0.001'; # TRIAL | 
| 6 |  |  |  |  |  |  | # ABSTRACT: adapts a Dist::Zilla plugin to work with App::Embra | 
| 7 |  |  |  |  |  |  |  | 
| 8 | 5 |  |  | 5 |  | 2835 | use Class::Inspector qw<>; | 
|  | 5 |  |  |  |  | 17408 |  | 
|  | 5 |  |  |  |  | 128 |  | 
| 9 | 5 |  |  | 5 |  | 2313 | use Module::Runtime qw<>; | 
|  | 5 |  |  |  |  | 6207 |  | 
|  | 5 |  |  |  |  | 118 |  | 
| 10 | 5 |  |  | 5 |  | 2445 | use Method::Signatures; | 
|  | 5 |  |  |  |  | 206149 |  | 
|  | 5 |  |  |  |  | 33 |  | 
| 11 |  |  |  |  |  |  |  | 
| 12 | 5 |  |  | 5 |  | 4290 | use App::Embra::Plugin::Zilla::WrapLog; | 
|  | 5 |  |  |  |  | 16 |  | 
|  | 5 |  |  |  |  | 164 |  | 
| 13 | 5 |  |  | 5 |  | 37 | use Moo; | 
|  | 5 |  |  |  |  | 6 |  | 
|  | 5 |  |  |  |  | 24 |  | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | has 'plugin' => ( | 
| 18 |  |  |  |  |  |  | is => 'lazy', | 
| 19 |  |  |  |  |  |  | isa => func( $plugin ) { | 
| 20 |  |  |  |  |  |  | die q{can't wrap something that isn't a Dist::Zilla plugin!} | 
| 21 |  |  |  |  |  |  | if not $plugin->does( 'Dist::Zilla::Role::Plugin' ); | 
| 22 |  |  |  |  |  |  | }, | 
| 23 |  |  |  |  |  |  | ); | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | has 'plugin_args' => ( | 
| 26 |  |  |  |  |  |  | is => 'ro', | 
| 27 |  |  |  |  |  |  | default => func { {} }, | 
| 28 |  |  |  |  |  |  | ); | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  |  | 
| 31 | 5 | 50 |  | 5 |  | 40525 | around 'isa' => func ( $orig, $self, $class ) { | 
|  | 5 |  |  | 5 |  | 3172 |  | 
|  | 5 |  |  |  |  | 32 |  | 
| 32 | 5 |  |  |  |  | 42 | return $class eq 'Dist::Zilla' || $orig->($self, $class); # cheeky | 
| 33 |  |  |  |  |  |  | }; | 
| 34 | 5 | 100 |  |  |  | 48 |  | 
| 35 | 4 |  |  |  |  | 358 | method _build_plugin { | 
| 36 |  |  |  |  |  |  | ( my $plugin_class = $self->name ) =~ s/^-/Dist::Zilla::Plugin::/xms; | 
| 37 |  |  |  |  |  |  |  | 
| 38 | 5 |  |  |  |  | 5518 | if( not Class::Inspector->loaded( $plugin_class ) ) { | 
| 39 |  |  |  |  |  |  | Module::Runtime::require_module $plugin_class; | 
| 40 |  |  |  |  |  |  | } | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | return $plugin_class->new( | 
| 43 |  |  |  |  |  |  | zilla => $self, | 
| 44 |  |  |  |  |  |  | plugin_name => $self->name, | 
| 45 | 5 |  |  |  |  | 19111 | logger => App::Embra::Plugin::Zilla::WrapLog->new( | 
| 46 |  |  |  |  |  |  | proxy_prefix => '['.$self->name.'] ', | 
| 47 |  |  |  |  |  |  | logger => $self->embra->logger, | 
| 48 |  |  |  |  |  |  | ), | 
| 49 | 5 |  |  | 5 |  | 10918 | %{ $self->plugin_args }, | 
|  | 5 |  |  | 5 |  | 6865 |  | 
|  | 5 |  |  |  |  | 233 |  | 
| 50 | 5 |  |  |  |  | 26 | ); | 
| 51 | 5 |  |  |  |  | 9 | } | 
| 52 | 5 |  |  |  |  | 15 |  | 
| 53 | 15 | 100 |  |  |  | 54 | method BUILDARGS( @args ) { | 
| 54 | 10 |  |  |  |  | 32 | my %args = @args; | 
| 55 |  |  |  |  |  |  | my %attrs; | 
| 56 |  |  |  |  |  |  | for my $attr ( qw< embra name plugin > ) { | 
| 57 |  |  |  |  |  |  | if( exists $args{$attr} ) { | 
| 58 | 5 |  |  |  |  | 195 | $attrs{$attr} = delete $args{$attr}; | 
| 59 |  |  |  |  |  |  | } | 
| 60 |  |  |  |  |  |  | } | 
| 61 | 5 | 50 |  | 5 |  | 3266 |  | 
|  | 3 |  |  | 3 |  | 67 |  | 
|  | 3 |  |  |  |  | 16 |  | 
| 62 | 3 | 50 |  | 1 |  | 31 | return { %attrs, plugin_args => \%args }; | 
|  | 1 | 50 |  |  |  | 12 |  | 
|  | 1 | 50 |  |  |  | 2 |  | 
|  | 1 | 50 |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 6 |  | 
|  | 2 |  |  |  |  | 22 |  | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 8 |  | 
|  | 2 |  |  |  |  | 8 |  | 
| 63 |  |  |  |  |  |  | } | 
| 64 | 3 |  |  |  |  | 34 |  | 
| 65 | 6 |  |  |  |  | 842 | method publish_site { | 
|  | 6 |  |  |  |  | 17 |  | 
| 66 | 6 |  |  |  |  | 33 | my @wraps = ( | 
| 67 | 6 | 100 |  |  |  | 72 | [ '-AfterBuild'    => func( $plugin ) { $plugin->after_build({ build_root => q<.> }) } ], | 
| 68 | 3 | 0 |  | 0 |  | 145 | [ '-BeforeRelease' => func( $plugin ) { $plugin->before_release()                    } ], | 
|  | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
| 69 | 3 |  |  |  |  | 74 | ); | 
| 70 |  |  |  |  |  |  | for my $wrap ( @wraps ) { | 
| 71 |  |  |  |  |  |  | my( $role, $shim ) = @{ $wrap }; | 
| 72 |  |  |  |  |  |  | $role =~ s/^-/Dist::Zilla::Role::/xms; | 
| 73 |  |  |  |  |  |  | if( $self->plugin->does( $role ) ) { | 
| 74 | 5 | 0 | 0 | 5 |  | 34924 | local *Dist::Zilla::VERSION = method { 4 }; # App::Embra::File->content, not ->encoded_content | 
|  | 0 | 0 | 0 | 0 |  |  |  | 
|  | 0 | 0 |  |  |  |  |  | 
|  | 0 |  |  |  |  |  |  | 
|  | 0 |  |  |  |  |  |  | 
|  | 0 |  |  |  |  |  |  | 
|  | 0 |  |  |  |  |  |  | 
|  | 0 |  |  |  |  |  |  | 
| 75 | 0 |  |  |  |  |  | $shim->( $self->plugin ); | 
| 76 | 0 |  |  |  |  |  | } | 
| 77 |  |  |  |  |  |  | } | 
| 78 |  |  |  |  |  |  | } | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | method extra_list_deps($class:, HashRef :$config) { | 
| 81 |  |  |  |  |  |  | ( my $plugin_class = $config->{_name} ) =~ s/^-/Dist::Zilla::Plugin::/xms; | 
| 82 |  |  |  |  |  |  | return $plugin_class; | 
| 83 |  |  |  |  |  |  | } | 
| 84 |  |  |  |  |  |  |  | 
| 85 |  |  |  |  |  |  | with 'App::Embra::Role::SitePublisher'; | 
| 86 |  |  |  |  |  |  | with 'App::Embra::Role::ExtraListDeps'; | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | has '+embra' => ( | 
| 89 |  |  |  |  |  |  | is => 'ro', | 
| 90 |  |  |  |  |  |  | required => 1, | 
| 91 |  |  |  |  |  |  | handles => [ qw< files > ], | 
| 92 |  |  |  |  |  |  | ); | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | 1; | 
| 95 |  |  |  |  |  |  |  | 
| 96 |  |  |  |  |  |  | __END__ | 
| 97 |  |  |  |  |  |  |  | 
| 98 |  |  |  |  |  |  | =pod | 
| 99 |  |  |  |  |  |  |  | 
| 100 |  |  |  |  |  |  | =encoding UTF-8 | 
| 101 |  |  |  |  |  |  |  | 
| 102 |  |  |  |  |  |  | =head1 NAME | 
| 103 |  |  |  |  |  |  |  | 
| 104 |  |  |  |  |  |  | App::Embra::Plugin::WrapZillaPlugin - adapts a Dist::Zilla plugin to work with App::Embra | 
| 105 |  |  |  |  |  |  |  | 
| 106 |  |  |  |  |  |  | =head1 VERSION | 
| 107 |  |  |  |  |  |  |  | 
| 108 |  |  |  |  |  |  | version 0.001 | 
| 109 |  |  |  |  |  |  |  | 
| 110 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 111 |  |  |  |  |  |  |  | 
| 112 |  |  |  |  |  |  | This plugin fools something which does L<Dist::Zilla::Role::Plugin> into treating a L<App::Embra> as if it were a L<Dist::Zilla>. Not all Dist::Zilla plugin roles are supported! | 
| 113 |  |  |  |  |  |  |  | 
| 114 |  |  |  |  |  |  | =head1 ATTRIBUTES | 
| 115 |  |  |  |  |  |  |  | 
| 116 |  |  |  |  |  |  | =head2 plugin | 
| 117 |  |  |  |  |  |  |  | 
| 118 |  |  |  |  |  |  | This is a L<Dist::Zilla> plugin adapted to work on L<App::Embra>; | 
| 119 |  |  |  |  |  |  |  | 
| 120 |  |  |  |  |  |  | =for Pod::Coverage isa | 
| 121 |  |  |  |  |  |  |  | 
| 122 |  |  |  |  |  |  | =head1 AUTHOR | 
| 123 |  |  |  |  |  |  |  | 
| 124 |  |  |  |  |  |  | Daniel Holz <dgholz@gmail.com> | 
| 125 |  |  |  |  |  |  |  | 
| 126 |  |  |  |  |  |  | =head1 COPYRIGHT AND LICENSE | 
| 127 |  |  |  |  |  |  |  | 
| 128 |  |  |  |  |  |  | This software is copyright (c) 2015 by Daniel Holz. | 
| 129 |  |  |  |  |  |  |  | 
| 130 |  |  |  |  |  |  | This is free software; you can redistribute it and/or modify it under | 
| 131 |  |  |  |  |  |  | the same terms as the Perl 5 programming language system itself. | 
| 132 |  |  |  |  |  |  |  | 
| 133 |  |  |  |  |  |  | =cut |