GUI.pm

filter: Statementstmt 26.4% 14 / 53 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.1% 4 / 7 Podpod 100% 3 / 3 totaltotal 28.0% 21 / 75 CC 7 SCAR 30.3
CC
7
Cov
22%
new
42.0
check
6.0
errorblank
2.0
CRAP 20.8
↑ Summary GUI/Curses.pm »
1 package Text::SpellChecker::GUI;
2  
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use ZConf::GUI;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use ZConf;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =head1 NAME
9  
10 Text::SpellChecker::GUI - Implements a user interface to Text::SpellChecker
11  
12 =head1 VERSION
13  
14 Version 0.0.2
15  
16 =cut
17  
18 2 our $VERSION = '0.0.2';
19  
20 =head1 SYNOPSIS
21  
22 use Text::SpellChecker::GUI;
23  
24 my $sg = Text::SpellChecker::GUI->new();
25 ...
26  
27 =head1 METHODS
28  
29 =head2 new
30  
31 This initilizes the object.
32  
33 =head3 args hash
34  
35 =head4 zconf
36  
37 This is the ZConf object to use. If it is not specified the one in the
38 object for zcrunner will be used. If neither zconf or zcrunner is specified,
39 a new one is created.
40  
41 =head4 zcgui
42  
43 This is the ZConf::GUI to use. If one is not specified,
44  
45  
46 =cut
47  
48 0 ▶sub new {
Subroutine new: not called CC=6 SCAR=37.4
Pod documented
49 0 my %args;
50 0 ▶ if(defined($_[1])){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[1]) 0 0 0
51 0 %args= %{$_[1]};
52 }
53  
54 0 my $self={error=>undef, errorString=>''};
55 0 bless $self;
56  
57 #initilize the ZConf::GUI object if needed
58 0 ▶ if (!defined($args{zcgui})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $args{'zcgui'}) { } 0 0 0
59 0 ▶ if (!defined($args{zconf})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $args{'zconf'}) { } 0 0 0
60 0 $self->{zg}=ZConf::GUI->new();
61 }else {
62 0 $self->{zg}=ZConf::GUI->new({zconf=>$args{zconf}});
63 }
64  
65 0 ▶ if ($self->{zg}->{error}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"zg"}{"error"}) 0 0 0
66 $self->{errorString}='Failed to initilize the ZConf::GUI object. error="'.
67 $self->{zg}->{error}.'" errorString="'
68 0 .$self->{zg}->{errorString}.'"';
69 0 $self->{error}=1;
70 0 warn('Text-SpellChecker-GUI new:1: '.$self->{errorString});
71 0 return $self;
72 }
73 }else {
74 0 $self->{zg}=$args{zcgui};
75 }
76  
77 #initilize the ZConf object if needed
78 0 ▶ if (!defined($args{zconf})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $args{'zconf'}) { } 0 0 0
79 0 $self->{zconf}=$args{zconf};
80 }else {
81 0 $self->{zconf}=$self->{zg}->{zconf};
82 }
83  
84 #as the GUI stuff is right below this module, use the module above this one
85 0 $self->{useX}=$self->{zg}->useX('Text::SpellChecker');
86  
87 0 my @preferred=$self->{zg}->which('Text::SpellChecker');
88  
89 0 my $toeval='use Text::SpellChecker::GUI::'.$preferred[0].';'."\n".
90 '$self->{be}=Text::SpellChecker::GUI::'.$preferred[0].
91 '->new({zconf=>$self->{zconf}, useX=>$self->{useX}, '.
92 'zcgui=>$self->{zg} }); return 1';
93  
94 0 my $er=eval($toeval);
95  
96 0 return $self;
97 }
98  
99 =head2 check
100  
101 This checks the specified the specified text for spelling errors.
102  
103 Only one option is taken and that is the text to be checked.
104  
105 The returned value is a hash.
106  
107 =head3 returned hash
108  
109 =head4 text
110  
111 This is the the resulting text.
112  
113 =head4 cancel
114  
115 If this is defined and true, then the user canceled the check and any changes.
116  
117 my %returned=$sg->check($text);
118 if($sg->{error}){
119 print "Error!\n";
120 }else{
121 if($returned{cancel}){
122 print "The check was canceled.";
123 }else{
124 $text=$returned{text};
125 }
126 }
127  
128 =cut
129  
130 0 ▶sub check{
Subroutine check: not called CC=2 SCAR=17.9
Pod documented
131 0 my $self=$_[0];
132 0 my $text=$_[1];
133  
134 0 $self->errorblank;
135
136 0 my %toreturn;
137  
138 0 ▶ if (!defined($self->{be})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"be"}) 0 0 0
139 0 $self->{errorString}='Backend is not initilized';
140 0 $self->{error}=2;
141 0 warn('Text-SpellChecker-GUI check:2: '.$self->{errorString});
142 0 return undef;
143 }
144  
145 0 %toreturn=$self->{be}->check($text);
146  
147 0 return %toreturn;
148 }
149  
150 =head2 errorblank
151  
152 This blanks the error storage and is only meant for internal usage.
153  
154 It does the following.
155  
156 $self->{error}=undef;
157 $self->{errorString}="";
158  
159 =cut
160  
161 #blanks the error flags
162 0 ▶sub errorblank{
Subroutine errorblank: not called CC=1 SCAR=6.9
Pod documented
163 0 my $self=$_[0];
164  
165 0 $self->{error}=undef;
166 0 $self->{errorString}="";
167  
168 0 return 1;
169 }
170  
171 =head1 ERROR CODES
172  
173 =head2 1
174  
175 Failed to initiate the object.
176  
177 =head2 2
178  
179 Backend is not initilized.
180  
181 =head1 AUTHOR
182  
183 Zane C. Bowers, C<< <vvelox at vvelox.net> >>
184  
185 =head1 BUGS
186  
187 Please report any bugs or feature requests to C<bug-text-spellchecker-gui at rt.cpan.org>, or through
188 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Text-SpellChecker-GUI>. I will be notified, and then you'll
189 automatically be notified of progress on your bug as I make changes.
190  
191  
192  
193  
194 =head1 SUPPORT
195  
196 You can find documentation for this module with the perldoc command.
197  
198 perldoc Text::SpellChecker::GUI
199  
200  
201 You can also look for information at:
202  
203 =over 4
204  
205 =item * RT: CPAN's request tracker
206  
207 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Text-SpellChecker-GUI>
208  
209 =item * AnnoCPAN: Annotated CPAN documentation
210  
211 L<http://annocpan.org/dist/Text-SpellChecker-GUI>
212  
213 =item * CPAN Ratings
214  
215 L<http://cpanratings.perl.org/d/Text-SpellChecker-GUI>
216  
217 =item * Search CPAN
218  
219 L<http://search.cpan.org/dist/Text-SpellChecker-GUI/>
220  
221 =back
222  
223  
224 =head1 ACKNOWLEDGEMENTS
225  
226  
227 =head1 COPYRIGHT & LICENSE
228  
229 Copyright 2009 Zane C. Bowers, all rights reserved.
230  
231 This program is free software; you can redistribute it and/or modify it
232 under the same terms as Perl itself.
233  
234  
235 =cut
236  
237 2 1; # End of Text::SpellChecker::GUI
↑ Summary GUI/Curses.pm »