line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Goo::Thing::pm::Perl5Adder; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
############################################################################### |
6
|
|
|
|
|
|
|
# Nigel Hamilton |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# Copyright Nigel Hamilton 2005 |
9
|
|
|
|
|
|
|
# All Rights Reserved |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
# Author: Nigel Hamilton |
12
|
|
|
|
|
|
|
# Filename: Perl5Adder.pm |
13
|
|
|
|
|
|
|
# Description: Add stuff to a program |
14
|
|
|
|
|
|
|
# |
15
|
|
|
|
|
|
|
# Date Change |
16
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------- |
17
|
|
|
|
|
|
|
# 01/08/2005 Factored out of ProgramEditor as part of the new Goo |
18
|
|
|
|
|
|
|
# 09/08/2005 This is the first change that has been automatically added. |
19
|
|
|
|
|
|
|
# 09/08/2005 Added the function that enables me to added changes like this. We |
20
|
|
|
|
|
|
|
# also need to test the line wrapping. Does it do a good job of |
21
|
|
|
|
|
|
|
# retaining the columns? |
22
|
|
|
|
|
|
|
# 09/08/2005 I really like the way it handles automated dates - cool! |
23
|
|
|
|
|
|
|
# |
24
|
|
|
|
|
|
|
############################################################################## |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
1
|
|
17832
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
44
|
|
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
1
|
|
7
|
use Goo::Object; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
29
|
1
|
|
|
1
|
|
7
|
use Goo::Prompter; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
30
|
1
|
|
|
1
|
|
8
|
use Goo::Thing::pm::PerlCoder; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
30
|
|
31
|
1
|
|
|
1
|
|
8
|
use Goo::Thing::pm::MethodMaker; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
1
|
|
6
|
use base qw(Goo::Object); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
359
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
############################################################################### |
37
|
|
|
|
|
|
|
# |
38
|
|
|
|
|
|
|
# run - keep adding a thing to the program |
39
|
|
|
|
|
|
|
# |
40
|
|
|
|
|
|
|
############################################################################### |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub run { |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
0
|
1
|
|
my ($this, $thing, $option) = @_; |
45
|
|
|
|
|
|
|
|
46
|
0
|
0
|
|
|
|
|
unless ($option) { |
47
|
0
|
|
|
|
|
|
$option = Goo::Prompter::pick_command("[M]ethod, [C]hange Log or [P]ackage", "M"); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
my $pc = Goo::Thing::pm::PerlCoder->new({ filename => $thing->get_full_path() |
51
|
|
|
|
|
|
|
}); |
52
|
|
|
|
|
|
|
|
53
|
0
|
0
|
|
|
|
|
if ($option eq "P") { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my @packages = Goo::Prompter::keep_asking("Add a package?"); |
56
|
0
|
|
|
|
|
|
foreach my $package (@packages) { |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# keep adding packages to the program |
59
|
0
|
|
|
|
|
|
$pc->add_package($package); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
} elsif ($option eq "M") { |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
my $mm = Goo::Thing::pm::MethodMaker->new(); |
65
|
0
|
|
|
|
|
|
foreach my $method ($mm->generate_methods()) { |
66
|
0
|
|
|
|
|
|
$pc->add_method($method); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
} elsif ($option eq "C") { |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
my $change = Goo::Prompter::ask("Describe a change:"); |
72
|
0
|
|
|
|
|
|
$pc->add_change_log($change); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# save any code changes |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
} else { |
77
|
0
|
|
|
|
|
|
Goo::Prompter::notify("Nothing added."); |
78
|
0
|
|
|
|
|
|
return; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
$pc->save(); |
82
|
0
|
|
|
|
|
|
return; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
__END__ |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 NAME |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Goo::Thing::pm::Perl5Adder - Add stuff to a Perl5 program |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 SYNOPSIS |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
use Goo::Thing::pm::Perl5Adder; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 DESCRIPTION |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 METHODS |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=over |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item run |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Action handler for adding methods, packages or change log entries to a Perl5 program (i.e., |
111
|
|
|
|
|
|
|
[A]dd). |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=back |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 AUTHOR |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Nigel Hamilton <nigel@trexy.com> |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 SEE ALSO |
120
|
|
|
|
|
|
|
|