File Coverage

blib/lib/CPAN/Changes/Dependencies/Details.pm
Criterion Covered Total %
statement 28 57 49.1
branch 0 6 0.0
condition n/a
subroutine 11 15 73.3
pod 2 2 100.0
total 41 80 51.2


line stmt bran cond sub pod time code
1 2     2   23773 use 5.006; # our
  2         7  
2 2     2   9 use strict;
  2         3  
  2         56  
3 2     2   16 use warnings;
  2         2  
  2         173  
4              
5             package CPAN::Changes::Dependencies::Details;
6              
7             our $VERSION = '0.001007';
8              
9             # ABSTRACT: Create CPAN::Changes style file only containing dependency change information
10              
11             our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
12              
13 2     2   1129 use Moo qw( extends around );
  2         23173  
  2         8  
14 2     2   4015 use MooX::Lsub qw( lsub );
  2         7569  
  2         8  
15 2     2   694 use Carp qw( croak );
  2         4  
  2         67  
16 2     2   971 use CPAN::Changes::Release;
  2         9947  
  2         67  
17 2     2   1183 use CPAN::Changes::Group::Dependencies::Details 0.001001; # First useful version
  2         183822  
  2         728  
18              
19             extends 'CPAN::Changes';
20              
21 0     0   0 lsub change_types => sub { [qw( Added Changed Removed )] };
22 0     0   0 lsub phases => sub { [qw( configure build runtime test )] };
23 0     0   0 lsub types => sub { [qw( requires )] };
24              
25 1     1 1 180 sub load { croak 'This module can only generate dependency details, not read them' }
26 1     1 1 104 sub load_string { croak 'This module can only generate dependency details, not read them' }
27              
28             my $release_keys = [ 'changes', 'version', 'date', 'note', ];
29             my $group_keys = [ 'new_prereqs', 'old_prereqs', 'prereqs_diff', 'all_diffs', ];
30              
31             sub _mk_release {
32 0     0     my ( $self, $release ) = @_;
33 0           my $input_args = { %{$release} };
  0            
34 0           my $release_args = {};
35 0           my $group_args = {};
36              
37 0           for my $release_key ( @{$release_keys} ) {
  0            
38 0 0         next unless exists $input_args->{$release_key};
39 0           $release_args->{$release_key} = delete $input_args->{$release_key};
40             }
41              
42 0           for my $group_key ( @{$group_keys} ) {
  0            
43 0 0         next unless exists $input_args->{$group_key};
44 0           $group_args->{$group_key} = delete $input_args->{$group_key};
45             }
46              
47 0           my $release_object = CPAN::Changes::Release->new( %{$release_args} );
  0            
48              
49 0           for my $change_type ( @{ $self->change_types } ) {
  0            
50 0           for my $phase ( @{ $self->phases } ) {
  0            
51 0           for my $type ( @{ $self->types } ) {
  0            
52             my $group = CPAN::Changes::Group::Dependencies::Details->new(
53             change_type => $change_type,
54             phase => $phase,
55             type => $type,
56 0           %{$group_args},
  0            
57             );
58 0 0         next unless $group->has_changes;
59 0           $release_object->attach_group($group);
60             }
61             }
62             }
63 0           return $release_object;
64             }
65              
66             around add_release => sub {
67             my ( $orig, $self, @releases ) = @_;
68             for my $release (@releases) {
69             my $release_object = $self->_mk_release($release);
70             $self->$orig($release_object);
71             }
72             return;
73             };
74              
75 2     2   12 no Moo;
  2         4  
  2         9  
76              
77             1;
78              
79             __END__
80              
81             =pod
82              
83             =encoding UTF-8
84              
85             =head1 NAME
86              
87             CPAN::Changes::Dependencies::Details - Create CPAN::Changes style file only containing dependency change information
88              
89             =head1 VERSION
90              
91             version 0.001007
92              
93             =head1 SYNOPSIS
94              
95             use CPAN::Changes::Dependencies::Details;
96             my $details = CPAN::Changes::Dependencies::Details->new(
97             preamble => "Some message",
98             change_types => [qw( Added Changed Removed )],
99             phases => [qw( build configure runtime test )],
100             types => [qw( requires recommends )],
101             );
102              
103             $changes->add_release({
104             version => '0.002',
105             date => '2009-07-06',
106             old_prereqs => CPAN::Meta->load_file('Dist-Foo-0.001/META.json')->effective_prereqs,
107             new_prereqs => CPAN::Meta->load_file('Dist-Foo-0.002/META.json')->effective_prereqs,
108             });
109              
110             print $changes->serialize;
111              
112             =head1 DESCRIPTION
113              
114             This module serves as a utility for producing complex change-logs in C<CPAN::Changes> style,
115             specifically tailored to conveying the nature of dependency changes between releases.
116              
117             It typically requires some mechanism external to this code to report the state of prerequisites
118             at given versions, where it computes their differences and produces sections detailing
119             the kinds of changes you have elected to itemize.
120              
121             =head1 AUTHOR
122              
123             Kent Fredric <kentnl@cpan.org>
124              
125             =head1 COPYRIGHT AND LICENSE
126              
127             This software is copyright (c) 2017 by Kent Fredric <kentfredric@gmail.com>.
128              
129             This is free software; you can redistribute it and/or modify it under
130             the same terms as the Perl 5 programming language system itself.
131              
132             =cut