File Coverage

blib/lib/RDF/DOAP/Version.pm
Criterion Covered Total %
statement 69 69 100.0
branch 11 12 91.6
condition 6 8 75.0
subroutine 15 15 100.0
pod 0 1 0.0
total 101 105 96.1


line stmt bran cond sub pod time code
1              
2             our $AUTHORITY = 'cpan:TOBYINK';
3             our $VERSION = '0.105';
4              
5             use Moose;
6 2     2   12 extends qw(RDF::DOAP::Resource);
  2         5  
  2         10  
7              
8             use RDF::DOAP::ChangeSet;
9 2     2   11816 use RDF::DOAP::Change;
  2         80  
  2         67  
10 2     2   14 use RDF::DOAP::Person;
  2         4  
  2         30  
11 2     2   9 use RDF::DOAP::Types -types;
  2         3  
  2         48  
12 2     2   10 use RDF::DOAP::Utils -traits;
  2         3  
  2         12  
13 2     2   10220 use List::Util qw(uniq);
  2         7  
  2         7  
14 2     2   585 use Text::Wrap qw(wrap);
  2         4  
  2         102  
15 2     2   12  
  2         15  
  2         87  
16             use RDF::Trine::Namespace qw(rdf rdfs owl xsd);
17 2     2   12 my $doap = 'RDF::Trine::Namespace'->new('http://usefulinc.com/ns/doap#');
  2         4  
  2         16  
18             my $dc = 'RDF::Trine::Namespace'->new('http://purl.org/dc/terms/');
19             my $dcs = 'RDF::Trine::Namespace'->new('http://ontologi.es/doap-changeset#');
20              
21             has $_ => (
22             traits => [ WithURI ],
23             is => 'ro',
24             isa => String,
25             coerce => 1,
26             uri => $doap->$_,
27             ) for qw( revision name branch );
28              
29             has issued => (
30             traits => [ WithURI ],
31             is => 'ro',
32             isa => String,
33             coerce => 1,
34             uri => $dc->issued,
35             );
36              
37             has changesets => (
38             traits => [ WithURI ],
39             is => 'ro',
40             isa => ArrayRef[ChangeSet],
41             coerce => 1,
42             uri => $dcs->changeset,
43             multi => 1,
44             trigger => sub { $_[0]->clear_changes },
45             );
46              
47             has changes => (
48             is => 'ro',
49             isa => ArrayRef[Change],
50             coerce => 1,
51             lazy => 1,
52             builder => '_build_changes',
53             clearer => 'clear_changes',
54             );
55              
56             has released_by => (
57             traits => [ WithURI, Gathering ],
58             is => 'ro',
59             isa => Person,
60             coerce => 1,
61             uri => $dcs->uri('released-by'),
62             gather_as => ['maintainer'],
63             );
64              
65             has _changelog_subsections => (
66             is => 'ro',
67             isa => ArrayRef[ArrayRef],
68             lazy => 1,
69             builder => '_build_changelog_subsections',
70             );
71              
72             {
73             my $self = shift;
74             [ map { @{$_->items} } @{$self->changesets || []} ];
75 7     7   10 }
76 7 100       10  
  6         8  
  6         122  
  7         142  
77             {
78             my $self = shift;
79            
80             my @ss = @{ $self->_changelog_subsections };
81 7     7 0 8
82             if (@ss == 1 and $ss[0][0] eq 'Other')
83 7         8 {
  7         152  
84             # If there's only an "Other" section, then avoid
85 7 100 100     30 # printing a section header for it.
86             return join(
87             "\n",
88             $self->_changelog_section_header,
89             map {
90             my ($head, @lines) = @$_;
91             (sort(@lines), '');
92             } @ss,
93 1         6 );
  1         4  
94 1         8 }
95            
96             return join(
97             "\n",
98             $self->_changelog_section_header,
99             map {
100             my ($head, @lines) = @$_;
101             (" [ $head ]", sort(@lines), '');
102             } @ss,
103 6         15 );
  7         18  
104 7         45 }
105              
106             {
107             my $self = shift;
108             return join(
109             "\t",
110             grep(
111 8     8   11 defined,
112 8   50     169 $self->revision,
      66        
113             ($self->issued // 'Unknown'),
114             ($self->name // $self->label),
115             ),
116             ) . "\n";
117             }
118              
119             {
120             my $self = shift;
121             uniq(map $_->[1], $self->_subsection_classification);
122             }
123              
124             {
125 7     7   9 (
126 7         14 [$dcs->SecurityFix => 'SECURITY', 'Fix'],
127             [$dcs->SecurityRegression => 'SECURITY', 'Regression'],
128             [$dcs->BackCompat => 'BACK COMPAT'],
129             [$dcs->Regression => 'REGRESSIONS'],
130             [$dcs->Bugfix => 'Bug Fixes'],
131             [$dcs->Documentation => 'Documentation'],
132 14     14   77 [$dcs->Tests => 'Test Suite'],
133             [$dcs->Packaging => 'Packaging'],
134             [$dcs->Addition => 'Other', 'Added'],
135             [$dcs->Removal => 'Other', 'Removed'],
136             [$dcs->Update => 'Other', 'Updated'],
137             [$dcs->Change => 'Other'],
138             );
139             }
140              
141             {
142             my $self = shift;
143            
144             my %sections;
145             my @classifications = $self->_subsection_classification;
146            
147             for my $ch (@{ $self->changes })
148             {
149 7     7   10 my $found_section;
150             for my $class (@classifications)
151 7         11 {
152 7         13 my ($type, $section, $tag) = @$class;
153             if ( $ch->isa($type) )
154 7         2334 {
  7         161  
155             my $text = join "\n", $ch->changelog_lines(1);
156 8         10 $text = "$tag: $text" if $tag;
157 8         13 push @{ $sections{$section} }, wrap(" - ", " ", $text);
158             $found_section++;
159 54         4977 last;
160 54 100       115 }
161             }
162 7         988 unless ($found_section)
163 7 50       48 {
164 7         10 my $text = join "\n", $ch->changelog_lines(1);
  7         29  
165 7         1747 push @{ $sections{Other} }, wrap(" - ", " ", $text);
166 7         13 }
167             }
168            
169 8 100       31 return [
170             map { exists($sections{$_}) ? [$_, @{$sections{$_}}] : (); }
171 1         6 $self->_subsection_order
172 1         5 ];
  1         5  
173             }
174              
175             1;