File Coverage

lib/DBIx/Schema/Changelog/Command/Driver.pm
Criterion Covered Total %
statement 45 45 100.0
branch 3 6 50.0
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 55 58 94.8


line stmt bran cond sub pod time code
1             package DBIx::Schema::Changelog::Command::Driver;
2              
3             =head1 NAME
4              
5             DBIx::Schema::Changelog::Command::Driver - Create a new driver module from template for DBIx::Schema::Changelog!
6              
7             =head1 VERSION
8              
9             Version 0.8.0
10              
11             =cut
12              
13             our $VERSION = '0.8.0';
14              
15 1     1   3394 use strict;
  1         2  
  1         37  
16 1     1   4 use warnings FATAL => 'all';
  1         2  
  1         38  
17 1     1   488 use Moose;
  1         389307  
  1         10  
18 1     1   6006 use File::Path qw( mkpath );
  1         2  
  1         538  
19              
20             with 'DBIx::Schema::Changelog::Command::Base';
21             ############# End of encapsulated class data. ########################
22              
23             has file => (
24             isa => 'Str',
25             is => 'ro',
26             default => q~package DBIx::Schema::Changelog::Driver::{0};
27              
28             =head1 NAME
29              
30             DBIx::Schema::Changelog::Driver::{0} - A new DBIx::Schema::Changelog::Driver module!
31              
32             =head1 VERSION
33              
34             Version 0.1.0
35              
36             =cut
37              
38             our $VERSION = '0.1.0';
39              
40             use {4};
41             use strict;
42             use warnings FATAL => 'all';
43             use Moose;
44              
45             with 'DBIx::Schema::Changelog::Driver';
46              
47             has commands => (
48             is => 'ro',
49             isa => 'HashRef[Str]',
50             default => sub {
51             return {};
52             }
53             );
54              
55             has defaults => (
56             is => 'ro',
57             isa => 'HashRef[Str]',
58             default => sub {
59             return {};
60             }
61             );
62              
63             has types => (
64             is => 'ro',
65             isa => 'HashRef[Str]',
66             default => sub {
67             return {};
68             }
69             );
70              
71             sub _min_version { '0' }
72              
73             =head1 SUBROUTINES/METHODS
74              
75             =head2 generate_unique
76              
77             =cut
78              
79             sub generate_unique {}
80              
81             =head2 generate_foreign_key
82              
83             =cut
84              
85             sub generate_foreign_key {}
86              
87             =head2 add_column
88              
89             =cut
90              
91             sub add_column {}
92              
93             no Moose;
94             __PACKAGE__->meta->make_immutable;
95              
96             1; # End of DBIx::Schema::Changelog::File::{0}
97              
98             __END__
99              
100             =head1 BUGS
101              
102             Please report any bugs or feature requests to C<bug-dbix-schema-changelog-driver-{0} at rt.cpan.org>, or through
103             the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=DBIx-Schema-Changelog-Driver-{0}>. I will be notified, and then you'll
104             automatically be notified of progress on your bug as I make changes.
105              
106              
107             =head1 SUPPORT
108              
109             You can find documentation for this module with the perldoc command.
110              
111             perldoc DBIx::Schema::Changelog::Driver::{0}
112              
113              
114             You can also look for information at:
115              
116             =over 4
117              
118             =item * RT: CPAN's request tracker (report bugs here)
119              
120             L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=DBIx-Schema-Changelog-Driver-{0}>
121              
122             =item * AnnoCPAN: Annotated CPAN documentation
123              
124             L<http://annocpan.org/dist/DBIx-Schema-Changelog-Driver-{0}>
125              
126             =item * CPAN Ratings
127              
128             L<http://cpanratings.perl.org/d/DBIx-Schema-Changelog-Driver-{0}>
129              
130             =item * Search CPAN
131              
132             L<http://search.cpan.org/dist/DBIx-Schema-Changelog-Driver-{0}/>
133              
134             =back
135              
136             =head1 ACKNOWLEDGEMENTS
137              
138             =head1 AUTHOR
139              
140             {1}, C<< <{2}> >>
141              
142             ~,
143             );
144              
145             =head1 SUBROUTINES/METHODS
146              
147             =head2 make
148              
149             =cut
150              
151             sub make {
152 1     1 1 2 my ( $self, $config ) = @_;
153 1 50       4 die "No author defined!" unless $config->{author};
154 1 50       13 die "No mail address defined!" unless $config->{email};
155 1 50       4 die "No new driver defined!" unless $config->{driver};
156 1         5 my $dir = "$config->{dir}/DBIx-Schema-Changelog-Driver-$config->{driver}";
157 1         1607 mkpath( "$dir/lib/DBIx/Schema/Changelog/Driver", 0755 );
158 1         233 mkpath( "$dir/t", 0755 );
159              
160             #module
161 1         19 my $path = File::Spec->catfile( $dir, 'lib', 'DBIx', 'Schema', 'Changelog',
162             'Driver', "$config->{driver}.pm" );
163 1         52 _write_file(
164             $path,
165             _replace_spare(
166             $self->file(),
167             [
168             $config->{driver}, $config->{author},
169             $config->{email}, $self->year(),
170             '5.10.0'
171             ]
172             )
173             );
174 1         46 _write_file( $path,
175             _replace_spare( $self->license(), [ $self->year(), $config->{author} ] )
176             );
177 1         6 _write_file( $path, qq~\n=cut\n~ );
178              
179             #AUXILIARY
180 1         20 $path = File::Spec->catfile( $dir, 'README.md' );
181 1         62 _write_file(
182             $path,
183             _replace_spare(
184             $self->readme(),
185             [
186             'Driver', $config->{driver}, $config->{author}, $config->{email}
187             ]
188             )
189             );
190 1         47 _write_file( $path,
191             _replace_spare( $self->license(), [ $self->year(), $config->{author} ] )
192             );
193 1         15 $path = File::Spec->catfile( $dir, 'Makefile.PL' );
194 1         44 _write_file(
195             $path,
196             _replace_spare(
197             $self->makefile(),
198             [
199             'Driver', $config->{driver}, $config->{author},
200             $config->{email}, $VERSION
201             ]
202             )
203             );
204 1         15 $path = File::Spec->catfile( $dir, 'Changes' );
205 1         74 _write_file(
206             $path,
207             _replace_spare(
208             $self->changes(),
209             [
210             'Driver', $config->{driver},
211             '0.0.0_001', '1970/01/01',
212             $config->{author}
213             ]
214             )
215             );
216 1         13 $path = File::Spec->catfile( $dir, 'MANIFEST' );
217 1         43 _write_file( $path,
218             _replace_spare( $self->manifest(), [ 'Driver', $config->{driver} ] ) );
219              
220             #tests
221 1         13 $path = File::Spec->catfile( $dir, 't', '00-load.t' );
222 1         80 _write_file( $path,
223             _replace_spare( $self->t_load(), [ 'Driver', $config->{driver} ] ) );
224 1         14 $path = File::Spec->catfile( $dir, 't', 'boilerplate.t' );
225 1         43 _write_file(
226             $path,
227             _replace_spare(
228             $self->t_boilerplate(), [ 'Driver', $config->{driver} ]
229             )
230             );
231 1         14 $path = File::Spec->catfile( $dir, 't', 'manifest.t' );
232 1         42 _write_file( $path, _replace_spare( $self->t_manifest(), [] ) );
233 1         14 $path = File::Spec->catfile( $dir, 't', 'pod-coverage.t' );
234 1         43 _write_file( $path, _replace_spare( $self->t_pod_coverage(), [] ) );
235 1         14 $path = File::Spec->catfile( $dir, 't', 'pod.t' );
236 1         45 _write_file( $path, _replace_spare( $self->t_pod(), [] ) );
237             }
238              
239 1     1   6 no Moose;
  1         2  
  1         5  
