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