| 1 | 4 | ▶ | use 5.006; # pragmas |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 2 | 4 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 4 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | package Test::File::ShareDir::Object::Module; | ||
| 6 | |||
| 7 | 4 | our $VERSION = '1.001002'; | |
| 8 | |||
| 9 | # ABSTRACT: Object Oriented ShareDir creation for modules | ||
| 10 | |||
| 11 | 4 | our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY | |
| 12 | |||
| 13 | |||
| 14 | |||
| 15 | |||
| 16 | |||
| 17 | |||
| 18 | |||
| 19 | |||
| 20 | |||
| 21 | |||
| 22 | |||
| 23 | |||
| 24 | |||
| 25 | 4 | ▶ | use Class::Tiny { |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 26 | 3 | ▶ | inc => sub { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 27 | 3 | require Test::File::ShareDir::Object::Inc; | |
| 28 | 3 | return Test::File::ShareDir::Object::Inc->new(); | |
| 29 | }, | ||
| 30 | 0 | ▶ | modules => sub { |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 31 | 0 | return {}; | |
| 32 | }, | ||
| 33 | 2 | ▶ | root => sub { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 34 | 2 | require Path::Tiny; | |
| 35 | 2 | return Path::Tiny::path(q[./])->absolute; | |
| 36 | }, | ||
| 37 | 4 | }; | |
| 38 | |||
| 39 | 4 | ▶ | use Carp qw( carp ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 40 | |||
| 41 | |||
| 42 | |||
| 43 | |||
| 44 | |||
| 45 | |||
| 46 | |||
| 47 | |||
| 48 | |||
| 49 | |||
| 50 | |||
| 51 | |||
| 52 | |||
| 53 | |||
| 54 | |||
| 55 | |||
| 56 | |||
| 57 | |||
| 58 | |||
| 59 | 3 | ▶ | sub __rcopy { require File::Copy::Recursive; goto \&File::Copy::Recursive::rcopy; } |
|
Subroutine
__rcopy: called CC=1 SCAR=0.0
| |||
| 60 | |||
| 61 | |||
| 62 | |||
| 63 | |||
| 64 | |||
| 65 | |||
| 66 | |||
| 67 | |||
| 68 | |||
| 69 | 3 | ▶ | sub module_names { |
|
Subroutine
module_names: called CC=1 SCAR=0.0
Pod
documented
| |||
| 70 | 3 | my ( $self, ) = @_; | |
| 71 | 3 | return keys %{ $self->modules }; | |
| 72 | } | ||
| 73 | |||
| 74 | |||
| 75 | |||
| 76 | |||
| 77 | |||
| 78 | |||
| 79 | |||
| 80 | |||
| 81 | |||
| 82 | 3 | ▶ | sub module_share_target_dir { |
|
Subroutine
module_share_target_dir: called CC=1 SCAR=0.0
Pod
documented
| |||
| 83 | 3 | my ( $self, $module ) = @_; | |
| 84 | |||
| 85 | 3 | $module =~ s/::/-/msxg; | |
| 86 | |||
| 87 | 3 | return $self->inc->module_tempdir->child($module); | |
| 88 | } | ||
| 89 | |||
| 90 | |||
| 91 | |||
| 92 | |||
| 93 | |||
| 94 | |||
| 95 | |||
| 96 | |||
| 97 | |||
| 98 | 3 | ▶ | sub module_share_source_dir { |
|
Subroutine
module_share_source_dir: called CC=1 SCAR=0.0
Pod
documented
| |||
| 99 | 3 | my ( $self, $module ) = @_; | |
| 100 | 3 | require Path::Tiny; | |
| 101 | 3 | return Path::Tiny::path( $self->modules->{$module} )->absolute( $self->root ); | |
| 102 | } | ||
| 103 | |||
| 104 | |||
| 105 | |||
| 106 | |||
| 107 | |||
| 108 | |||
| 109 | |||
| 110 | |||
| 111 | |||
| 112 | 3 | ▶ | sub install_module { |
|
Subroutine
install_module: called CC=1 SCAR=0.0
Pod
documented
| |||
| 113 | 3 | my ( $self, $module ) = @_; | |
| 114 | 3 | my $source = $self->module_share_source_dir($module); | |
| 115 | 3 | my $target = $self->module_share_target_dir($module); | |
| 116 | 3 | return __rcopy( $source, $target ); | |
| 117 | } | ||
| 118 | |||
| 119 | |||
| 120 | |||
| 121 | |||
| 122 | |||
| 123 | |||
| 124 | |||
| 125 | |||
| 126 | |||
| 127 | 3 | ▶ | sub install_all_modules { |
|
Subroutine
install_all_modules: called CC=2 SCAR=6.9
Pod
documented
| |||
| 128 | 3 | my ($self) = @_; | |
| 129 | 3 | for my $module ( $self->module_names ) { | |
| 130 | 3 | $self->install_module($module); | |
| 131 | } | ||
| 132 | 3 | return; | |
| 133 | } | ||
| 134 | |||
| 135 | |||
| 136 | |||
| 137 | |||
| 138 | |||
| 139 | |||
| 140 | |||
| 141 | 0 | ▶ | sub add_to_inc { |
|
Subroutine
add_to_inc: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 142 | 0 | my ($self) = @_; | |
| 143 | 0 | carp 'add_to_inc deprecated since 1.001000, use register'; | |
| 144 | 0 | return $self->register; | |
| 145 | } | ||
| 146 | |||
| 147 | |||
| 148 | |||
| 149 | |||
| 150 | |||
| 151 | |||
| 152 | |||
| 153 | |||
| 154 | |||
| 155 | |||
| 156 | |||
| 157 | 3 | ▶ | sub register { |
|
Subroutine
register: called CC=1 SCAR=0.0
Pod
documented
| |||
| 158 | 3 | my ($self) = @_; | |
| 159 | 3 | $self->inc->register; | |
| 160 | 3 | return; | |
| 161 | } | ||
| 162 | |||
| 163 | |||
| 164 | |||
| 165 | |||
| 166 | |||
| 167 | |||
| 168 | |||
| 169 | |||
| 170 | |||
| 171 | |||
| 172 | |||
| 173 | 1 | ▶ | sub clear { |
|
Subroutine
clear: called CC=1 SCAR=0.0
Pod
documented
| |||
| 174 | 1 | my ($self) = @_; | |
| 175 | 1 | $self->inc->clear; | |
| 176 | 1 | return; | |
| 177 | } | ||
| 178 | |||
| 179 | 4 | 1; | |
| 180 | |||
| 181 | __END__ | ||