| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Bundle::ToolSet; | 
| 2 | 1 |  |  | 1 |  | 25225 | use ToolSet 0.99; | 
|  | 1 |  |  |  |  | 1132 |  | 
|  | 1 |  |  |  |  | 8 |  | 
| 3 | 1 |  |  | 1 |  | 40 | use base 'ToolSet'; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 132 |  | 
| 4 |  |  |  |  |  |  | our $VERSION = 0.1; | 
| 5 |  |  |  |  |  |  |  | 
| 6 | 1 |  |  | 1 |  | 255 | BEGIN{ | 
| 7 |  |  |  |  |  |  | #Extra-funky user customization here | 
| 8 |  |  |  |  |  |  | } | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | #NO USER SERVICABLE PARTS BELOW, edit POD =head1 CONTENTS | 
| 11 |  |  |  |  |  |  | my $parser = Bundle::ToolSet_Pod->new(); | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | #Permit fat commas, otherwise: parse_file( *Bundle::ToolSet_Pod::DATA ); | 
| 14 |  |  |  |  |  |  | my @LINES; | 
| 15 |  |  |  |  |  |  | while(){ | 
| 16 |  |  |  |  |  |  | s/\s*=>\s*/ /g; | 
| 17 |  |  |  |  |  |  | push @LINES, $_; | 
| 18 |  |  |  |  |  |  | } | 
| 19 |  |  |  |  |  |  | $parser->parse_lines(@LINES, undef); | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | ToolSet->export(@{$_}) for @{$parser->{module}}; | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | foreach( @{$parser->{pragma}} ){ | 
| 24 |  |  |  |  |  |  | my $toggle = pop @${_}; | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | if( $toggle eq '-' ){ | 
| 27 |  |  |  |  |  |  | ToolSet->use_pragma($_->[0], split/\s+/, $_->[1]); } | 
| 28 |  |  |  |  |  |  | elsif( $toggle eq '+' ){ | 
| 29 |  |  |  |  |  |  | ToolSet->no_pragma ($_->[0], split/\s+/, $_->[1]); } | 
| 30 |  |  |  |  |  |  | else{ | 
| 31 |  |  |  |  |  |  | warn "Something's rotten in Denmark.";  } | 
| 32 |  |  |  |  |  |  | } | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  | 1; | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | package Bundle::ToolSet_Pod; | 
| 37 |  |  |  |  |  |  | our $VERSION = 0.01; | 
| 38 | 1 |  |  | 1 |  | 11 | use base qw(Pod::Simple); | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 1217 |  | 
| 39 |  |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  | #Parser makes you do some of the heavy lifting | 
| 41 |  |  |  |  |  |  | our $MODE; | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | sub _handle_element_start { | 
| 44 | 57 |  |  | 57 |  | 10113 | my($undef, $elem) = @_; | 
| 45 | 57 | 100 |  |  |  | 198 | $MODE = 1 if $elem =~ /head1/i; | 
| 46 | 57 | 100 |  |  |  | 277 | $MODE = 0 unless $elem =~ /head1|Para/; | 
| 47 |  |  |  |  |  |  | } | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | sub _handle_text{ | 
| 50 | 68 |  |  | 68 |  | 598 | my($self, $text) = @_; | 
| 51 |  |  |  |  |  |  |  | 
| 52 | 68 | 100 | 100 |  |  | 228 | if( $MODE && $text =~ /^CONTENTS/i ){ | 
| 53 | 1 |  |  |  |  | 2 | $MODE = 2; | 
| 54 | 1 |  |  |  |  | 4 | $self->{module} = []; | 
| 55 | 1 |  |  |  |  | 3 | $self->{pragma} = []; | 
| 56 | 1 |  |  |  |  | 4 | return; | 
| 57 |  |  |  |  |  |  | } | 
| 58 | 67 | 100 |  |  |  | 223 | return unless $MODE == 2; | 
| 59 |  |  |  |  |  |  |  | 
| 60 | 4 | 50 |  |  |  | 36 | if( $text =~ | 
| 61 |  |  |  |  |  |  | /\s*             #padding | 
| 62 |  |  |  |  |  |  | ([\w:']+)        #package | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | \s*             #padding | 
| 65 |  |  |  |  |  |  | (\d*(?:\.\d+)*)? #optional version | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  | (?:              #optional comment | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | (?:              #"Comment" | 
| 70 |  |  |  |  |  |  | \s*          #padding | 
| 71 |  |  |  |  |  |  | -\s+           #delimiter | 
| 72 |  |  |  |  |  |  |  | 
| 73 |  |  |  |  |  |  | (?:            #optional extensions | 
| 74 |  |  |  |  |  |  | \s*          #padding | 
| 75 |  |  |  |  |  |  | (.*)         #import | 
| 76 |  |  |  |  |  |  | ([+-])       #no? | 
| 77 |  |  |  |  |  |  | \s*          #padding | 
| 78 |  |  |  |  |  |  | )? | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | (.+)?          #actual comment | 
| 81 |  |  |  |  |  |  | )? | 
| 82 |  |  |  |  |  |  | )? | 
| 83 |  |  |  |  |  |  | /x ){ | 
| 84 |  |  |  |  |  |  | #    print "#$text \nP<$1> V<$2> I<$3> N<$4> C<$5>\n"; | 
| 85 |  |  |  |  |  |  |  | 
| 86 |  |  |  |  |  |  | #XXX ToolSet doesn't support version specifications... | 
| 87 | 4 | 100 |  |  |  | 19 | if( $1 eq lc($1) ){ #ISA pragma | 
| 88 | 3 |  |  |  |  | 5 | push @{$self->{pragma}}, [$1, $3, $4]; | 
|  | 3 |  |  |  |  | 22 |  | 
| 89 |  |  |  |  |  |  | } | 
| 90 |  |  |  |  |  |  | else{ | 
| 91 | 1 |  |  |  |  | 5 | push @{$self->{module}}, [$1, $3]; | 
|  | 1 |  |  |  |  | 7 |  | 
| 92 |  |  |  |  |  |  | } | 
| 93 |  |  |  |  |  |  | } | 
| 94 |  |  |  |  |  |  | } | 
| 95 |  |  |  |  |  |  |  | 
| 96 |  |  |  |  |  |  | 1; | 
| 97 |  |  |  |  |  |  |  | 
| 98 |  |  |  |  |  |  | __DATA__ |