240             __PACKAGE__->meta->make_immutable;
241              
242             1;
243              
244             __END__
245              
246             =head1 AUTHOR
247              
248             Mario Zieschang, C<< <mario.zieschang at combase.de> >>
249              
250             =head1 LICENSE AND COPYRIGHT
251              
252             Copyright 2015 Mario Zieschang.
253              
254             This program is free software; you can redistribute it and/or modify it
255             under the terms of the the Artistic License (2.0). You may obtain a
256             copy of the full license at:
257              
258             L<http://www.perlfoundation.org/artistic_license_2_0>
259              
260             Any use, modification, and distribution of the Standard or Modified
261             Versions is governed by this Artistic License. By using, modifying or
262             distributing the Package, you accept this license. Do not use, modify,
263             or distribute the Package, if you do not accept this license.
264              
265             If your Modified Version has been derived from a Modified Version made
266             by someone other than you, you are nevertheless required to ensure that
267             your Modified Version complies with the requirements of this license.
268              
269             This license does not grant you the right to use any trademark, service
270             mark, trade name, or logo of the Copyright Holder.
271              
272             This license includes the non-exclusive, worldwide, free-of-charge
273             patent license to make, have made, use, offer to sell, sell, import and
274             otherwise transfer the Package with respect to any patent claims
275             licensable by the Copyright Holder that are necessarily infringed by the
276             Package. If you institute patent litigation (including a cross-claim or
277             counterclaim) against any party alleging that the Package constitutes
278             direct or contributory patent infringement, then this Artistic License
279             to you shall terminate on the date that such litigation is filed.
280              
281             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
282             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
283             THE IMPLIED WARRANTIES OF MERCHANT ABILITY, FITNESS FOR A PARTICULAR
284             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
285             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
286             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
287             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
288             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
289              
290             =cut