File Coverage

blib/lib/Geoffrey/Changelog/None.pm
Criterion Covered Total %
statement 37 38 97.3
branch 5 6 83.3
condition 2 4 50.0
subroutine 13 13 100.0
pod 6 6 100.0
total 63 67 94.0


line stmt bran cond sub pod time code
1             package Geoffrey::Changelog::None;
2              
3 3     3   389042 use utf8;
  3         377  
  3         23  
4 3     3   176 use 5.016;
  3         14  
5 3     3   21 use strict;
  3         22  
  3         94  
6 3     3   16 use warnings;
  3         6  
  3         292  
7 3     3   15623 use File::Slurp qw/write_file read_file/;
  3         146944  
  3         447  
8 3     3   1782 use Data::Dumper;
  3         25176  
  3         325  
9              
10             $Geoffrey::Changelog::None::VERSION = '0.000206';
11              
12 3     3   30 use parent 'Geoffrey::Role::Changelog';
  3         6  
  3         30  
13              
14             sub new {
15 4     4 1 1380 my $class = shift;
16 4         34 my $self = $class->SUPER::new(@_);
17 4   50     47 $self->{ending} //= '.pl';
18 4   50     26 $self->{from_hash} //= 0;
19 4         25 return bless $self, $class;
20             }
21              
22             sub from_hash {
23 6     6 1 1195 my ( $self, $b_load_from_hash ) = @_;
24 6 100       49 return $self->{from_hash} if !defined $b_load_from_hash;
25 1         14 $self->{from_hash} = $b_load_from_hash;
26 1         4 return $self;
27             }
28              
29             sub tpl_main {
30             return {
31 1     1 1 26 templates => [
32             {
33             name => 'tpl_std',
34             columns => [ { name => 'id', type => 'integer', notnull => 1, primarykey => 1, default => 'inc', }, ],
35             },
36             ],
37             prefix => 'smpl',
38             postfix => 'end',
39             changelogs => [ '01', ],
40             };
41             }
42              
43             sub tpl_sub {
44             return [
45             {
46 1     1 1 1474 id => '001.01-maz',
47             author => 'Mario Zieschang',
48             entries => [ { action => 'table.add', name => 'client', template => 'tpl_std', columns => [], }, ],
49             }
50             ];
51             }
52              
53             sub load {
54 5     5 1 17 my ( $self, $ur_file_structure ) = @_;
55 5 100       20 return $self->from_hash ? $ur_file_structure : do( $ur_file_structure . $self->ending() );
56             }
57              
58             sub write {
59 4     4 1 13 my ( $self, $dir, $hr_data, $b_dump ) = @_;
60 4         23 my $s_file = $dir . $self->ending;
61 4         37 $hr_data = Data::Dumper->new( [$hr_data] )->Terse(1)->Deparse(1)->Sortkeys(1)->Dump;
62 4 50       650 return $hr_data if $b_dump;
63 0           return write_file( $s_file, $hr_data );
64             }
65              
66             1; # End of Geoffrey::Changelog
67              
68             __END__