lib/DBIx/SchemaChecksum/App/NewChangesFile.pm

filter: Statementstmt 45.8% 11 / 24 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 40.0% 2 / 5 Podpod n/a totaltotal 44.8% 13 / 29 CC 1 SCAR 4.7
CC
1
Cov
46%
__ANON__
2.0
run
2.0
tpl
2.0
CRAP 1.6
« script/scs.pl ↑ Summary lib/DBIx/SchemaChecksum/App/Checksum.pm »
1 package DBIx::SchemaChecksum::App::NewChangesFile;
2  
3 # ABSTRACT: Generate a new changes-file
4 1 our $VERSION = '1.106'; # VERSION
5  
6 1 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use MooseX::App::Command;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 extends qw(DBIx::SchemaChecksum::App);
10  
11 1 option '+sqlsnippetdir' => ( required => 1);
12 option 'change_name' => (
13 is=>'ro',
14 isa=>'Str',
15 documentation=>'Short description of the change, change file name will be based on this value',
16 0 ▶ default=>sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
17 0 'unnamed_change_'.time(),
18 }
19 1 );
20  
21 0 ▶sub run {
Subroutine run: not called CC=1 SCAR=6.9
22 0 my $self = shift;
23  
24 0 my $name = my $change_desc = $self->change_name;
25 0 $name=~s/[^a-z0-9\-\._]/_/gi;
26  
27 0 my $file = Path::Class::Dir->new($self->sqlsnippetdir)->file($name.'.sql');
28 0 my $current_checksum = $self->checksum;
29 0 my $tpl = $self->tpl;
30 0 $tpl=~s/%CHECKSUM%/$current_checksum/;
31 0 $tpl=~s/%NAME%/$change_desc/;
32  
33 0 $file->parent->mkpath;
34 0 $file->spew(iomode => '>:encoding(UTF-8)', $tpl);
35  
36 0 say "New change-file ready at ".$file->stringify;
37 }
38  
39 0 ▶sub tpl {
Subroutine tpl: not called CC=1 SCAR=6.9
40 0 return <<EOSNIPPET;
41 -- preSHA1sum: %CHECKSUM%
42 -- postSHA1sum: xxx-New-Checksum-xxx
43 -- %NAME%
44  
45 EOSNIPPET
46 }
47  
48 1 __PACKAGE__->meta->make_immutable();
49 1 1;
50  
51 __END__
« script/scs.pl ↑ Summary lib/DBIx/SchemaChecksum/App/Checksum.pm »