Changeset 1649

Show
Ignore:
Timestamp:
09/02/06 06:56:05
Author:
mark
Message:

r14@travis: mark | 2006-09-01 21:13:39 +0100

added even more documentation to the Test
Base extention

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/t/TestPlagger.pm

    r1648 r1649  
    289289use File::Temp (); 
    290290 
     291 
     292=over 
     293 
     294=item interpolate 
     295 
     296Filter that replaces scalar values of the type 
     297 
     298  $foo 
     299  $foo::bar 
     300 
     301With their actual values.  But don't do backslash escaped things like 
     302 
     303  \$foo 
     304 
     305Note that you can't do this either: 
     306 
     307  ${foo} 
     308 
     309Meaning you can't use $foo like so: 
     310 
     311  BAR$fooHELLO 
     312   
     313=cut 
     314 
     315 define the interpolate filter - replace $vars with  
    291316sub interpolate { 
    292317    my $stuff = shift; 
    293     $stuff =~ s/(?<!\\)(\$[\w\:]+)/$1/eeg; 
    294     $stuff =~ s/\\\$/\$/g; 
     318     
     319    # interpert in $foo::bar to their values in the string 
     320    # (but not \$foo::bar) 
     321    $stuff =~ s/(?<!\\)     # check there's no backslash before this 
     322                (\$[\w\:]+) # look for a $var possibly with packages 
     323               /$1/eegx;    # replace it with its value 
     324 
     325    $stuff =~ s/\\\$/\$/g;  # turn the escaped \$ into $ 
     326     
    295327    $stuff; 
    296328} 
     329 
     330=item config 
     331 
     332Filter that configures plagger based on the YAML passed in. 
     333 
     334=cut 
    297335 
    298336sub config { 
    299337    my $yaml = shift; 
     338     
     339    # replace $foo values with their actual values 
    300340    $yaml = $self->interpolate($yaml); 
    301341 
     
    309349} 
    310350 
     351=item output_file 
     352 
     353Reads the file who's filename is in $main::output and returns it (failing on problems) 
     354 
     355=cut 
     356 
    311357sub output_file { 
    312358    my $output = $main::output or die "\$main::output is undefined";