« Dist/Zilla/Plugin/ATOOMIC/Contributors.pm
↑ Summary
Dist/Zilla/Plugin/ATOOMIC/Git/CheckFor/CorrectBranch.pm »
| 1 | package Dist::Zilla::Plugin::ATOOMIC::License; | ||
| 2 | |||
| 3 | use v5.10; | ||
| 4 | |||
| 5 | use strict; | ||
| 6 | use warnings; | ||
| 7 | use autodie; | ||
| 8 | use namespace::autoclean; | ||
| 9 | |||
| 10 | our $VERSION = '1.00'; | ||
| 11 | |||
| 12 | use Module::Runtime qw( use_module ); | ||
| 13 | use String::RewritePrefix; | ||
| 14 | |||
| 15 | use Moose; | ||
| 16 | |||
| 17 | with 'Dist::Zilla::Role::LicenseProvider'; | ||
| 18 | |||
| 19 | sub provide_license { | ||
| 20 | my $self = shift; | ||
| 21 | my $args = shift; | ||
| 22 | |||
| 23 | my $year = $args->{copyright_year}; | ||
| 24 | my $this_year = (localtime)[5] + 1900; | ||
| 25 | my $years = $year == $this_year ? $year : "$year - $this_year"; | ||
| 26 | |||
| 27 | my $license_class = String::RewritePrefix->rewrite( | ||
| 28 | { | ||
| 29 | '=' => q{}, | ||
| 30 | q{} => 'Software::License::' | ||
| 31 | }, | ||
| 32 | $self->zilla()->_license_class() // 'Artistic_2_0', | ||
| 33 | ); | ||
| 34 | |||
| 35 | use_module($license_class); | ||
| 36 | |||
| 37 | return $license_class->new( | ||
| 38 | { | ||
| 39 | holder => $args->{copyright_holder} || 'David Rolsky', | ||
| 40 | year => $years, | ||
| 41 | }, | ||
| 42 | ); | ||
| 43 | } | ||
| 44 | |||
| 45 | __PACKAGE__->meta->make_immutable; | ||
| 46 | |||
| 47 | 1; | ||
| 48 | |||
| 49 | # ABSTRACT: Sets up default license and copyright holder | ||
| 50 | |||
| 51 | __END__ |