File Coverage

lib/DBIx/Schema/Changelog/Command/Changeset.pm
Criterion Covered Total %
statement 31 31 100.0
branch n/a
condition n/a
subroutine 10 10 100.0
pod 1 1 100.0
total 42 42 100.0


line stmt bran cond sub pod time code
1             package DBIx::Schema::Changelog::Command::Changeset;
2              
3             =head1 NAME
4              
5             DBIx::Schema::Changelog::Command::Changeset - Create a new changeset project from template for DBIx::Schema::Changelog!
6              
7             =head1 VERSION
8              
9             Version 0.7.2
10              
11             =cut
12              
13             our $VERSION = '0.7.2';
14              
15 1     1   4234 use strict;
  1         1  
  1         30  
16 1     1   3 use warnings FATAL => 'all';
  1         2  
  1         32  
17 1     1   2 use Moose;
  1         2  
  1         6  
18 1     1   4859 use File::Path qw( mkpath );
  1         2  
  1         44  
19 1     1   3 use MooseX::Types::Moose qw(Str);
  1         1  
  1         14  
20 1     1   3139 use MooseX::HasDefaults::RO;
  1         2  
  1         7  
21 1     1   3161 use MooseX::Types::LoadableClass qw(LoadableClass);
  1         3  
  1         9  
22 1     1   792 use Method::Signatures::Simple;
  1         2  
  1         7  
23              
24             with 'DBIx::Schema::Changelog::Command::Base';
25              
26             has dir => (
27             isa => Str,
28             required => 1,
29             );
30              
31             has file_type => (
32             isa => Str,
33             default => 'Yaml'
34             );
35              
36             has loader_class => (
37             isa => LoadableClass,
38             lazy => 1,
39             default => method {
40             'DBIx::Schema::Changelog::File::' . $self->file_type()
41             }
42             );
43              
44             has loader => (
45             is => 'ro',
46             does => 'DBIx::Schema::Changelog::File',
47             lazy => 1,
48             default => method { $self->loader_class()->new(); }
49             );
50              
51 1     1 1 2 =head1 SUBROUTINES/METHODS
52 1         28  
53 1         45 =head2 make
54              
55             =cut
56              
57             sub make {
58 1         42 my ($self) = @_;
59             mkpath( File::Spec->catfile( $self->dir(), 'changelog' ), 0755 );
60             _write_file(
61             File::Spec->catfile( $self->dir(), 'changelog', 'changelog' )
62             . $self->loader()->ending(),
63             _replace_spare( $self->loader()->tpl_main(), [] )
64             );
65 1     1   921 _write_file(
  1         1  
  1         4  
66             File::Spec->catfile( $self->dir(), 'changelog', 'changelog-01' )
67             . $self->loader()->ending(),
68             _replace_spare( $self->loader()->tpl_sub(), [] )
69             );
70             }
71              
72             no Moose;
73             __PACKAGE__->meta->make_immutable;
74              
75             1;
76              
77             __END__
78              
79             =head1 AUTHOR
80              
81             Mario Zieschang, C<< <mario.zieschang at combase.de> >>
82              
83             =head1 LICENSE AND COPYRIGHT
84              
85             Copyright 2015 Mario Zieschang.
86              
87             This program is free software; you can redistribute it and/or modify it
88             under the terms of the the Artistic License (2.0). You may obtain a
89             copy of the full license at:
90              
91             L<http://www.perlfoundation.org/artistic_license_2_0>
92              
93             Any use, modification, and distribution of the Standard or Modified
94             Versions is governed by this Artistic License. By using, modifying or
95             distributing the Package, you accept this license. Do not use, modify,
96             or distribute the Package, if you do not accept this license.
97              
98             If your Modified Version has been derived from a Modified Version made
99             by someone other than you, you are nevertheless required to ensure that
100             your Modified Version complies with the requirements of this license.
101              
102             This license does not grant you the right to use any trademark, service
103             mark, trade name, or logo of the Copyright Holder.
104              
105             This license includes the non-exclusive, worldwide, free-of-charge
106             patent license to make, have made, use, offer to sell, sell, import and
107             otherwise transfer the Package with respect to any patent claims
108             licensable by the Copyright Holder that are necessarily infringed by the
109             Package. If you institute patent litigation (including a cross-claim or
110             counterclaim) against any party alleging that the Package constitutes
111             direct or contributory patent infringement, then this Artistic License
112             to you shall terminate on the date that such litigation is filed.
113              
114             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
115             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
116             THE IMPLIED WARRANTIES OF MERCHANT ABILITY, FITNESS FOR A PARTICULAR
117             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
118             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
119             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
120             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
121             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
122              
123             =cut