bin/yukki-setup

filter: Statementstmt 100% 62 / 62 Branchbran 83.3% 10 / 12 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 93.1% 81 / 87 CC 2 SCAR 2.0
CC
2
Cov
95%
__ANON__
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« blib/lib/Yukki/User.pm ↑ Summary blib/lib/Yukki/Settings/Repository.pm »
1 #!/usr/bin/env perl
2 6 ▶use v5.24;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 6 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 6 ▶use Yukki::Web;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use Yukki::TextUtil qw( load_file );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 6 ▶use autodie;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 ▶use File::ShareDir qw( module_dir );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 6 ▶use Path::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 6 my $site_dir = shift;
13 6 my $skel_dir = shift;
14  
15 6 ▶die "usage: $0 path/to/new-site-directory [path/to/skel]\n" unless $site_dir;
Branch: 1 branch
BranchTrueFalseTotal
unless $site_dir 0 6 6
16 6 ▶die qq[A file or directory named "$site_dir" already exists, will not overwrite.\n]
Branch: 1 branch
BranchTrueFalseTotal
if -e $site_dir 0 6 6
17 if -e $site_dir;
18  
19 6 my $root = path($site_dir)->absolute;
20 6 ▶my $module_dir = path($skel_dir // module_dir('Yukki::Web'));
Condition33%1/3
$skel_dir // module_dir("Yukki::Web")
l!l&&r!l&&!r
600
MC/DC0%0/2
$skel_dir // module_dir("Yukki::Web")
$skel_dir module_dir("Yukki::Web")
Truth table33%1/3
A // B
A= $skel_dirB= module_dir("Yukki::Web")
ABresult
1X1
011
000
21  
22 6 $root->mkpath;
23 $module_dir->visit(
24 888 ▶ sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
25 888 my ($path, $state) = @_;
26 888 my $new_path = $path->relative($module_dir)->absolute($root);
27 888 ▶ if ($path->is_dir) {
Branch: 1 branch
BranchTrueFalseTotal
if ($path->is_dir) { } 150 738 888
28 150 $new_path->mkpath;
29 }
30 else {
31 738 $path->copy($new_path);
32 }
33 },
34 6 { recurse => 1 },
35 );
36  
37 6 my $yaml = path($root, 'etc', 'yukki.conf');
38  
39 # Don't use YAML to load the file or we'll lose spaces and comments
40 6 rename $yaml, "$yaml~";
41 6 open my $out_config, '>:encoding(UTF-8)', $yaml;
42 6 open my $in_config, '<:encoding(UTF-8)', "$yaml~";
43 6 ▶while (my $line = <$in_config>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $in_config)) 492 6 498
44 492 ▶ if ($line =~ /^root:/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^root:/u) 6 486 492
45 6 $line = "root: $root\n";
46 }
47 492 print $out_config $line;
48 }
49 6 close $out_config;
50 6 close $in_config;
51 6 unlink "$yaml~";
52  
53 6 chmod 0444, "$yaml";
54  
55 6 my $config = load_file($yaml);
56  
57 6 say "Please read the installation instructions if you have not:\n";
58 6 say "\tperldoc Yukki::Manual::Installation\n";
59  
60 6 say "The rest of these remarks assume you run this first:\n";
61 6 say "\tcd $site_dir\n";
62  
63 6 say "You probably want to setup your repositories by running:\n";
64 6 for (sort keys %{ $config->{repositories} }) {
65 12 ▶ if (/^yukki$/) { say "\tyukki-git-init $_ git://github.com/zostay/yukki-help.git" }
Branch: 1 branch
BranchTrueFalseTotal
if (/^yukki$/u) { } 6 6 12
66 6 else { say "\tyukki-git-init $_" }
67 }
68 6 print "\n";
69  
70 6 say "And then you'll want at least one user, so run:\n";
71 6 say "\tyukki-add-user\n";
72  
73 6 say "To start your Yukki server, run:\n";
74 6 say "\tcd $site_dir; plackup yukki.psgi\n";
75  
76 6 say "Have a nice day!";
77  
78 # ABSTRACT: constructs the boilerplate needed to start a Yukki site
79 # PODNAME: yukki-setup
80  
81 __END__
« blib/lib/Yukki/User.pm ↑ Summary blib/lib/Yukki/Settings/Repository.pm »