| 1 | package PPI::Token::Data; | ||||||||||
| 2 | |||||||||||
| 3 | =pod | ||||||||||
| 4 | |||||||||||
| 5 | =head1 NAME | ||||||||||
| 6 | |||||||||||
| 7 | PPI::Token::Data - The actual data in the __DATA__ section of a file | ||||||||||
| 8 | |||||||||||
| 9 | =head1 INHERITANCE | ||||||||||
| 10 | |||||||||||
| 11 | PPI::Token::Data | ||||||||||
| 12 | isa PPI::Token | ||||||||||
| 13 | isa PPI::Element | ||||||||||
| 14 | |||||||||||
| 15 | =head1 DESCRIPTION | ||||||||||
| 16 | |||||||||||
| 17 | The C<PPI::Token::Data> class is used to represent the actual data inside | ||||||||||
| 18 | a file's C<__DATA__> section. | ||||||||||
| 19 | |||||||||||
| 20 | One C<PPI::Token::Data> object is used to represent the entire of the data, | ||||||||||
| 21 | primarily so that it can provide a convenient handle directly to the data. | ||||||||||
| 22 | |||||||||||
| 23 | =head1 METHODS | ||||||||||
| 24 | |||||||||||
| 25 | C<PPI::Token::Data> provides one method in addition to those provided by | ||||||||||
| 26 | our parent L<PPI::Token> and L<PPI::Element> classes. | ||||||||||
| 27 | |||||||||||
| 28 | =cut | ||||||||||
| 29 | |||||||||||
| 30 | 63 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 31 | 63 | ▶ | use IO::String 1.07 (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 32 | 63 | ▶ | use PPI::Token (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 33 | |||||||||||
| 34 | 63 | our $VERSION = '1.260'; # VERSION | |||||||||
| 35 | |||||||||||
| 36 | 63 | our @ISA = "PPI::Token"; | |||||||||
| 37 | |||||||||||
| 38 | |||||||||||
| 39 | |||||||||||
| 40 | |||||||||||
| 41 | |||||||||||
| 42 | ##################################################################### | ||||||||||
| 43 | # Methods | ||||||||||
| 44 | |||||||||||
| 45 | =pod | ||||||||||
| 46 | |||||||||||
| 47 | =head2 handle | ||||||||||
| 48 | |||||||||||
| 49 | The C<handle> method returns a L<IO::String> handle that allows you | ||||||||||
| 50 | to do all the normal handle-y things to the contents of the __DATA__ | ||||||||||
| 51 | section of the file. | ||||||||||
| 52 | |||||||||||
| 53 | Unlike in perl itself, this means you can also do things like C<print> | ||||||||||
| 54 | new data onto the end of the __DATA__ section, or modify it with | ||||||||||
| 55 | any other process that can accept an L<IO::Handle> as input or output. | ||||||||||
| 56 | |||||||||||
| 57 | Returns an L<IO::String> object. | ||||||||||
| 58 | |||||||||||
| 59 | =cut | ||||||||||
| 60 | |||||||||||
| 61 | sub handle { | ||||||||||
| 62 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
handle: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 63 | 1 | IO::String->new( \$self->{content} ); | |||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | sub __TOKENIZER__on_line_start { | ||||||||||
| 67 | 6 | ▶ | my ( $self, $t ) = @_; | ||||||||
|
Subroutine
__TOKENIZER__on_line_start: called CC=3 SCAR=11.0
| |||||||||||
| 68 | |||||||||||
| 69 | # Add the line | ||||||||||
| 70 | 6 | ▶ | if ( defined $t->{token} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 71 | 3 | $t->{token}->{content} .= $t->{line}; | |||||||||
| 72 | } | ||||||||||
| 73 | else { | ||||||||||
| 74 | 3 | ▶ | defined( $t->{token} = $t->{class}->new( $t->{line} ) ) or return undef; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 75 | } | ||||||||||
| 76 | |||||||||||
| 77 | 6 | return 0; | |||||||||
| 78 | } | ||||||||||
| 79 | |||||||||||
| 80 | 63 | 1; | |||||||||
| 81 | |||||||||||
| 82 | =pod | ||||||||||
| 83 | |||||||||||
| 84 | =head1 SUPPORT | ||||||||||
| 85 | |||||||||||
| 86 | See the L<support section|PPI/SUPPORT> in the main module. | ||||||||||
| 87 | |||||||||||
| 88 | =head1 AUTHOR | ||||||||||
| 89 | |||||||||||
| 90 | Adam Kennedy E<lt>adamk@cpan.orgE<gt> | ||||||||||
| 91 | |||||||||||
| 92 | =head1 COPYRIGHT | ||||||||||
| 93 | |||||||||||
| 94 | Copyright 2001 - 2011 Adam Kennedy. | ||||||||||
| 95 | |||||||||||
| 96 | This program is free software; you can redistribute | ||||||||||
| 97 | it and/or modify it under the same terms as Perl itself. | ||||||||||
| 98 | |||||||||||
| 99 | The full text of the license can be found in the | ||||||||||
| 100 | LICENSE file included with this module. | ||||||||||
| 101 | |||||||||||
| 102 | =cut | ||||||||||