line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::EditorTools::Command::RenamePackageFromPath; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Rename the package based on the file's path |
4
|
|
|
|
|
|
|
|
5
|
7
|
|
|
7
|
|
7098
|
use strict; |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
268
|
|
6
|
7
|
|
|
7
|
|
39
|
use warnings; |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
201
|
|
7
|
7
|
|
|
7
|
|
1170
|
use Path::Class; |
|
7
|
|
|
|
|
48835
|
|
|
7
|
|
|
|
|
440
|
|
8
|
|
|
|
|
|
|
|
9
|
7
|
|
|
7
|
|
41
|
use App::EditorTools -command; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
52
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.00'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub opt_spec { |
14
|
3
|
|
|
3
|
1
|
33086
|
return ( [ "filename|f=s", "The filename and path of the package", ] ); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub validate_args { |
18
|
3
|
|
|
3
|
1
|
1652
|
my ( $self, $opt, $args ) = @_; |
19
|
3
|
50
|
|
|
|
25
|
$self->usage_error("Filename is required") unless $opt->{filename}; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# If we are dealing with a real file, see if we can clean up the |
22
|
|
|
|
|
|
|
# path. This let's us work on files under a symlink |
23
|
|
|
|
|
|
|
# (ie, M/ -> lib/App/Model), but rename them correctly. |
24
|
3
|
100
|
|
|
|
73
|
if( -f $opt->{filename} ){ |
25
|
2
|
|
|
|
|
10
|
my $real_name = file( $opt->{filename} )->resolve; |
26
|
2
|
50
|
|
|
|
1106
|
$opt->{filename} = $real_name if defined $real_name; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
3
|
|
|
|
|
9
|
return 1; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub execute { |
33
|
3
|
|
|
3
|
1
|
13
|
my ( $self, $opt, $arg ) = @_; |
34
|
|
|
|
|
|
|
|
35
|
3
|
|
|
|
|
5
|
my $doc_as_str = eval { local $/ = undef; }; |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
23
|
|
36
|
|
|
|
|
|
|
|
37
|
3
|
|
|
|
|
749
|
require PPIx::EditorTools::RenamePackageFromPath; |
38
|
3
|
|
|
|
|
137882
|
print PPIx::EditorTools::RenamePackageFromPath->new->rename( |
39
|
|
|
|
|
|
|
code => $doc_as_str, |
40
|
|
|
|
|
|
|
filename => $opt->{filename} )->code; |
41
|
3
|
|
|
|
|
7167
|
return; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |