| 1 | package Kwiki::Command; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use Spoon::Command -Base; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | |||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 0 | ▶ | sub handle_new { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 0 | $self->assert_directory(shift, 'Kwiki'); | |||||||||||||||||||||||||||||||||||||||||||||
| 6 | 0 | $self->add_new_default_config; | |||||||||||||||||||||||||||||||||||||||||||||
| 7 | 0 | $self->install('files'); | |||||||||||||||||||||||||||||||||||||||||||||
| 8 | 0 | $self->install('config'); | |||||||||||||||||||||||||||||||||||||||||||||
| 9 | 0 | $self->create_registry; | |||||||||||||||||||||||||||||||||||||||||||||
| 10 | # XXX a method should return this list of plugin class_ids | ||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 0 | $self->install('display'); | |||||||||||||||||||||||||||||||||||||||||||||
| 12 | 0 | $self->install('edit'); | |||||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | $self->install('formatter'); | |||||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | $self->install('users'); | |||||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | $self->install('pages'); | |||||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | $self->install('theme'); | |||||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | $self->install('toolbar'); | |||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | $self->install('status'); | |||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | $self->install('widgets'); | |||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | io('plugin')->mkdir; | |||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | $self->set_permissions; | |||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | warn "\nKwiki software installed! Point your browser at this location.\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | sub handle_new_view { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_new_view: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | $self->assert_directory(shift, 'kwiki view'); | |||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | die "Parent directory does not look like a Kwiki installation" | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | unless -e '../plugins'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | require Cwd; | |||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | my $home = Cwd::cwd(); | |||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | $home =~ s/.*\///; | |||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | for my $file (io->updir->all) { | |||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | my $name = $file->filename; | |||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | next if $name eq '.htaccess'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | next if $name eq 'plugins'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | next if $name eq 'registry.dd'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | next if $name eq $home; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | io->link($name)->symlink($file->name); | |||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | $self->create_new_view_plugins; | |||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | $self->handle_update; | |||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | print <<END; | |||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | New view created. Now edit the $home/plugins file and run | ||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 'kwiki -update' in the '$home' subdirectory. | ||||||||||||||||||||||||||||||||||||||||||||||
| 46 | END | ||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | sub create_new_view_plugins { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_new_view_plugins: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | io('plugins')->print(<<END); | |||||||||||||||||||||||||||||||||||||||||||||
| 51 | # You can either list all the plugins you want manually, or put '+' and '-' in | ||||||||||||||||||||||||||||||||||||||||||||||
| 52 | # front of the plugins you want to add/remove from ../plugins respectively. | ||||||||||||||||||||||||||||||||||||||||||||||
| 53 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 54 | # Example: | ||||||||||||||||||||||||||||||||||||||||||||||
| 55 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 56 | # -Kwiki::Edit | ||||||||||||||||||||||||||||||||||||||||||||||
| 57 | # +Kwiki::Favorites | ||||||||||||||||||||||||||||||||||||||||||||||
| 58 | # +Kwiki::Weather | ||||||||||||||||||||||||||||||||||||||||||||||
| 59 | END | ||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | sub assert_directory { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
assert_directory: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | chdir io->dir(shift || '.')->assert->open->name; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || '.'
MC/DC0%0/1
shift() || '.'
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | my $noun = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | die "Can't make new $noun in a non-empty directory\n" | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 66 | unless io('.')->empty; | ||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | sub add_new_default_config { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_new_default_config: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | $self->hub->config->add_config( | |||||||||||||||||||||||||||||||||||||||||||||
| 71 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 72 | display_class => 'Kwiki::Display', | ||||||||||||||||||||||||||||||||||||||||||||||
| 73 | edit_class => 'Kwiki::Edit', | ||||||||||||||||||||||||||||||||||||||||||||||
| 74 | files_class => 'Kwiki::Files', | ||||||||||||||||||||||||||||||||||||||||||||||
| 75 | theme_class => 'Kwiki::Theme::Basic', | ||||||||||||||||||||||||||||||||||||||||||||||
| 76 | toolbar_class => 'Kwiki::Toolbar', | ||||||||||||||||||||||||||||||||||||||||||||||
| 77 | status_class => 'Kwiki::Status', | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | widgets_class => 'Kwiki::Widgets', | ||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 80 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | sub install { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
install: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | my $class_id = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | my $object = $self->hub->$class_id | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 86 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | return unless $object->can('extract_files'); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | my $class_title = $self->hub->$class_id->class_title; | |||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | $self->msg("Extracting files for $class_title:\n"); | |||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | $self->hub->$class_id->quiet($self->quiet); | |||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | $self->hub->$class_id->extract_files; | |||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | $self->msg("\n"); | |||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | sub is_kwiki_dir { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_kwiki_dir: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | my $dir = shift || '.'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || '.'
MC/DC0%0/1
shift() || '.'
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | -d "$dir/plugin" and -f "$dir/registry.dd"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | sub handle_update { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_update: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | chdir io->dir(shift || '.')->assert->open . ''; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || '.'
MC/DC0%0/1
shift() || '.'
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | die "Can't update non Kwiki directory!\n" | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 103 | unless -d 'plugin'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | $self->create_registry; | |||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | $self->install($_) for $self->all_class_ids; | |||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | $self->set_permissions; | |||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | sub handle_update_all { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_update_all: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | my @dirs = (io->curdir, io->curdir->All_Dirs); | |||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | while (my $dir = shift @dirs) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | next unless $self->is_kwiki_dir($dir); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | $self->msg('Updating ', $dir->absolute->pathname, "\n"); | |||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | $dir->chdir; | |||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | system("kwiki -quiet -update"); | |||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | sub all_class_ids { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all_class_ids: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | my @all_modules; | |||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | for my $key (keys %{$self->hub->config}) { | |||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | push @all_modules, $self->hub->config->{$key} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 123 | if $key =~ /_class/; | ||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | push @all_modules, @{$self->hub->config->{plugin_classes} || []}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->hub->config->{'plugin_classes'} || []
MC/DC0%0/1
$self->hub->config->{'plugin_classes'} || []
$self->hub->config->{'plugin_classes'}
Truth table0%0/2
A
A= $self->hub->config->{'plugin_classes'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 126 | map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | eval "require $_; 1" | |||||||||||||||||||||||||||||||||||||||||||||
| 128 | ? $_->can('extract_files') | ||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | ? do { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | my $class_id = $_->class_id; | |||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | $self->hub->config->add_config({"${class_id}_class" => $_}); | |||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ($_->class_id) | |||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 134 | : () | ||||||||||||||||||||||||||||||||||||||||||||||
| 135 | : (); | ||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } @all_modules; | ||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | sub handle_add { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_add: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | $self->update_plugins('+', @_); | |||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | sub handle_remove { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_remove: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | $self->update_plugins('-', @_); | |||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | sub update_plugins { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_plugins: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | die "This operation must be performed inside a Kwiki installation directory" | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 149 | unless -f $self->hub->config->plugins_file; | ||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | my $mode = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | return $self->usage unless @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | my $plugins_file = $self->hub->config->plugins_file; | |||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my $plugins = io($plugins_file); | |||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | my @lines = $plugins->chomp->slurp; | |||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | for my $module (@_) { | |||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | eval "require $module;1" or die $@ or | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/8
eval "require $module;1" or die $@ or $module = "Kwiki::$module" and eval "require $module;1"
eval "require $module;1" or die $@
$module = "Kwiki::$module" and eval "require $module;1"
MC/DC0%0/3
eval "require $module;1" or die $@ or $module = "Kwiki::$module" and eval "require $module;1"
eval "require $module;1"
$module = "Kwiki::$module"
eval "require $module;1"
Truth table0%0/4
A or B and C
A= eval "require $module;1"B= $module = "Kwiki::$module"C= eval "require $module;1"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 157 | ($module = "Kwiki::$module" and eval "require $module;1") or | ||||||||||||||||||||||||||||||||||||||||||||||
| 158 | die "Invalid module '$module'"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | if ($mode eq '+') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | next if grep /^$module$/, @lines; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | push @lines, $module; | |||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | @lines = grep {$_ ne $module} @lines; | |||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $plugins->println($_) for @lines; | |||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | $plugins->close; | |||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | $self->hub->config->add_plugins_file($plugins_file); | |||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | $self->handle_update; | |||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | sub handle_install { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_install: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | die "This operation must be performed inside a Kwiki installation directory" | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 174 | unless -f $self->hub->config->plugins_file; | ||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | return $self->usage unless @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | require Cwd; | |||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | $self->cpan_setup; | |||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | my @modules = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | for my $module (@_) { | |||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $self->fake_install($module); | |||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | my $home = Cwd::cwd(); | |||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | my $rc = CPAN::Shell->expand('Module', $module); | |||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | if (not defined $rc) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | die "WARNING - Can't install $module\nStopping...\n"; | |||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | $rc->install; | |||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | chdir $home; | |||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | $self->update_plugins('+', @modules); | |||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | sub cpan_setup { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cpan_setup: not called CC=2 SCAR=13.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 1 | ▶ | no warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | require CPAN; | |||||||||||||||||||||||||||||||||||||||||||||
| 195 | # require CPAN::Config; | ||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | my $lib = io->dir('lib')->absolute; | |||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | $ENV{PERL_MM_OPT} = "INSTALLSITELIB=$lib PREFIX=$lib" | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 198 | if $lib->exists; | ||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | CPAN::Config->load; | |||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | $CPAN::Config_loaded = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | my $cpan_dir = io->dir('.cpan')->rel2abs; | |||||||||||||||||||||||||||||||||||||||||||||
| 202 | $CPAN::Config->{cpan_home} = | ||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | $CPAN::Config->{build_dir} = $cpan_dir; | |||||||||||||||||||||||||||||||||||||||||||||
| 204 | $CPAN::Config->{keep_source_where} = | ||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | io->catdir($cpan_dir, 'sources')->name; | |||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | sub fake_install { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fake_install: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | return unless -d 'lib'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | my $module = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | $module =~ s/::/\//g; | |||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | $module .= '.pm'; | |||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | my $file = io->catfile('lib', $module); | |||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | $file->assert->touch | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 215 | unless -f $file->name; | ||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | sub handle_compress { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle_compress: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | require Spoon::Installer; | |||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | Spoon::Installer->new->compress_lib(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | sub set_permissions { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_permissions: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | my $umask = umask 0000; | |||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | chmod 0777, qw(database plugin); | |||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | chmod 0666, qw(database/HomePage); | |||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | chmod 0755, qw(index.cgi); | |||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | umask $umask; | |||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | sub create_registry { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_registry: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | my $registry = $self->hub->registry; | |||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | my $registry_path = $registry->registry_path; | |||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | $self->msg("Generating Kwiki Registry '$registry_path'\n"); | |||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | $registry->update; | |||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | if ($registry->validate) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | $registry->write; | |||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | $self->hub(); | |||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | $self->hub->registry->load; | |||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | sub usage { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
usage: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | warn <<END . $self->command_usage(" kwiki -%-20s # %s\n"); | |||||||||||||||||||||||||||||||||||||||||||||
| 246 | usage: | ||||||||||||||||||||||||||||||||||||||||||||||
| 247 | kwiki -new [path] # Generate a new Kwiki | ||||||||||||||||||||||||||||||||||||||||||||||
| 248 | kwiki -update [path] # Update an existing Kwiki | ||||||||||||||||||||||||||||||||||||||||||||||
| 249 | kwiki -add Kwiki::Foo # Add a plugin | ||||||||||||||||||||||||||||||||||||||||||||||
| 250 | kwiki -remove Kwiki::Foo # Remove a plugin | ||||||||||||||||||||||||||||||||||||||||||||||
| 251 | kwiki -install Kwiki::Foo # Download and install a plugin | ||||||||||||||||||||||||||||||||||||||||||||||
| 252 | kwiki -new_view [subdir] # Create a new view under an existing Kwiki | ||||||||||||||||||||||||||||||||||||||||||||||
| 253 | kwiki -update_all # Update all Kwiki dirs under current dir | ||||||||||||||||||||||||||||||||||||||||||||||
| 254 | END | ||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 1 | __DATA__ | |||||||||||||||||||||||||||||||||||||||||||||