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