DOAP/Project.pm

filter: Statementstmt 84.4% 76 / 90 Branchbran 56.2% 9 / 16 Conditioncond 27.7% 10 / 36 MC/DCmcdc 12.5% 2 / 16 Subroutinesub 73.3% 11 / 15 Podpod 0.0% 0 / 6 totaltotal 60.3% 108 / 179 CC 25 SCAR 26.4
CC
25
Cov
67%
sorted_releases
35.6
__ANON__
18.7
changelog
9.0
CRAP 14.0
« DOAP/Resource.pm ↑ Summary DOAP/Change.pm »
1 package RDF::DOAP::Project;
2  
3 2 our $AUTHORITY = 'cpan:TOBYINK';
4 2 our $VERSION = '0.105';
5  
6 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 extends qw(RDF::DOAP::Resource);
8  
9 2 ▶use RDF::DOAP::Person;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use RDF::DOAP::Version;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use RDF::DOAP::Repository;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use RDF::DOAP::Types -types;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use RDF::DOAP::Utils -traits;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 2 ▶use RDF::Trine::Namespace qw(rdf rdfs owl xsd);
Subroutine BEGIN: called CC=1 SCAR=0.0
16 2 my $doap = 'RDF::Trine::Namespace'->new('http://usefulinc.com/ns/doap#');
17  
18 has $_ => (
19 traits => [ WithURI ],
20 is => 'ro',
21 isa => String,
22 coerce => 1,
23 12 uri => do { (my $x = $_) =~ s/_/-/g; $doap->$x },
24 2 ) for qw(name shortdesc created description programming_language os );
25  
26 2 has release => (
27 traits => [ WithURI ],
28 is => 'ro',
29 isa => ArrayRef[Version],
30 coerce => 1,
31 uri => $doap->release,
32 multi => 1,
33 );
34  
35 has $_ => (
36 traits => [ WithURI, Gathering ],
37 is => 'ro',
38 isa => ArrayRef[Person],
39 coerce => 1,
40 multi => 1,
41 uri => $doap->$_,
42 gather_as => ['maintainer'],
43 2 ) for qw( maintainer );
44  
45 has $_ => (
46 traits => [ WithURI, Gathering ],
47 is => 'ro',
48 isa => ArrayRef[Person],
49 coerce => 1,
50 multi => 1,
51 uri => $doap->$_,
52 gather_as => ['contributor'],
53 2 ) for qw( developer documenter );
54  
55 has $_ => (
56 traits => [ WithURI, Gathering ],
57 is => 'ro',
58 isa => ArrayRef[Person],
59 coerce => 1,
60 multi => 1,
61 uri => $doap->$_,
62 gather_as => ['thanks'],
63 2 ) for qw( translator tester helper );
64  
65 has $_ => (
66 traits => [ WithURI ],
67 is => 'ro',
68 isa => Identifier,
69 coerce => 1,
70 8 uri => do { (my $x = $_) =~ s/_/-/g; $doap->$x },
71 2 ) for qw( wiki bug_database mailing_list download_page );
72  
73 has $_ => (
74 traits => [ WithURI ],
75 is => 'ro',
76 isa => ArrayRef[Identifier],
77 coerce => 1,
78 16 uri => do { (my $x = $_) =~ s/_/-/g; $doap->$x },
79 multi => 1,
80 2 ) for qw( homepage old_homepage license download_mirror screenshots category support_forum developer_forum );
81  
82 2 has repository => (
83 traits => [ WithURI ],
84 is => 'ro',
85 isa => ArrayRef[Repository],
86 coerce => 1,
87 multi => 1,
88 uri => $doap->repository,
89 );
90  
91 1 ▶around homepage => sub {
Subroutine __ANON__: called CC=6 SCAR=29.3
92 1 my ($orig, $self, @args) = (shift, shift, @_);
93 1 ▶ if (@args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) { } 0 1 1
94 0 return $self->$orig(@args);
95 }
96 else {
97 return [
98 # de-prioritize metacpan links
99 sort {
100 0 ▶ ("$a" =~ /metacpan/ && "$b" =~ /metacpan/) ? ("$a" cmp "$b") :
Branch: 3 branches
BranchTrueFalseTotal
"$a" =~ /metacpan/ && "$b" =~ /metacpan/ ? : 0 0 0
"$a" =~ /metacpan/ ? : 0 0 0
"$b" =~ /metacpan/ ? : 0 0 0
Condition0%0/3
"$a" =~ /metacpan/ and "$b" =~ /metacpan/
!ll&&!rl&&r
000
MC/DC0%0/2
"$a" =~ /metacpan/ and "$b" =~ /metacpan/
"$a" =~ /metacpan/ "$b" =~ /metacpan/
Truth table0%0/3
A and B
A= "$a" =~ /metacpan/B= "$b" =~ /metacpan/
ABresult
0X0
100
111
101 ("$a" =~ /metacpan/) ? 1 :
102 ("$b" =~ /metacpan/) ? -1 : ("$a" cmp "$b")
103 1 } @{ $self->$orig() }
104 ];
105 }
106 2 };
107  
108 sub rdf_load_all
109 0 ▶{
Subroutine rdf_load_all: not called CC=1 SCAR=6.9
Pod undocumented
110 0 my $class = shift;
111 0 my ($model) = @_;
112 0 map $class->rdf_load($_, $model), $model->subjects($rdf->type, $doap->Project);
113 }
114  
115 sub gather_all_maintainers
116 0 ▶{
Subroutine gather_all_maintainers: not called CC=1 SCAR=6.9
Pod undocumented
117 0 require RDF::DOAP::Utils;
118 0 my $self = shift;
119 0 RDF::DOAP::Utils::gather_objects($self, 'maintainer');
120 }
121  
122 sub gather_all_contributors
123 0 ▶{
Subroutine gather_all_contributors: not called CC=1 SCAR=6.9
Pod undocumented
124 0 require RDF::DOAP::Utils;
125 0 my $self = shift;
126 0 RDF::DOAP::Utils::gather_objects($self, 'contributor');
127 }
128  
129 sub gather_all_thanks
130 0 ▶{
Subroutine gather_all_thanks: not called CC=1 SCAR=6.9
Pod undocumented
131 0 require RDF::DOAP::Utils;
132 0 my $self = shift;
133 0 RDF::DOAP::Utils::gather_objects($self, 'thanks');
134 }
135  
136 sub sorted_releases
137 1 ▶{
Subroutine sorted_releases: called CC=9 SCAR=35.7
Pod undocumented
138 1 my $self = shift;
139 my @rels = sort {
140 12 ▶ ($a->revision and $b->revision and version->parse($a->revision) cmp version->parse($b->revision)) or
Condition16%4/24
$a->revision && $b->revision && 'version'->parse($a->revision) cmp 'version'->parse($b->revision) || $a->issued && $b->issued && $a->issued cmp $b->issued || $a->rdf_about && $b->rdf_about && $a->rdf_about->as_ntriples cmp $b->rdf_about->as_ntriples
l!l&&r!l&&!r
1200
$a->revision and $b->revision and "version"->parse($a->revision) cmp "version"->parse($b->revision) or $a->issued and $b->issued and $a->issued cmp $b->issued
l!l&&r!l&&!r
1200
$a->revision and $b->revision and "version"->parse($a->revision) cmp "version"->parse($b->revision)
!ll&&!rl&&r
0012
$a->revision and $b->revision
!ll&&!rl&&r
0012
$a->issued and $b->issued and $a->issued cmp $b->issued
!ll&&!rl&&r
000
$a->issued and $b->issued
!ll&&!rl&&r
000
$a->rdf_about and $b->rdf_about and $a->rdf_about->as_ntriples cmp $b->rdf_about->as_ntriples
!ll&&!rl&&r
000
$a->rdf_about and $b->rdf_about
!ll&&!rl&&r
000
MC/DC0%0/9
$a->revision && $b->revision && 'version'->parse($a->revision) cmp 'version'->parse($b->revision) || $a->issued && $b->issued && $a->issued cmp $b->issued || $a->rdf_about && $b->rdf_about && $a->rdf_about->as_ntriples cmp $b->rdf_about->as_ntriples
$a->revision $b->revision "version"->parse($a->revision) cmp "version"->parse($b->revision) $a->issued $b->issued $a->issued cmp $b->issued $a->rdf_about $b->rdf_about $a->rdf_about->as_ntriples cmp $b->rdf_about->as_ntriples
Truth table2%1/40
A and B and C or D and E and F || G and H and I
A= $a->revisionB= $b->revisionC= "version"->parse($a->revision) cmp "version"->parse($b->revision)D= $a->issuedE= $b->issuedF= $a->issued cmp $b->issuedG= $a->rdf_aboutH= $b->rdf_aboutI= $a->rdf_about->as_ntriples cmp $b->rdf_about->as_ntriples
ABCDEFGHIresult
111XXXXXX1
0XX111XXX1
10X111XXX1
110111XXX1
0XX0XX1111
0XX10X1111
0XX1101111
10X0XX1111
10X10X1111
10X1101111
1100XX1111
11010X1111
1101101111
0XX0XX0XX0
0XX0XX10X0
0XX0XX1100
0XX10X0XX0
0XX10X10X0
0XX10X1100
0XX1100XX0
0XX11010X0
0XX1101100
10X0XX0XX0
10X0XX10X0
10X0XX1100
10X10X0XX0
10X10X10X0
10X10X1100
10X1100XX0
10X11010X0
10X1101100
1100XX0XX0
1100XX10X0
1100XX1100
11010X0XX0
11010X10X0
11010X1100
1101100XX0
11011010X0
1101101100
141 ($a->issued and $b->issued and $a->issued cmp $b->issued) or
142 ($a->rdf_about and $b->rdf_about and $a->rdf_about->as_ntriples cmp $b->rdf_about->as_ntriples)
143 1 } @{$self->release};
144 1 return \@rels;
145 }
146  
147 sub changelog
148 1 ▶{
Subroutine changelog: called CC=9 SCAR=22.0
Pod undocumented
149 1 my $self = shift;
150
151 1 my @releases = @{ $self->sorted_releases };
152 1 my @filtered_releases;
153 1 ▶ while (@releases) {
Branch: 1 branch
BranchTrueFalseTotal
if (@releases) 7 1 8
154 7 my $next = shift @releases;
155 7 ▶ if (@releases) {
Branch: 1 branch
BranchTrueFalseTotal
if (@releases) { } 6 1 7
156 6 my $found_catchup = undef;
157 6 for my $i (reverse(0 .. $#releases)) {
158 26 ▶ for my $cs (@{ $releases[$i]->changesets || [] }) {
Condition50%1/2
$releases[$i]->changesets || []
l!l
260
MC/DC0%0/1
$releases[$i]->changesets || []
$releases[$i]->changesets
Truth table50%1/2
A
A= $releases[$i]->changesets
Aresult
11
00
159 26 ▶ if ($cs->has_versus and $cs->versus->revision eq $next->revision) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cs->has_versus and $cs->versus->revision eq $next->revision) 1 25 26
Condition100%3/3
$cs->has_versus and $cs->versus->revision eq $next->revision
!ll&&!rl&&r
2141
MC/DC100%2/2
$cs->has_versus and $cs->versus->revision eq $next->revision
$cs->has_versus $cs->versus->revision eq $next->revision
Truth table100%3/3
A and B
A= $cs->has_versusB= $cs->versus->revision eq $next->revision
ABresult
0X0
100
111
160 1 $found_catchup = $i;
161 }
162 }
163 }
164 6 ▶ if ($found_catchup) {
Branch: 1 branch
BranchTrueFalseTotal
if ($found_catchup) { } 1 5 6
165 1 my @intermediates = splice(@releases, 0, $found_catchup);
166 1 push @filtered_releases, $next->changelog_section;
167 1 push @filtered_releases, map $_->_changelog_section_header, @intermediates;
168 }
169 else {
170 5 push @filtered_releases, $next->changelog_section;
171 }
172 }
173 else {
174 1 push @filtered_releases, $next->changelog_section;
175 }
176 }
177
178 1 return join "\n",
179 $self->_changelog_header,
180 reverse @filtered_releases;
181 }
182  
183 sub _changelog_header
184 1 ▶{
Subroutine _changelog_header: called CC=4 SCAR=14.2
185 1 my $self = shift;
186 1 my @lines = (
187 $self->name,
188 ("=" x length($self->name)),
189 "",
190 );
191 push @lines, sprintf('%-14s%s', "$_->[0]:", $_->[1])
192 1 for grep defined($_->[1]), (
193 ["Created" => $self->created],
194 1 ▶ map(["Home page"=>$_], @{$self->homepage||[]}),
Condition50%1/2
$self->homepage || []
l!l
10
MC/DC0%0/1
$self->homepage || []
$self->homepage
Truth table50%1/2
A
A= $self->homepage
Aresult
11
00
195 ["Bug tracker" => $self->bug_database],
196 ["Wiki" => $self->wiki],
197 ["Mailing list" => $self->mailing_list],
198 1 ▶ map(["Maintainer"=>$_->to_string], @{$self->maintainer||[]}),
Condition50%1/2
$self->maintainer || []
l!l
10
MC/DC0%0/1
$self->maintainer || []
$self->maintainer
Truth table50%1/2
A
A= $self->maintainer
Aresult
11
00
199 );
200 1 return join("\n", @lines)."\n";
201 }
202  
203 2 1;
« DOAP/Resource.pm ↑ Summary DOAP/Change.pm »