blib/lib/Git/PurePerl/Walker/Role/HasRepo.pm

filter: Statementstmt 100% 28 / 28 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 100% 37 / 37 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« lib/Git/PurePerl/Walker/Method/FirstParent/FromHEAD.pm ↑ Summary blib/lib/Git/PurePerl/Walker/Role/Method.pm »
1 12 ▶use 5.008; #utf8
Subroutine BEGIN: called CC=1 SCAR=0.0
2 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 12 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 package Git::PurePerl::Walker::Role::HasRepo;
7  
8 12 our $VERSION = '0.004000';
9  
10 # ABSTRACT: An entity that has a repo
11  
12 12 our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
13  
14 12 ▶use Moose::Role qw( with has );
Subroutine BEGIN: called CC=1 SCAR=0.0
15 12 ▶use Git::PurePerl::Walker::Types qw( GPPW_Repository );
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29 12 with qw( MooseX::Clone );
30  
31  
32  
33  
34  
35  
36  
37  
38  
39 12 has '_repo' => ( isa => GPPW_Repository, is => 'rw', weak_ref => 1 );
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66 sub for_repository {
67 9 ▶ my ( $self, $repo ) = @_;
Subroutine for_repository: called CC=1 SCAR=0.0
Pod documented
68 9 my $clone = $self->clone( _repo => $repo, );
69 9 return $clone;
70 }
71  
72 12 ▶no Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
73 12 1;
74  
75 __END__
76  
77 =pod
78  
79 =encoding UTF-8
80  
81 =head1 NAME
82  
83 Git::PurePerl::Walker::Role::HasRepo - An entity that has a repo
84  
85 =head1 VERSION
86  
87 version 0.004000
88  
89 =head1 DESCRIPTION
90  
91 This is a composition role consumed by other roles to provide them with a
92 private repo property.
93  
94 This role also folds in L<< C<MooseX::B<Clone>>|MooseX::Clone >> and provides the 'for_repository'
95 method which sets the repo property.
96  
97 package Foo {
98 use Moose;
99 with 'Git::PurePerl::Walker::Role::HasRepo';
100 __PACKAGE__->meta->make_immutable;
101 }
102  
103 my $factory = Foo->new( %args );
104  
105 my $instance = $factory->for_repository( $Git_PurePerl_Repo );
106  
107 =head1 METHODS
108  
109 =head2 for_repository
110  
111 Construct an entity for a given repository.
112  
113 This internally calls L<< C<MooseX::B<Clone>>|MooseX::Clone >> on the current object, passing the _repo
114 field to its constructor, producing a separate, disconnected object to work
115 with.
116  
117 The rationale behind this is simple: Its very likely users will want one set of
118 settings for a consuming class, but they'll want to use those same settings with
119 multiple repositories.
120  
121 And as each repository will need to maintain its own state for traversal, they
122 have to normally manually construct an object for each repository, manually
123 disconnecting the constructor arguments.
124  
125 This instead is simple:
126  
127 my $thing = Thing->new( %args );
128 my ( @foos ) = map { $thing->for_repository( $_ ) } @repos;
129  
130 And now all C<@foos> can be mangled independently.
131  
132 =head1 INHERITED METHODS
133  
134 =head2 clone
135  
136 L<< C<MooseX::B<Clone>-E<gt>I<clone( %params )>>|MooseX::Clone/clone-params >>
137  
138 =head1 PRIVATE ATTRIBUTES
139  
140 =head2 _repo
141  
142 =head1 PRIVATE ATTRIBUTE GENERATED METHODS
143  
144 =head2 _repo
145  
146 =head1 CONSUMED ROLES
147  
148 =head2 MooseX::Clone
149  
150 L<< C<MooseX::B<Clone>>|MooseX::Clone >>
151  
152 =head1 AUTHOR
153  
154 Kent Fredric <kentnl@cpan.org>
155  
156 =head1 COPYRIGHT AND LICENSE
157  
158 This software is copyright (c) 2014 by Kent Fredric <kentnl@cpan.org>.
159  
160 This is free software; you can redistribute it and/or modify it under
161 the same terms as the Perl 5 programming language system itself.
162  
163 =cut
« lib/Git/PurePerl/Walker/Method/FirstParent/FromHEAD.pm ↑ Summary blib/lib/Git/PurePerl/Walker/Role/Method.pm »