File Coverage

lib/Dist/Zilla/Plugin/Code/LicenseProvider.pm
Criterion Covered Total %
statement 23 23 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod 0 1 0.0
total 31 32 96.8


line stmt bran cond sub pod time code
1             # vim: ts=4 sts=4 sw=4 et: syntax=perl
2             #
3             # Copyright (c) 2020-2023 Sven Kirmess
4             #
5             # Permission to use, copy, modify, and distribute this software for any
6             # purpose with or without fee is hereby granted, provided that the above
7             # copyright notice and this permission notice appear in all copies.
8             #
9             # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10             # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11             # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12             # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13             # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14             # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15             # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16              
17 2     2   1662 use 5.006;
  2         10  
18 2     2   11 use strict;
  2         4  
  2         42  
19 2     2   10 use warnings;
  2         4  
  2         110  
20              
21             package Dist::Zilla::Plugin::Code::LicenseProvider;
22              
23             our $VERSION = '0.008';
24              
25 2     2   619 use Moose;
  2         453873  
  2         14  
26 2     2   14462 use namespace::autoclean;
  2         4  
  2         16  
27              
28             with 'Dist::Zilla::Role::LicenseProvider';
29              
30 2     2   952 use Config::MVP 2.200012 (); # https://github.com/rjbs/Config-MVP/issues/13
  2         171  
  2         55  
31 2     2   437 use MooseX::Types::Moose qw(CodeRef);
  2         57044  
  2         12  
32              
33             has provide_license => (
34             is => 'ro',
35             isa => 'CodeRef',
36             reader => '_provide_license',
37             required => 1,
38             );
39              
40             sub provide_license {
41 2     2 0 109092 my $self = shift;
42              
43 2         109 my $code_ref = $self->_provide_license;
44 2         15 return $self->$code_ref(@_);
45             }
46              
47             __PACKAGE__->meta->make_immutable;
48              
49             1;
50              
51             __END__
52              
53             =pod
54              
55             =encoding UTF-8
56              
57             =head1 NAME
58              
59             Dist::Zilla::Plugin::Code::LicenseProvider - something that offers a license for a dist
60              
61             =head1 VERSION
62              
63             Version 0.008
64              
65             =head1 SYNOPSIS
66              
67             =head2 Dist::Zilla::Role::PluginBundle
68              
69             package Dist::Zilla::PluginBundle::MyBundle;
70              
71             use Moose;
72             with 'Dist::Zilla::Role::PluginBundle';
73              
74             sub bundle_config {
75             my ( $class, $section ) = @_;
76              
77             my @plugins;
78             push @plugins, [
79             'SomeUniqueName',
80             'Dist::Zilla::Plugin::Code::LicenseProvider',
81             {
82             provide_license => sub {
83             my ($self) = @_;
84             $self->log('Hello world');
85             },
86             },
87             ];
88              
89             return @plugins;
90             }
91              
92             =head2 Dist::Zilla::Role::PluginBundle::Easy
93              
94             package Dist::Zilla::PluginBundle::MyBundle;
95              
96             use Moose;
97             with 'Dist::Zilla::Role::PluginBundle::Easy';
98              
99             sub configure {
100             my ( $self ) = @_;
101              
102             $self->add_plugins([
103             'Code::LicenseProvider',
104             {
105             provide_license => sub {
106             my ($self) = @_;
107             $self->log('Hello world');
108             },
109             },
110             ]);
111              
112             return;
113             }
114              
115             =head1 DESCRIPTION
116              
117             This plugin implements the L<Dist::Zilla::Role::LicenseProvider> role.
118              
119             =head1 SUPPORT
120              
121             =head2 Bugs / Feature Requests
122              
123             Please report any bugs or feature requests through the issue tracker
124             at L<https://github.com/skirmess/Dist-Zilla-Plugin-Code/issues>.
125             You will be notified automatically of any progress on your issue.
126              
127             =head2 Source Code
128              
129             This is open source software. The code repository is available for
130             public review and contribution under the terms of the license.
131              
132             L<https://github.com/skirmess/Dist-Zilla-Plugin-Code>
133              
134             git clone https://github.com/skirmess/Dist-Zilla-Plugin-Code.git
135              
136             =head1 AUTHOR
137              
138             Sven Kirmess <sven.kirmess@kzone.ch>
139              
140             =head1 SEE ALSO
141              
142             L<Dist::Zilla>, L<Dist::Zilla::Role::LicenseProvider>
143              
144             =cut