blib/lib/Pinto/Schema/Result/Registration.pm

filter: Statementstmt 63.4% 59 / 93 Branchbran 15.0% 3 / 20 Conditioncond 21.0% 4 / 19 MC/DCmcdc 9.0% 1 / 11 Subroutinesub 51.3% 19 / 37 Podpod 11.1% 1 / 9 totaltotal 46.0% 87 / 189 CC 18 SCAR 20.9
CC
18
Cov
50%
string_compare
42.0
numeric_compare
20.0
pin
6.0
CRAP 8.1
« blib/lib/Pinto/Action/Diff.pm ↑ Summary blib/lib/Pinto/Remote/Action/Add.pm »
1 63 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package Pinto::Schema::Result::Registration;
4  
5 # Created by DBIx::Class::Schema::Loader
6 # DO NOT MODIFY THE FIRST PART OF THIS FILE
7  
8  
9 63 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 63 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 63 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 63 ▶use MooseX::NonMoose;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 63 ▶use MooseX::MarkAsMethods autoclean => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 63 extends 'DBIx::Class::Core';
16  
17  
18 63 __PACKAGE__->table("registration");
19  
20  
21 63 __PACKAGE__->add_columns(
22 "id", { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
23 "revision", { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
24 "package_name", { data_type => "text", is_nullable => 0 },
25 "package", { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
26 "distribution", { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
27 "is_pinned", { data_type => "boolean", is_nullable => 0 },
28 );
29  
30  
31 63 __PACKAGE__->set_primary_key("id");
32  
33  
34 63 __PACKAGE__->add_unique_constraint( "revision_package_name_unique", [ "revision", "package_name" ] );
35  
36  
37 63 __PACKAGE__->belongs_to(
38 "distribution",
39 "Pinto::Schema::Result::Distribution",
40 { id => "distribution" },
41 { is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" },
42 );
43  
44  
45 63 __PACKAGE__->belongs_to(
46 "package",
47 "Pinto::Schema::Result::Package",
48 { id => "package" },
49 { is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" },
50 );
51  
52  
53 63 __PACKAGE__->belongs_to(
54 "revision",
55 "Pinto::Schema::Result::Revision",
56 { id => "revision" },
57 { is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" },
58 );
59  
60  
61 63 with 'Pinto::Role::Schema::Result';
62  
63 # Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-03-04 12:39:54
64 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:AkBHZ7hQ0BdZdv0DoCJufA
65  
66 #------------------------------------------------------------------------------
67  
68 # ABSTRACT: Represents the relationship between a Package and a Stack
69  
70 #------------------------------------------------------------------------------
71  
72 63 our $VERSION = '0.14'; # VERSION
73  
74 #------------------------------------------------------------------------------
75  
76 63 ▶use String::Format;
Subroutine BEGIN: called CC=1 SCAR=0.0
77  
78 63 ▶use Pinto::Util qw(itis throw);
Subroutine BEGIN: called CC=1 SCAR=0.0
79  
80 63 ▶use overload (
Subroutine BEGIN: called CC=1 SCAR=0.0
81 63 '""' => 'to_string',
82 'cmp' => 'string_compare',
83 '<=>' => 'numeric_compare',
84 fallback => undef
85 63 );
86  
87 #-------------------------------------------------------------------------------
88  
89 84 ▶sub FOREIGNBUILDARGS {
Subroutine FOREIGNBUILDARGS: called CC=3 SCAR=11.0
Pod undocumented
90 84 my ( $class, $args ) = @_;
91  
92 # Should we default these here or in the database?
93  
94 84 ▶ $args ||= {};
Condition50%1/2
$args ||= {}
l!l
840
MC/DC0%0/1
$args ||= {}
$args
Truth table50%1/2
A
A= $args
Aresult
11
00
95 84 ▶ $args->{is_pinned} ||= 0;
Condition100%2/2
$args->{"is_pinned"} ||= 0
l!l
480
MC/DC100%1/1
$args->{"is_pinned"} ||= 0
$args->{"is_pinned"}
Truth table100%2/2
A
A= $args->{"is_pinned"}
Aresult
11
00
96  
97 84 return $args;
98 }
99  
100 #-------------------------------------------------------------------------------
101  
102 0 ▶sub update { throw 'PANIC: Update to registrations are not allowed' }
Subroutine update: not called CC=1 SCAR=6.9
Pod documented
103  
104 #-------------------------------------------------------------------------------
105  
106 0 ▶sub pin {
Subroutine pin: not called CC=2 SCAR=17.9
Pod undocumented
107 0 my ($self) = @_;
108  
109 0 ▶ throw "$self is already pinned" if $self->is_pinned;
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_pinned 0 0 0
110  
111 0 $self->delete;
112 0 my $copy = $self->copy( { is_pinned => 1 } );
113  
114 0 return $copy;
115 }
116  
117 #-------------------------------------------------------------------------------
118  
119 0 ▶sub unpin {
Subroutine unpin: not called CC=2 SCAR=17.9
Pod undocumented
120 0 my ($self) = @_;
121  
122 0 ▶ throw "$self is not pinned" if not $self->is_pinned;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_pinned 0 0 0
123  
124 0 $self->delete;
125 0 my $copy = $self->copy( { is_pinned => 0 } );
126  
127 0 return $copy;
128 }
129  
130 #-------------------------------------------------------------------------------
131  
132 0 ▶sub numeric_compare {
Subroutine numeric_compare: not called CC=4 SCAR=30.0
Pod undocumented
133 0 my ( $reg_a, $reg_b ) = @_;
134  
135 0 my $pkg = __PACKAGE__;
136 0 ▶ throw "Can only compare $pkg objects"
Branch: 1 branch
BranchTrueFalseTotal
unless itis($reg_a, $pkg) and itis($reg_b, $pkg) 0 0 0
Condition0%0/3
itis($reg_a, $pkg) and itis($reg_b, $pkg)
!ll&&!rl&&r
000
MC/DC0%0/2
itis($reg_a, $pkg) and itis($reg_b, $pkg)
itis($reg_a, $pkg) itis($reg_b, $pkg)
Truth table0%0/3
A and B
A= itis($reg_a, $pkg)B= itis($reg_b, $pkg)
ABresult
0X0
100
111
137 if not( itis( $reg_a, $pkg ) && itis( $reg_b, $pkg ) );
138  
139 0 ▶ return 0 if $reg_a->id == $reg_b->id;
Branch: 1 branch
BranchTrueFalseTotal
if $reg_a->id == $reg_b->id 0 0 0
140  
141 0 return $reg_a->package <=> $reg_b->package;
142 }
143  
144 #------------------------------------------------------------------------------
145  
146 0 ▶sub string_compare {
Subroutine string_compare: not called CC=6 SCAR=37.4
Pod undocumented
147 0 my ( $reg_a, $reg_b ) = @_;
148  
149 0 my $class = __PACKAGE__;
150 0 ▶ throw "Can only compare $class objects"
Branch: 1 branch
BranchTrueFalseTotal
unless itis($reg_a, $class) and itis($reg_b, $class) 0 0 0
Condition0%0/3
itis($reg_a, $class) and itis($reg_b, $class)
!ll&&!rl&&r
000
MC/DC0%0/2
itis($reg_a, $class) and itis($reg_b, $class)
itis($reg_a, $class) itis($reg_b, $class)
Truth table0%0/3
A and B
A= itis($reg_a, $class)B= itis($reg_b, $class)
ABresult
0X0
100
111
151 if not( itis( $reg_a, $class ) && itis( $reg_b, $class ) );
152  
153 0 ▶ return 0 if $reg_a->id == $reg_b->id;
Branch: 1 branch
BranchTrueFalseTotal
if $reg_a->id == $reg_b->id 0 0 0
154  
155 return
156 0 ▶ ( $reg_a->package->distribution->author cmp $reg_b->package->distribution->author )
Condition0%0/6
$reg_a->package->distribution->author cmp $reg_b->package->distribution->author || $reg_a->package->distribution->vname cmp $reg_b->package->distribution->vname || $reg_a->package->vname cmp $reg_b->package->vname
l!l&&r!l&&!r
000
$reg_a->package->distribution->author cmp $reg_b->package->distribution->author or $reg_a->package->distribution->vname cmp $reg_b->package->distribution->vname
l!l&&r!l&&!r
000
MC/DC0%0/3
$reg_a->package->distribution->author cmp $reg_b->package->distribution->author || $reg_a->package->distribution->vname cmp $reg_b->package->distribution->vname || $reg_a->package->vname cmp $reg_b->package->vname
$reg_a->package->distribution->author cmp $reg_b->package->distribution->author $reg_a->package->distribution->vname cmp $reg_b->package->distribution->vname $reg_a->package->vname cmp $reg_b->package->vname
Truth table0%0/4
A or B || C
A= $reg_a->package->distribution->author cmp $reg_b->package->distribution->authorB= $reg_a->package->distribution->vname cmp $reg_b->package->distribution->vnameC= $reg_a->package->vname cmp $reg_b->package->vname
ABCresult
1XX1
01X1
0011
0000
157 || ( $reg_a->package->distribution->vname cmp $reg_b->package->distribution->vname )
158 || ( $reg_a->package->vname cmp $reg_b->package->vname );
159 }
160  
161 #------------------------------------------------------------------------------
162  
163 2 ▶sub flags {
Subroutine flags: called CC=1 SCAR=0.0
Pod undocumented
164 2 my ($self) = @_;
165  
166 2 my $format = '%m%s%y';
167 2 return $self->to_string($format);
168 }
169  
170 #------------------------------------------------------------------------------
171  
172 4 ▶sub to_string {
Subroutine to_string: called CC=2 SCAR=9.5
Pod undocumented
173 4 my ( $self, $format ) = @_;
174  
175 # my ($pkg, $file, $line) = caller;
176 # warn __PACKAGE__ . " stringified from $file at line $line";
177  
178 my %fspec = (
179 0 ▶ p => sub { $self->package->name },
Subroutine __ANON__: not called CC=1 SCAR=6.9
180 0 ▶ P => sub { $self->package->vname },
Subroutine __ANON__: not called CC=1 SCAR=6.9
181 0 ▶ v => sub { $self->package->version },
Subroutine __ANON__: not called CC=1 SCAR=6.9
182 0 ▶ M => sub { $self->package->is_main_module ? 'm' : '-'},
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$self->package->is_main_module ? : 0 0 0
183 2 ▶ y => sub { $self->is_pinned ? '!' : '-' },
Subroutine __ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
$self->is_pinned ? : 0 2 2
184 2 ▶ m => sub { $self->distribution->is_devel ? 'd' : 'r' },
Subroutine __ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
$self->distribution->is_devel ? : 0 2 2
185 0 ▶ h => sub { $self->distribution->path },
Subroutine __ANON__: not called CC=1 SCAR=6.9
186 0 ▶ H => sub { $self->distribution->native_path },
Subroutine __ANON__: not called CC=1 SCAR=6.9
187 2 ▶ f => sub { $self->distribution->archive },
Subroutine __ANON__: called CC=1 SCAR=0.0
188 2 ▶ s => sub { $self->distribution->is_local ? 'l' : 'f' },
Subroutine __ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
$self->distribution->is_local ? : 2 0 2
189 0 ▶ S => sub { $self->distribution->source },
Subroutine __ANON__: not called CC=1 SCAR=6.9
190 2 ▶ a => sub { $self->distribution->author },
Subroutine __ANON__: called CC=1 SCAR=0.0
191 0 ▶ d => sub { $self->distribution->name },
Subroutine __ANON__: not called CC=1 SCAR=6.9
192 0 ▶ D => sub { $self->distribution->vname },
Subroutine __ANON__: not called CC=1 SCAR=6.9
193 0 ▶ V => sub { $self->distribution->version },
Subroutine __ANON__: not called CC=1 SCAR=6.9
194 0 ▶ u => sub { $self->distribution->uri },
Subroutine __ANON__: not called CC=1 SCAR=6.9
195 0 ▶ i => sub { $self->revision->uuid_prefix },
Subroutine __ANON__: not called CC=1 SCAR=6.9
196 2 ▶ F => sub { $self->flags },
Subroutine __ANON__: called CC=1 SCAR=0.0
197 4 );
198  
199 # Some attributes are just undefined, usually because of
200 # oddly named distributions and other old stuff on CPAN.
201 63 ▶ no warnings 'uninitialized'; ## no critic qw(NoWarnings);
Subroutine BEGIN: called CC=1 SCAR=0.0
202  
203 4 ▶ $format ||= $self->default_format();
Condition33%1/3
$format ||= $self->default_format
l!l&&r!l&&!r
400
MC/DC0%0/2
$format ||= $self->default_format
$format $self->default_format
Truth table33%1/3
A ||= B
A= $formatB= $self->default_format
ABresult
1X1
011
000
204 4 return String::Format::stringf( $format, %fspec );
205 }
206  
207 #-------------------------------------------------------------------------------
208  
209 0 ▶sub default_format {
Subroutine default_format: not called CC=1 SCAR=6.9
Pod undocumented
210  
211 0 return '%a/%D/%P/%y'; # AUTHOR/DIST_VNAME/PKG_VNAME/PIN_STATUS
212 }
213  
214 #------------------------------------------------------------------------------
215  
216 63 __PACKAGE__->meta->make_immutable;
217  
218 #------------------------------------------------------------------------------
219 63 1;
220  
221 __END__
« blib/lib/Pinto/Action/Diff.pm ↑ Summary blib/lib/Pinto/Remote/Action/Add.pm »