OpenInteract2/Brick/PackageCPAN.pm

filter: Statementstmt 57.1% 12 / 21 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 44.4% 4 / 9 Podpod 0.0% 0 / 6 totaltotal 42.1% 16 / 38 CC 2 SCAR 8.8
CC
2
Cov
52%
load
6.0
get_resources
2.0
MAKEFILEPL
2.0
CRAP 2.4
« OpenInteract2/Brick/WhatsNew.pm ↑ Summary OpenInteract2/Setup/RequireSessionClasses.pm »
1 package OpenInteract2::Brick::PackageCPAN;
2  
3 87 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 87 ▶use base qw( OpenInteract2::Brick );
Subroutine BEGIN: called CC=1 SCAR=0.0
5 87 ▶use OpenInteract2::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 87 my %INLINED_SUBS = (
8 'Makefile.PL' => 'MAKEFILEPL',
9 'Brick.pm' => 'BRICKPM',
10 'module_include.t' => 'MODULE_INCLUDET',
11 );
12  
13 87 ▶sub get_name {
Subroutine get_name: called CC=1 SCAR=0.0
Pod undocumented
14 87 return 'package_cpan';
15 }
16  
17 0 ▶sub get_resources {
Subroutine get_resources: not called CC=1 SCAR=6.9
Pod undocumented
18 return (
19 0 'Makefile.PL' => [ 'Makefile.PL', 'yes' ],
20 'Brick.pm' => [ 'lib OpenInteract2 Brick [% subclass %].pm', 'yes' ],
21 'module_include.t' => [ 't 00_basic_include.t ', 'yes' ],
22 );
23 }
24  
25 0 ▶sub load {
Subroutine load: not called CC=2 SCAR=17.9
Pod undocumented
26 0 my ( $self, $resource_name ) = @_;
27 0 my $inline_sub_name = $INLINED_SUBS{ $resource_name };
28 0 ▶ unless ( $inline_sub_name ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($inline_sub_name) 0 0 0
29 0 OpenInteract2::Exception->throw(
30 "Resource name '$resource_name' not found ",
31 "in ", ref( $self ), "; cannot load content." );
32 }
33 0 return $self->$inline_sub_name();
34 }
35  
36 87 OpenInteract2::Brick->register_factory_type( get_name() => __PACKAGE__ );
37  
38 =pod
39  
40 =head1 NAME
41  
42 OpenInteract2::Brick::PackageCPAN - All resources used for creating a CPAN distribution from a package
43  
44 =head1 SYNOPSIS
45  
46 oi2_manage create_cpan --package_dir=/path/to/mypackage
47  
48 =head1 DESCRIPTION
49  
50 This class just holds all the static resources used when creating a CPAN distribution from a package.
51  
52 These resources are associated with OpenInteract2 version 1.99_06.
53  
54 =head2 Resources
55  
56 You can grab resources individually using the names below and
57 C<load_resource()> and C<copy_resources_to()>, or you can copy all the
58 resources at once using C<copy_all_resources_to()> -- see
59 L<OpenInteract2::Brick> for details.
60  
61 =over 4
62  
63  
64 =item B<Makefile.PL>
65  
66 =item B<Brick.pm>
67  
68 =item B<module_include.t>
69  
70  
71 =back
72  
73 =head1 COPYRIGHT
74  
75 Copyright (c) 2005 Chris Winters. All rights reserved.
76  
77 This library is free software; you can redistribute it and/or modify
78 it under the same terms as Perl itself.
79  
80 =head1 AUTHORS
81  
82  
83 Chris Winters E<lt>chris@cwinters.comE<gt>
84  
85  
86 =cut
87  
88  
89 0 ▶sub MAKEFILEPL {
Subroutine MAKEFILEPL: not called CC=1 SCAR=6.9
Pod undocumented
90 0 return <<'SOMELONGSTRING';
91 use ExtUtils::MakeMaker;
92  
93 my %opts = (
94 'NAME' => '[% full_app_class %]',
95 'VERSION' => '[% package_version %]',
96 'PL_FILES' => {},
97 'NO_META' => 1,
98 'PREREQ_PM' => {
99 'OpenInteract2::Action' => 1.66, # proxy for OI2
100 [% FOREACH module = required_modules -%]
101 [% module %] => 0,
102 [% END -%]
103 },
104 );
105  
106 if ( $ExtUtils::MakeMaker::VERSION >= 5.43 ) {
107 $opts{AUTHOR} = '[% author_names.join( ', ' ) %]',
108 $opts{ABSTRACT} = q{[% abstract %]},
109 }
110  
111 WriteMakefile( %opts );
112  
113 SOMELONGSTRING
114 }
115  
116 0 ▶sub BRICKPM {
Subroutine BRICKPM: not called CC=1 SCAR=6.9
Pod undocumented
117 0 return <<'SOMELONGSTRING';
118 package [% full_brick_class %];
119  
120 use strict;
121 use base qw( OpenInteract2::Brick );
122 use OpenInteract2::Exception;
123  
124 my %INLINED_SUBS = (
125 [% FOREACH file_info = package_files -%]
126 '[% file_info.name %]' => '[% file_info.inline_name %]',
127 [% END -%]
128 );
129  
130 sub get_name {
131 return '[% package_name %]';
132 }
133  
134 sub get_resources {
135 return (
136 [% FOREACH file_info = package_files -%]
137 '[% file_info.name %]' => [ '[% file_info.destination %]', '[% file_info.evaluate %]' ],
138 [% END -%]
139 );
140 }
141  
142 sub load {
143 my ( $self, $resource_name ) = @_;
144 my $inline_sub_name = $INLINED_SUBS{ $resource_name };
145 unless ( $inline_sub_name ) {
146 OpenInteract2::Exception->throw(
147 "Resource name '$resource_name' not found ",
148 "in ", ref( $self ), "; cannot load content." );
149 }
150 return $self->$inline_sub_name();
151 }
152  
153 OpenInteract2::Brick->register_factory_type( get_name() => __PACKAGE__ );
154  
155 =pod
156  
157 =head1 NAME
158  
159 [% full_brick_class %] - Installation data for OpenInteract2 package '[% package_name %]'
160  
161 =head1 SYNOPSIS
162  
163 oi2_manage install_package --package=[% package_name %]
164  
165 =head1 DESCRIPTION
166  
167 You generally don't use this class directly. See the docs for
168 L<[% full_app_class %]> and L<OpenInteract2::Brick> for more.
169  
170 =head1 SEE ALSO
171  
172 L<[% full_app_class %]>
173  
174 =head1 COPYRIGHT
175  
176 Copyright (c) 2005 [% author_names.join( ', ' ) %]. All rights reserved.
177  
178 This library is free software; you can redistribute it and/or modify
179 it under the same terms as Perl itself.
180  
181 =head1 AUTHORS
182  
183 [% FOREACH author_info = authors %]
184 [% author_info.name %] E<lt>[% author_info.email %]E<gt>
185 [% END %]
186  
187 =cut
188  
189 [% FOREACH file_info = package_files %]
190 sub [% file_info.inline_name %] {
191 return <<'SUPERLONGSTRING';
192 [% file_info.contents %]
193 SUPERLONGSTRING
194 }
195  
196 [% END %]
197  
198  
199 SOMELONGSTRING
200 }
201  
202 0 ▶sub MODULE_INCLUDET {
Subroutine MODULE_INCLUDET: not called CC=1 SCAR=6.9
Pod undocumented
203 0 return <<'SOMELONGSTRING';
204 # -*-perl-*-
205  
206 use strict;
207 use Test::More tests => [% package_modules.size + 2 %];
208  
209 require_ok( '[% full_app_class %]' );
210 require_ok( '[% full_brick_class %]' );
211 [% FOREACH module = package_modules.sort -%]
212 require_ok( '[% module %]' );
213 [% END -%]
214  
215  
216 SOMELONGSTRING
217 }
218  
« OpenInteract2/Brick/WhatsNew.pm ↑ Summary OpenInteract2/Setup/RequireSessionClasses.pm »