File Coverage

blib/lib/RDF/DOAP/Change.pm
Criterion Covered Total %
statement 40 46 86.9
branch 11 14 78.5
condition 3 6 50.0
subroutine 10 11 90.9
pod 0 4 0.0
total 64 81 79.0


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         4  
  2         13  
7              
8             use RDF::DOAP::Person;
9 2     2   10499 use RDF::DOAP::Types -types;
  2         4  
  2         71  
10 2     2   33 use RDF::DOAP::Utils -traits;
  2         4  
  2         15  
11 2     2   10297 use List::Util qw(uniq);
  2         4  
  2         11  
12 2     2   640 use Text::Wrap qw(wrap);
  2         4  
  2         133  
13 2     2   815  
  2         4525  
  2         108  
14             use RDF::Trine::Namespace qw(rdf rdfs owl xsd);
15 2     2   12 my $doap = 'RDF::Trine::Namespace'->new('http://usefulinc.com/ns/doap#');
  2         3  
  2         15  
16             my $dc = 'RDF::Trine::Namespace'->new('http://purl.org/dc/terms/');
17             my $dcs = 'RDF::Trine::Namespace'->new('http://ontologi.es/doap-changeset#');
18              
19             has blame => (
20             traits => [ WithURI, Gathering ],
21             is => 'ro',
22             isa => ArrayRef[Person],
23             coerce => 1,
24             uri => $dcs->blame,
25             multi => 1,
26             gather_as => ['contributor'],
27             );
28              
29             has thanks => (
30             traits => [ WithURI, Gathering ],
31             is => 'ro',
32             isa => ArrayRef[Person],
33             coerce => 1,
34             uri => $dcs->thanks,
35             multi => 1,
36             gather_as => ['thanks'],
37             );
38              
39             our %ROLES = (
40             $dcs->Addition => 'RDF::DOAP::Change::Addition',
41             $dcs->Removal => 'RDF::DOAP::Change::Removal',
42             $dcs->Bugfix => 'RDF::DOAP::Change::Bugfix',
43             $dcs->Update => 'RDF::DOAP::Change::Update',
44             $dcs->Regression => 'RDF::DOAP::Change::Regression',
45             $dcs->Documentation => 'RDF::DOAP::Change::Documentation',
46             $dcs->Packaging => 'RDF::DOAP::Change::Packaging',
47             $dcs->SecurityFix => 'RDF::DOAP::Change::SecurityFix',
48             $dcs->SecurityRegression => 'RDF::DOAP::Change::SecurityRegression',
49             );
50              
51             {
52             my $self = shift;
53            
54 9     9 0 16297 my @roles = grep defined, map $ROLES{$_}, @{ $self->rdf_type || [] };
55             push @roles, $ROLES{$dcs->Bugfix}
56 9 50       18 if $self->has_rdf_about
  9         244  
57 9 100 33     358 && $self->has_rdf_model
      66        
58             && $self->rdf_model->count_statements($self->rdf_about, $dcs->fixes, undef);
59            
60             $self->Moose::Util::apply_all_roles(uniq @roles) if @roles;
61             }
62 9 100       29417  
63             {
64             my $self = shift;
65             my $text = join "\n", $self->changelog_lines;
66             wrap(" - ", " ", $text);
67 0     0 0 0 }
68 0         0  
69 0         0 {
70             my $self = shift;
71             my ($notype) = @_;
72            
73             my @lines;
74 8     8 0 25 if ($notype)
75 8         11 {
76             @lines = $self->label;
77 8         12 }
78 8 50       16 else
79             {
80 8         197 my @type = sort map $_->uri =~ m{(\w+)$}, @{ $self->rdf_type };
81             @lines = "(@type) " . $self->label;
82             }
83            
84 0         0 for my $person (uniq sort @{$self->blame||[]}, @{$self->thanks||[]})
  0         0  
85 0         0 {
86             push @lines, sprintf("%s++", $person->to_string('compact'));
87             }
88 8 100       12
  8 100       161  
  8         175  
89             push @lines, $self->changelog_links;
90 2         7
91             return @lines;
92             }
93 8         44  
94             {
95 8         27 my $self = shift;
96             return @{ $self->see_also || [] };
97             }
98              
99             1;