| 1 | package Kwiki::Spork; | ||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use Kwiki::Plugin -Base; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use Kwiki::Installer -Base; | ||||||||||||||||||||||||||
|
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 | 1 | our $VERSION = '0.11'; | |||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | const class_id => 'spork'; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 0 | ▶ | sub register { | ||||||||||||||||||||||||||
|
Subroutine
register: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 9 | 0 | my $registry = shift; | |||||||||||||||||||||||||||
| 10 | 0 | $registry->add(wafl => spork => 'Kwiki::Spork::Wafl'); | |||||||||||||||||||||||||||
| 11 | } | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | package Kwiki::Spork::Wafl; | ||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use base 'Spoon::Formatter::WaflBlock'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use Cwd; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 0 | ▶ | sub to_html { | ||||||||||||||||||||||||||
|
Subroutine
to_html: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 18 | 0 | my $text = $self->block_text; | |||||||||||||||||||||||||||
| 19 | 0 | $self->make_spork($text); | |||||||||||||||||||||||||||
| 20 | 0 | return join '', | |||||||||||||||||||||||||||
| 21 | qq{<div class="spork">\n}, | ||||||||||||||||||||||||||||
| 22 | $self->render($text), | ||||||||||||||||||||||||||||
| 23 | qq{</div>\n}; | ||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub make_spork { | ||||||||||||||||||||||||||
|
Subroutine
make_spork: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 27 | 0 | my $home = cwd; | |||||||||||||||||||||||||||
| 28 | 0 | my $text = shift; | |||||||||||||||||||||||||||
| 29 | 0 | my $page = $self->hub->pages->current; | |||||||||||||||||||||||||||
| 30 | 0 | my $spork_dir = io->catdir( | |||||||||||||||||||||||||||
| 31 | $self->hub->spork->plugin_directory, $page->id)->assert; | ||||||||||||||||||||||||||||
| 32 | 0 | ▶ | if ((my @x = $spork_dir->all) == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | 0 | $self->require_spork; | |||||||||||||||||||||||||||
| 34 | 0 | chdir $spork_dir; | |||||||||||||||||||||||||||
| 35 | 0 | $self->spork_command->new_spork; | |||||||||||||||||||||||||||
| 36 | 0 | chdir $home; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | 0 | my $slides = io->catfile("$spork_dir", 'Spork.slides'); | |||||||||||||||||||||||||||
| 39 | 0 | ▶ | unless (-f $slides->name and $slides->scalar eq $text) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-f $slides->name and $slides->scalar eq $text
MC/DC0%0/2
-f $slides->name and $slides->scalar eq $text
-f $slides->name
$slides->scalar eq $text
Truth table0%0/3
A and B
A= -f $slides->nameB= $slides->scalar eq $text
| |||||||||||||||||||||||||||||
| 40 | 0 | $self->require_spork; | |||||||||||||||||||||||||||
| 41 | 0 | $slides->print($text); | |||||||||||||||||||||||||||
| 42 | 0 | $slides->close; | |||||||||||||||||||||||||||
| 43 | 0 | chdir $spork_dir; | |||||||||||||||||||||||||||
| 44 | 0 | my %env = %ENV; | |||||||||||||||||||||||||||
| 45 | 0 | delete $env{GATEWAY_INTERFACE}; #XXX Ugly | |||||||||||||||||||||||||||
| 46 | 0 | local %ENV = %env; | |||||||||||||||||||||||||||
| 47 | 0 | $self->spork_command->make_spork; | |||||||||||||||||||||||||||
| 48 | 0 | chdir $home; | |||||||||||||||||||||||||||
| 49 | 0 | my $htaccess = io('template/tt2/spork_htaccess')->scalar; | |||||||||||||||||||||||||||
| 50 | 0 | io("$spork_dir/slides/.htaccess")->print($htaccess); | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 0 | ▶ | sub spork_command { | ||||||||||||||||||||||||||
|
Subroutine
spork_command: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 55 | 0 | local $main::HUB; #XXX tt2 hack | |||||||||||||||||||||||||||
| 56 | 0 | Spork->new->load_hub->command; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 0 | ▶ | sub render { | ||||||||||||||||||||||||||
|
Subroutine
render: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 60 | 0 | my $text = shift; | |||||||||||||||||||||||||||
| 61 | 0 | $text =~ s/^\+//gm; | |||||||||||||||||||||||||||
| 62 | $text = join "----\n", grep { | ||||||||||||||||||||||||||||
| 63 | 0 | ▶ | /\S/ and not /^\w+:\s+\S+/ | ||||||||||||||||||||||||||
|
Condition0%0/3
/\S/ && !/^\w+:\s+\S+/
MC/DC0%0/2
/\S/ && !/^\w+:\s+\S+/
/\S/
!/^\w+:\s+\S+/
Truth table0%0/3
A && not(B)
A= /\S/B= !/^\w+:\s+\S+/
| |||||||||||||||||||||||||||||
| 64 | } split /^\-{4,}\s*\n/m, $text; | ||||||||||||||||||||||||||||
| 65 | 0 | $self->hub->template->process('spork_section.html', | |||||||||||||||||||||||||||
| 66 | text => $text, | ||||||||||||||||||||||||||||
| 67 | ); | ||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | #XXX Something evil is happening and I need this ugly hack. | ||||||||||||||||||||||||||||
| 71 | 0 | ▶ | sub require_spork { | ||||||||||||||||||||||||||
|
Subroutine
require_spork: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 72 | 0 | require Spork; | |||||||||||||||||||||||||||
| 73 | 0 | require Spork::Config; | |||||||||||||||||||||||||||
| 74 | 0 | require Spork::Hub; | |||||||||||||||||||||||||||
| 75 | 0 | require Spork::Command; | |||||||||||||||||||||||||||
| 76 | 0 | require Spork::Template::TT2; | |||||||||||||||||||||||||||
| 77 | 0 | require Spork::Formatter; | |||||||||||||||||||||||||||
| 78 | 0 | require Spork::Slides; | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | package Kwiki::Spork; | ||||||||||||||||||||||||||||
| 82 | 1 | __DATA__ | |||||||||||||||||||||||||||