File Coverage

blib/lib/Goo/Thing/pm/Perl6Editor.pm
Criterion Covered Total %
statement 36 51 70.5
branch 0 4 0.0
condition n/a
subroutine 12 13 92.3
pod 1 1 100.0
total 49 69 71.0


line stmt bran cond sub pod time code
1             package Goo::Thing::pm::Perl6Editor;
2              
3             ###############################################################################
4             # Nigel Hamilton
5             #
6             # Copyright Nigel Hamilton 2005
7             # All Rights Reserved
8             #
9             # Author: Nigel Hamilton
10             # Filename: Goo::Thing::pm::Perl6Editor.pm
11             # Description: Edit a program interactively as fast as possible
12             #
13             # Date Change
14             # -----------------------------------------------------------------------------
15             # 15/02/2005 Auto generated file
16             # 15/02/2005 Wanted to boost my code-cutting productivity and accuracy
17             # Other things to add - renaming methods automatically changes
18             # tests and 'link backs' from other modules
19             # 16/02/2005 Added deleteMethod method - this is a bit of a mind bend!
20             # 05/05/2005 Added a TypeLessTranslator to make typing quicker - think
21             # phone txt 4 code! The idea is write shrt read looonger.
22             # 01/07/2005 Integrated new model of "Things"
23             # 01/08/2005 New command-based system caused massive refactoring of this
24             # module. It used a whopping 16 other modules - crazy!
25             # 07/08/2005 Want to add ThereDocs back into the mix
26             # 17/08/2005 Added method: doTypeLessTranslation
27             # 17/08/2005 Added method: doThereDoc
28             # 02/11/2005 Now returns to the location of the original ThereDoc
29             # Handles all actions a Thing can do: e > > p > > l > >
30             # 03/11/2005 Preparing for CPAN alpha release
31             #
32             ###############################################################################
33              
34 1     1   16118 use strict;
  1         4  
  1         50  
35              
36 1     1   7 use Data::Dumper;
  1         3  
  1         66  
37              
38             # top level utility functions
39 1     1   6 use Goo::Differ;
  1         3  
  1         32  
40 1     1   5 use Goo::Object;
  1         4  
  1         19  
41 1     1   6 use Goo::Prompter;
  1         1  
  1         91  
42 1     1   6 use Goo::TextEditor;
  1         11  
  1         28  
43 1     1   7 use Goo::FileUtilities;
  1         2  
  1         32  
44              
45             # thing specific modules
46 1     1   6 use Goo::ThereDocManager;
  1         2  
  1         20  
47 1     1   630 use Goo::Thing::pm::ExecDocManager;
  1         3  
  1         28  
48 1     1   786 use Goo::Thing::pm::PerlTidyManager;
  1         3  
  1         31  
49 1     1   549 use Goo::Thing::pm::TypeLessTranslator;
  1         3  
  1         28  
50              
51 1     1   7 use base qw(Goo::Object);
  1         2  
  1         291  
52              
53              
54             ###############################################################################
55             #
56             # run - edit a program
57             #
58             ###############################################################################
59              
60             sub run {
61              
62 0     0 1   my ($this, $thing, $line_number) = @_;
63              
64             # continuously edit if they use ThereDocs
65 0           while (1) {
66              
67             #my @old_file = FileUtilities::getFileAsLines($thing->get_full_path());
68              
69             # clear the page
70 0           Goo::Prompter::clear();
71              
72             # can we write to this Thing?
73 0 0         unless (-W $thing->get_full_path()) {
74              
75             # just view the file then
76 0           Goo::TextEditor::view($thing->get_full_path(), $line_number);
77 0           last;
78              
79             }
80              
81             # edit the file
82 0           Goo::TextEditor::edit($thing->get_full_path(), $line_number);
83              
84             # process any ThereDocs
85 0           my ($theredoc_line_number, $target_thing, $target_action, $target_line_number) =
86             Goo::ThereDocManager->new()->process($thing);
87              
88             # jump out - no other action to take
89 0 0         unless ($target_thing) {
90              
91             # ok ... let's tidy this up
92             # this does mean some modules may not be tidied
93             # if a user exited at a different location
94             # does perl tidy work on perl6?
95 0           Goo::Thing::pm::PerlTidyManager::process($thing->get_full_path());
96 0           last;
97             }
98              
99 0           Goo::Prompter::notify("Looking for target thing " . Dumper($target_thing));
100              
101             # carry out the action
102 0           Goo::Prompter::notify("$target_thing->do_action($target_action, $target_line_number);");
103 0           $target_thing->do_action($target_action, $target_line_number);
104              
105             # return to the editor from where we came >>
106 0           $line_number = $theredoc_line_number;
107              
108             }
109              
110              
111             # does it contain any "execdocs"?
112             # ExecDocManager::process($thing);
113             #my @new_file = FileUtilities::getFileAsLines($thing->get_full_path());
114             #my $diff = Differ->new();
115             # take the diff
116             #$diff->diff(\@old_file, \@new_file);
117             # check for TypeLessTranslation
118             #foreach my $line_number ($diff->get_line_numbers()) {
119             # change array in place
120             # $new_file[ $line_number - 1 ] =
121             # TypeLessTranslator::translateLine($diff->get_line($line_number));
122             #
123             #}
124             # save the file
125             #FileUtilities::writeLinesAsFile($thing->get_full_path(), @new_file);
126              
127              
128             }
129              
130             1;
131              
132              
133             __END__
134              
135             =head1 NAME
136              
137             Goo::Thing::pm::Perl6Editor - Not implemented yet.
138              
139             =head1 SYNOPSIS
140              
141             use Goo::Thing::pm::Perl6Editor;
142              
143             =head1 DESCRIPTION
144              
145              
146              
147             =head1 METHODS
148              
149             =over
150              
151             =item run
152              
153             edit a Perl6 program
154              
155              
156             =back
157              
158             =head1 AUTHOR
159              
160             Nigel Hamilton <nigel@trexy.com>
161              
162             =head1 SEE ALSO
163