blib/lib/Kwiki/Test.pm

filter: Statementstmt 59.3% 35 / 59 Branchbran 40.0% 4 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 62.5% 10 / 16 Podpod 0.0% 0 / 10 totaltotal 51.5% 49 / 95 CC 7 SCAR 9.6
CC
7
Cov
57%
initialize_plugins
6.0
cleanup
6.0
hub
3.1
CRAP 2.6
↑ Summary
1 package Kwiki::Test;
2 4 ▶use Spiffy -Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶use Kwiki;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use IO::All;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use Cwd;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 const 'base_dir' => Cwd::abs_path(".") . "/kwiki";
8  
9 4 our $VERSION = '0.03';
10  
11 4 ▶sub init {
Subroutine init: called CC=2 SCAR=9.9
Pod undocumented
12 4 my $plugins = shift;
13 4 $self->make_directory;
14 4 $self->install_new_kwiki;
15 0 ▶ if ($plugins) {
Branch: 1 branch
BranchTrueFalseTotal
if ($plugins) 0 0 0
16 0 $self->add_plugins($plugins);
17 }
18 0 return $self;
19 }
20  
21 0 ▶sub initialize_plugins {
Subroutine initialize_plugins: not called CC=2 SCAR=17.9
Pod undocumented
22 0 my @plugins = @{$self->hub->registry->lookup->{plugins}};
23 0 foreach my $plugin (@plugins) {
24 0 my $class = $plugin->{id};
25 0 $self->hub->$class->init;
26 }
27 }
28  
29 0 ▶sub reset_hub {
Subroutine reset_hub: not called CC=1 SCAR=6.9
Pod undocumented
30 0 undef($self->{hub});
31 0 $self->hub;
32 }
33  
34 4 ▶sub hub {
Subroutine hub: called CC=3 SCAR=11.2
Pod undocumented
35 4 ▶ return $self->{hub} if $self->{hub};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"hub"} 0 4 4
36 4 ▶ chdir($self->base_dir) || die "unable to chdir to ", $self->base_dir,
Branch: 1 branch
BranchTrueFalseTotal
chdir $self->base_dir or die "unable to chdir to ", $self->base_dir, "$!\n" 4 0 4
37 "$!\n";;
38 4 my @configs = qw(config.yaml -plugins plugins);
39 4 my $hub = Kwiki->new->load_hub(@configs);
40 4 $self->{hub} = $hub;
41 }
42  
43 4 ▶sub make_directory {
Subroutine make_directory: called CC=2 SCAR=6.9
Pod undocumented
44 4 ▶ mkdir($self->base_dir) || warn "unable to mkdir ", $self->base_dir, "\n";
Branch: 1 branch
BranchTrueFalseTotal
mkdir $self->base_dir or warn "unable to mkdir ", $self->base_dir, "\n" 1 3 4
45 }
46  
47 4 ▶sub install_new_kwiki {
Subroutine install_new_kwiki: called CC=1 SCAR=0.4
Pod undocumented
48 # we've already chdir'd
49 4 $self->hub->command->process(qw(-quiet -new .));
50 # reset the hub
51 0 undef($self->{hub});
52 }
53  
54 0 ▶sub add_plugins {
Subroutine add_plugins: not called CC=1 SCAR=6.9
Pod undocumented
55 0 my $plugins = shift;
56 0 $self->hub->command->quiet(1);
57 0 $self->hub->command->handle_add(@$plugins);
58 0 $self->initialize_plugins;
59 }
60  
61 0 ▶sub cleanup {
Subroutine cleanup: not called CC=2 SCAR=17.9
Pod undocumented
62 0 ▶ io($self->base_dir)->rmtree unless $ENV{KWIKI_TEST_DIRTY};
Branch: 1 branch
BranchTrueFalseTotal
unless $ENV{"KWIKI_TEST_DIRTY"} 0 0 0
63 }
64  
65 # Utlity stuff
66 # some of this is obvious, but doing it in here in case
67 # there are change dirs and the like that we'd like to do
68  
69 0 ▶sub exists_as_file {
Subroutine exists_as_file: not called CC=1 SCAR=6.9
Pod undocumented
70 0 -f shift;
71 }
72  
73 0 ▶sub exists_as_dir {
Subroutine exists_as_dir: not called CC=1 SCAR=6.9
Pod undocumented
74 0 -d shift;
75 }
76  
77 4 __DATA__
↑ Summary