File Coverage

blib/lib/RDF/DOAP/Change/Bugfix.pm
Criterion Covered Total %
statement 17 17 100.0
branch 2 4 50.0
condition n/a
subroutine 5 5 100.0
pod n/a
total 24 26 92.3


line stmt bran cond sub pod time code
1              
2             our $AUTHORITY = 'cpan:TOBYINK';
3             our $VERSION = '0.105';
4              
5             use Moose::Role;
6 1     1   738 requires qw( rdf_about rdf_model );
  1         2  
  1         10  
7              
8             use RDF::DOAP::Issue;
9 1     1   5256 use RDF::DOAP::Types -types;
  1         28  
  1         38  
10 1     1   6  
  1         2  
  1         5  
11             use RDF::Trine::Namespace qw(rdf rdfs owl xsd);
12 1     1   5184 my $doap = 'RDF::Trine::Namespace'->new('http://usefulinc.com/ns/doap#');
  1         2  
  1         5  
13             my $dc = 'RDF::Trine::Namespace'->new('http://purl.org/dc/terms/');
14             my $dcs = 'RDF::Trine::Namespace'->new('http://ontologi.es/doap-changeset#');
15              
16             has fixes => (
17             is => 'ro',
18             isa => ArrayRef[Issue],
19             coerce => 1,
20             lazy => 1,
21             builder => '_build_fixes',
22             );
23              
24             {
25             my $self = shift;
26             return [] unless $self->has_rdf_about;
27 4     4   9 return [] unless $self->has_rdf_model;
28 4 50       110
29 4 50       136 my $model = $self->rdf_model;
30             [ map 'RDF::DOAP::Issue'->rdf_load($_, $model), $model->objects($self->rdf_about, $dcs->fixes) ];
31 4         94 }
32 4         95  
33             override changelog_links => sub
34             {
35             my $self = shift;
36             my @pages = map {
37             my $bug = $_;
38             grep defined, $bug->page, @{ $bug->see_also || [] };
39             } @{ $self->fixes };
40             return (@pages, super());
41             };
42              
43             my %ABBREV = (
44             GITHUB => 'GH',
45             RT => 'RT',
46             );
47             override changelog_lines => sub
48             {
49             my $self = shift;
50             my @lines = super();
51             my @added = map {
52             !defined($_->id) ? () :
53             ($_->rdf_about =~ /\b(RT|GITHUB)\b/i) ? "Fixes $ABBREV{uc($1)}#$_->{id}." :
54             "Fixes #$_->{id}."
55             } @{ $self->fixes };
56             splice(@lines, 1, 0, @added) if @added;
57             return @lines;
58             };
59              
60             1;