line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
package Goo::Thing::pm::ProgramDeleter; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
############################################################################### |
5
|
|
|
|
|
|
|
# Nigel Hamilton |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# Copyright Nigel Hamilton 2005 |
8
|
|
|
|
|
|
|
# All Rights Reserved |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# Author: Nigel Hamilton |
11
|
|
|
|
|
|
|
# Filename: ProgramDeleter.pm |
12
|
|
|
|
|
|
|
# Description: Add stuff to a program |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# Date Change |
15
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------- |
16
|
|
|
|
|
|
|
# 01/08/2005 Factored out of ProgramEditor as part of the new Goo |
17
|
|
|
|
|
|
|
# 11/08/2005 Added method: testIt |
18
|
|
|
|
|
|
|
# |
19
|
|
|
|
|
|
|
############################################################################## |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
10999
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
1
|
|
6
|
use Goo::Object; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
24
|
1
|
|
|
1
|
|
6
|
use Goo::Loader; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
23
|
|
25
|
1
|
|
|
1
|
|
6
|
use Goo::Prompter; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
26
|
1
|
|
|
1
|
|
392
|
use Goo::FileDeleter; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
use Goo::Thing::pm::PerlCoder; |
28
|
|
|
|
|
|
|
use Goo::Thing::pm::ProgramProfiler; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
use base qw(Object); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
############################################################################### |
34
|
|
|
|
|
|
|
# |
35
|
|
|
|
|
|
|
# delete_package - delete a specific package |
36
|
|
|
|
|
|
|
# |
37
|
|
|
|
|
|
|
############################################################################### |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub delete_package { |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my ($this, $filename, $package) = @_; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
if (Goo::Prompter::confirm("Delete $package from this program?")) { |
44
|
|
|
|
|
|
|
my $pc = Goo::Thing::pm::PerlCoder->new( { filename => $filename } ); |
45
|
|
|
|
|
|
|
$pc->delete_package($package); |
46
|
|
|
|
|
|
|
$pc->save(); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# delete the actual package as well? |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
############################################################################### |
54
|
|
|
|
|
|
|
# |
55
|
|
|
|
|
|
|
# delete_method - delete a specific method |
56
|
|
|
|
|
|
|
# |
57
|
|
|
|
|
|
|
############################################################################### |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub delete_method { |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
my ($this, $filename, $method) = @_; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
if (Goo::Prompter::confirm("Delete method $method?")) { |
64
|
|
|
|
|
|
|
my $pc = Goo::Thing::pm::PerlCoder->new( { filename => $filename } ); |
65
|
|
|
|
|
|
|
$pc->delete_method($method); |
66
|
|
|
|
|
|
|
$pc->save(); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# delete in backlinks too? |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
############################################################################### |
75
|
|
|
|
|
|
|
# |
76
|
|
|
|
|
|
|
# run - keep adding a thing to the program |
77
|
|
|
|
|
|
|
# |
78
|
|
|
|
|
|
|
############################################################################### |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub run { |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
my ($this, $thing, $option) = @_; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
unless ($option) { |
85
|
|
|
|
|
|
|
$option = Goo::Prompter::ask_for_key("Delete?"); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
my $profile = Goo::Thing::pm::ProgramProfiler->new($thing); |
89
|
|
|
|
|
|
|
$profile->generate_profile($thing); |
90
|
|
|
|
|
|
|
my $option = $profile->get_option($option); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
if ($option->isa("Goo::Thing::pm::PackageProfileOption")) { |
93
|
|
|
|
|
|
|
$this->delete_package($thing->get_filename(), $option->{text}); |
94
|
|
|
|
|
|
|
# delete the actual package? |
95
|
|
|
|
|
|
|
return; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
} elsif ($option->isa("Goo::Thing::pm::MethodProfileOption")) { |
98
|
|
|
|
|
|
|
$this->delete_method($thing->get_filename(), $option->{text}); |
99
|
|
|
|
|
|
|
# delete backlinks to this method? |
100
|
|
|
|
|
|
|
return; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
} elsif ($option->isa("Goo::ThingProfileOption")) { |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# use the file delete to delete this |
105
|
|
|
|
|
|
|
my $new_thing = Goo::Loader::load($option->{text}); |
106
|
|
|
|
|
|
|
my $deleter = Goo::FileDeleter->new(); |
107
|
|
|
|
|
|
|
$deleter->run($new_thing); |
108
|
|
|
|
|
|
|
return; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
1; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
__END__ |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 NAME |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Goo::Thing::pm::ProgramDeleter - Delete stuff from a program |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 SYNOPSIS |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
use Goo::Thing::pm::ProgramDeleter; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 DESCRIPTION |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
WARNING: Use with care. This needs to delegate correctly to either a Perl6Deleter or a Perl5Deleter. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 METHODS |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=over |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=item delete_package |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
delete a specific package |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item delete_method |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
delete a specific method |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item run |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
keep adding a thing to the program |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=back |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 AUTHOR |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Nigel Hamilton <nigel@trexy.com> |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 SEE ALSO |
154
|
|
|
|
|
|
|
|