blib/lib/Text/UberText/Node/Text.pm

filter: Statementstmt 57.1% 16 / 28 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.1% 4 / 7 Podpod 100% 3 / 3 totaltotal 60.5% 23 / 38 CC 1 SCAR 3.6
CC
1
Cov
57%
new
2.0
process
2.0
quickReplace
2.0
CRAP 1.4
« blib/lib/Text/UberText.pm ↑ Summary Dispatch/t/1.t »
1 #
2 # Package Definition
3 #
4  
5 package Text::UberText::Node::Text;
6  
7 #
8 # Compiler Directives
9 #
10  
11 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 #
15 # Includes
16 #
17  
18 5 ▶use Text::UberText::Node;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 #
21 # Global Variables
22 #
23  
24 5 ▶use vars qw/@ISA $EscapeChar $VERSION /;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 5 $VERSION=0.95;
27  
28 # Text within a block that can be replaced with other characters
29 # An escape sequence within an UberText doc would look like this:
30 # %pc; (percent sign)
31  
32 5 $EscapeChar={
33 "lb" => "[",
34 "rb" => "]",
35 "pc" => "%",
36 "lp" => "(",
37 "rp" => ")",
38 "dq" => "\"",
39 "sq" => "'",
40 "co" => ":",
41 "sc" => ";",
42 };
43  
44  
45 #
46 # Inheritance
47 #
48  
49 5 @ISA=("Text::UberText::Node");
50  
51 #
52 # Methods
53 #
54  
55 sub new
56 0 ▶{
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
57 0 my ($class)=shift;
58 0 my ($object);
59 0 $object={};
60 0 bless ($object,$class);
61 0 $object->_init(@_);
62 0 return $object;
63 }
64  
65 sub process
66 0 ▶{
Subroutine process: not called CC=1 SCAR=6.9
Pod documented
67 0 my ($self)=shift;
68 0 $self->{output}=quickReplace($self->{input});
69 0 return;
70 }
71  
72 sub quickReplace
73 0 ▶{
Subroutine quickReplace: not called CC=1 SCAR=6.9
Pod documented
74 0 my ($string)=shift;
75 0 $string=~s/\%(\w\w);/$EscapeChar->{$1}/g;
76 0 return $string;
77 }
78  
79 #
80 # Hidden Methods
81 #
82  
83 #
84 # Exit Block
85 #
86 5 1;
87  
88 #
89 # POD Documentation
90 #
91  
92 =head1 NAME
93  
94 Text::UberText::Node::Text - UberText Text Node
95  
96 =head1 DESCRIPTION
97  
98 The Node::Text module handles processing an UberText text segment
99 embedded within an UberText file. It is a subclass of the Text::UberText::Node
100 class.
101  
102 =head1 ESCAPE SEQUENCES
103  
104 UberText files cannot contain certain characters, as a result of which, they
105 need to be specified with escape sequences.
106  
107 Escape sequences start with a percent sign (%), and end with a semi-colon (;). Two
108 alpabetic characters in the middle specify what character they intend to replace.
109  
110 =over 4
111  
112 =item %pc;
113  
114 Percent sign (%)
115  
116 =item %dq;
117  
118 Double quote (")
119  
120 =item %sq;
121  
122 Single quote (')
123  
124 =item %co;
125  
126 Colon (:)
127  
128 =item %sc;
129  
130 Semi-colon (;)
131  
132 =item %lb;
133  
134 Left bracket ([)
135  
136 =item %rb;
137  
138 Right bracket (])
139  
140 =item %lp;
141  
142 Left parenthesis (()
143  
144 =item %rp;
145  
146 Right parenthesis ())
147  
148 =back
149  
150 =head1 METHODS
151  
152 The following methods are overriden from the Text::UberText::Node module to
153 perform specific functions on passed input.
154  
155 =over 4
156  
157 =item $node->process();
158  
159 Generates the output, replacing all escape sequences.
160  
161 =item $node->quickReplace();
162  
163 Performs the actual escape sequence replacement.
164  
165 =item $node->run();
166  
167 The run method does nothing. All processing of the text is performed before
168 the document tree is actually run.
169  
170 =back
171  
172 =head1 AUTHOR
173  
174 Chris Josephes E<lt>cpj1@visi.comE<gt>
175  
176 =head1 SEE ALSO
177  
178 L<Text::UberText::Node>,
179 L<Text::UberText::Node::Command>
180  
181 =head1 COPYRIGHT
182  
183 Copyright 2002, Chris Josephes. All rights reserved.
184 This module is free software. It may be used, redistributed,
185 and/or modified under the same terms as Perl itself.
186 ~
« blib/lib/Text/UberText.pm ↑ Summary Dispatch/t/1.t »