line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Initializes a new Pinto repository |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Pinto::Initializer; |
4
|
|
|
|
|
|
|
|
5
|
51
|
|
|
51
|
|
22287
|
use Moose; |
|
51
|
|
|
|
|
125
|
|
|
51
|
|
|
|
|
355
|
|
6
|
51
|
|
|
51
|
|
310502
|
use MooseX::StrictConstructor; |
|
51
|
|
|
|
|
121
|
|
|
51
|
|
|
|
|
486
|
|
7
|
51
|
|
|
51
|
|
155612
|
use MooseX::MarkAsMethods ( autoclean => 1 ); |
|
51
|
|
|
|
|
128
|
|
|
51
|
|
|
|
|
484
|
|
8
|
|
|
|
|
|
|
|
9
|
51
|
|
|
51
|
|
169155
|
use IO::Zlib; |
|
51
|
|
|
|
|
128
|
|
|
51
|
|
|
|
|
465
|
|
10
|
51
|
|
|
51
|
|
2438
|
use Path::Class; |
|
51
|
|
|
|
|
114
|
|
|
51
|
|
|
|
|
3284
|
|
11
|
|
|
|
|
|
|
|
12
|
51
|
|
|
51
|
|
284
|
use Pinto; |
|
51
|
|
|
|
|
104
|
|
|
51
|
|
|
|
|
1058
|
|
13
|
51
|
|
|
51
|
|
237
|
use Pinto::Config; |
|
51
|
|
|
|
|
100
|
|
|
51
|
|
|
|
|
1336
|
|
14
|
51
|
|
|
51
|
|
251
|
use Pinto::Util qw(debug); |
|
51
|
|
|
|
|
90
|
|
|
51
|
|
|
|
|
31296
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '0.13'; # VERSION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub init { |
23
|
113
|
|
|
113
|
0
|
5297
|
my ( $self, %args ) = @_; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
die "Must specify a root\n" |
26
|
113
|
50
|
|
|
|
695
|
if not $args{root}; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Normalize root |
29
|
113
|
|
|
|
|
1001
|
$args{root} =~ s{^file://}{}; |
30
|
|
|
|
|
|
|
|
31
|
113
|
|
|
|
|
3172
|
$self->_check_sanity(%args); |
32
|
113
|
|
|
|
|
779
|
$self->_make_dirs(%args); |
33
|
113
|
|
|
|
|
751
|
$self->_write_config(%args); |
34
|
113
|
|
|
|
|
888
|
$self->_write_mailrc(%args); |
35
|
113
|
|
|
|
|
740
|
$self->_set_version(%args); |
36
|
113
|
|
|
|
|
707
|
$self->_create_db(%args); |
37
|
113
|
|
|
|
|
11114
|
$self->_create_stack(%args); |
38
|
|
|
|
|
|
|
|
39
|
113
|
|
|
|
|
4427
|
return $self; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _check_sanity { |
45
|
113
|
|
|
113
|
|
504
|
my ( $self, %args ) = @_; |
46
|
|
|
|
|
|
|
|
47
|
113
|
|
|
|
|
537
|
my $root_dir = dir( $args{root} ); |
48
|
113
|
50
|
33
|
|
|
4962
|
die "Directory $root_dir must be empty to create a repository there\n" |
49
|
|
|
|
|
|
|
if -e $root_dir and $root_dir->children; |
50
|
|
|
|
|
|
|
|
51
|
113
|
|
|
|
|
19415
|
return; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _make_dirs { |
57
|
113
|
|
|
113
|
|
545
|
my ( $self, %args ) = @_; |
58
|
|
|
|
|
|
|
|
59
|
113
|
|
|
|
|
4540
|
my $config = Pinto::Config->new( root => $args{root} ); |
60
|
|
|
|
|
|
|
|
61
|
113
|
|
|
|
|
748
|
for my $dir ( $config->directories ) { |
62
|
678
|
|
|
|
|
112353
|
debug "Making directory $dir"; |
63
|
678
|
|
|
|
|
2008
|
$dir->mkpath; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
113
|
|
|
|
|
13547
|
return; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub _write_config { |
72
|
113
|
|
|
113
|
|
547
|
my ( $self, %args ) = @_; |
73
|
|
|
|
|
|
|
|
74
|
113
|
|
|
|
|
3116
|
my $config = Pinto::Config->new( root => $args{root} ); |
75
|
|
|
|
|
|
|
|
76
|
113
|
|
|
|
|
3057
|
my $config_file = $config->config_dir->file( $config->basename ); |
77
|
113
|
|
|
|
|
14039
|
$config->write_config_file( file => $config_file, values => \%args ); |
78
|
|
|
|
|
|
|
|
79
|
113
|
|
|
|
|
576879
|
return; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub _write_mailrc { |
85
|
113
|
|
|
113
|
|
520
|
my ( $self, %args ) = @_; |
86
|
|
|
|
|
|
|
|
87
|
113
|
|
|
|
|
3524
|
my $config = Pinto::Config->new( root => $args{root} ); |
88
|
|
|
|
|
|
|
|
89
|
113
|
50
|
|
|
|
3425
|
my $fh = IO::Zlib->new( $config->mailrc_file->stringify, 'wb' ) or die $!; |
90
|
113
|
|
|
|
|
236936
|
print {$fh} ''; # File will be empty, but have gzip headers |
|
113
|
|
|
|
|
946
|
|
91
|
113
|
50
|
|
|
|
11919
|
close $fh or throw $!; |
92
|
|
|
|
|
|
|
|
93
|
113
|
|
|
|
|
42791
|
return; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub _set_version { |
99
|
113
|
|
|
113
|
|
535
|
my ( $self, %args ) = @_; |
100
|
|
|
|
|
|
|
|
101
|
113
|
|
|
|
|
3387
|
my $pinto = Pinto->new( root => $args{root} ); |
102
|
|
|
|
|
|
|
|
103
|
113
|
|
|
|
|
2895
|
$pinto->repo->set_version; |
104
|
|
|
|
|
|
|
|
105
|
113
|
|
|
|
|
3722
|
return; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub _create_db { |
111
|
113
|
|
|
113
|
|
480
|
my ( $self, %args ) = @_; |
112
|
|
|
|
|
|
|
|
113
|
113
|
|
|
|
|
2858
|
my $pinto = Pinto->new( root => $args{root} ); |
114
|
|
|
|
|
|
|
|
115
|
113
|
|
|
|
|
2607
|
$pinto->repo->db->deploy; |
116
|
|
|
|
|
|
|
|
117
|
113
|
|
|
|
|
14257
|
return; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub _create_stack { |
123
|
113
|
|
|
113
|
|
657
|
my ( $self, %args ) = @_; |
124
|
|
|
|
|
|
|
|
125
|
113
|
|
100
|
|
|
1325
|
my $stack = $args{stack} || 'master'; |
126
|
113
|
100
|
|
|
|
537
|
my $is_default = $args{no_default} ? 0 : 1; |
127
|
113
|
|
|
|
|
3763
|
my $pinto = Pinto->new( root => $args{root} ); |
128
|
|
|
|
|
|
|
|
129
|
113
|
|
|
|
|
973
|
$pinto->run( New => ( stack => $stack, default => $is_default ) ); |
130
|
|
|
|
|
|
|
|
131
|
113
|
|
|
|
|
3674
|
return; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
1; |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
__END__ |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=pod |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=encoding UTF-8 |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=for :stopwords Jeffrey Ryan Thalhammer |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 NAME |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Pinto::Initializer - Initializes a new Pinto repository |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 VERSION |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
version 0.13 |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 AUTHOR |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Jeffrey Ryan Thalhammer <jeff@stratopan.com> |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Jeffrey Ryan Thalhammer. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
167
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=cut |