line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Kwiki::Test; |
2
|
4
|
|
|
4
|
|
27640
|
use Spiffy -Base; |
|
4
|
|
|
|
|
29410
|
|
|
4
|
|
|
|
|
40
|
|
3
|
4
|
|
|
4
|
|
14447
|
use Kwiki; |
|
4
|
|
|
4
|
|
10
|
|
|
4
|
|
|
4
|
|
123
|
|
|
4
|
|
|
|
|
19
|
|
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
95
|
|
|
4
|
|
|
|
|
7356
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use IO::All; |
5
|
|
|
|
|
|
|
use Cwd; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
const 'base_dir' => Cwd::abs_path(".") . "/kwiki"; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub init { |
12
|
|
|
|
|
|
|
my $plugins = shift; |
13
|
|
|
|
|
|
|
$self->make_directory; |
14
|
|
|
|
|
|
|
$self->install_new_kwiki; |
15
|
|
|
|
|
|
|
if ($plugins) { |
16
|
|
|
|
|
|
|
$self->add_plugins($plugins); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
return $self; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub initialize_plugins { |
22
|
|
|
|
|
|
|
my @plugins = @{$self->hub->registry->lookup->{plugins}}; |
23
|
|
|
|
|
|
|
foreach my $plugin (@plugins) { |
24
|
|
|
|
|
|
|
my $class = $plugin->{id}; |
25
|
|
|
|
|
|
|
$self->hub->$class->init; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub reset_hub { |
30
|
|
|
|
|
|
|
undef($self->{hub}); |
31
|
|
|
|
|
|
|
$self->hub; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub hub { |
35
|
|
|
|
|
|
|
return $self->{hub} if $self->{hub}; |
36
|
|
|
|
|
|
|
chdir($self->base_dir) || die "unable to chdir to ", $self->base_dir, |
37
|
|
|
|
|
|
|
"$!\n";; |
38
|
|
|
|
|
|
|
my @configs = qw(config.yaml -plugins plugins); |
39
|
|
|
|
|
|
|
my $hub = Kwiki->new->load_hub(@configs); |
40
|
|
|
|
|
|
|
$self->{hub} = $hub; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub make_directory { |
44
|
|
|
|
|
|
|
mkdir($self->base_dir) || warn "unable to mkdir ", $self->base_dir, "\n"; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub install_new_kwiki { |
48
|
|
|
|
|
|
|
# we've already chdir'd |
49
|
|
|
|
|
|
|
$self->hub->command->process(qw(-quiet -new .)); |
50
|
|
|
|
|
|
|
# reset the hub |
51
|
|
|
|
|
|
|
undef($self->{hub}); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub add_plugins { |
55
|
|
|
|
|
|
|
my $plugins = shift; |
56
|
|
|
|
|
|
|
$self->hub->command->quiet(1); |
57
|
|
|
|
|
|
|
$self->hub->command->handle_add(@$plugins); |
58
|
|
|
|
|
|
|
$self->initialize_plugins; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub cleanup { |
62
|
|
|
|
|
|
|
io($self->base_dir)->rmtree unless $ENV{KWIKI_TEST_DIRTY}; |
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
|
|
|
|
|
|
|
sub exists_as_file { |
70
|
|
|
|
|
|
|
-f shift; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub exists_as_dir { |
74
|
|
|
|
|
|
|
-d shift; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
__DATA__ |