Cindy-Apache2

 view release on metacpan or  search on metacpan

lib/Cindy/Apache2.pm  view on Meta::CPAN

  print $out->toStringHTML();

  dump_xpath_profile();

  return Apache2::Const::OK;
}

#
# Read data of the given kind into a stringref
#
sub read_subrequest($$$;$)
{
  my ($r, $what, $rtext, $rtype) = @_;
  my $rsub = lookup_by_env($r, $what);
  if (!defined($rsub)) {
    return Apache2::Const::HTTP_NOT_FOUND;
  }
  my $rv = $rsub->run_trapped($rtext);
  if ($rv != Apache2::Const::OK) {
    return $rv;
  }

lib/Cindy/Apache2.pm  view on Meta::CPAN

  }
  copy_mtime($rsub, $r);
  
  return Apache2::Const::OK;
}

#
# Reads a subrequests LastModified header and sets it
# for the main request 
#
sub copy_mtime($$)
{
  my ($from, $to) = @_;
  # If no mtime is available 
  # we asume the document has just 
  # been created.
  my $mtime = $from->mtime || time; 
  $to->update_mtime($mtime);
}

#
# return An apache subrequest object
# 
sub lookup_by_env($$)
{
  my ($r, $pname) = @_;

  my $rtn;
  my $env_file = $r->subprocess_env("CINDY_$pname"."_FILE");
  if ($env_file) {
    DEBUG "Looking up '$env_file' for $pname."; 
    $rtn = $r->lookup_file($env_file);
  }

lib/Cindy/Apache2.pm  view on Meta::CPAN

  } else {
    DEBUG "Lookup succeeded for '$env_x' for $pname."; 
  }

  return $rtn;     
}

#
# return An XML:LibXML root node.
# 
sub parse_by_type($$$)
{
  my ($type, $text, $what) = @_;

  my $rtn;

  eval {
    if ($type =~ m/html/io) {
      my %opt = (no_implied => 1,
                 # We do not want this module 
                 # to add a DOCTYPE.

t/lib/My/TestHelper.pm  view on Meta::CPAN

use warnings;
use base 'Exporter';
use Test::Builder;
use FileHandle;

our @EXPORT_OK = qw(cmp_file_ok read_file);

my $Test = Test::Builder->new;

# compare string to a file's contents
sub cmp_file_ok($$;$) {
    my ($got, $file, $desc) = @_;

    unless (-e $file and -r $file) {
        $Test->ok(0, $desc);
        $Test->diag("$file not found or not readable");
        return 0;
    }

    my $ok = 0;

t/lib/My/TestHelper.pm  view on Meta::CPAN

        # ignore whitespace differences
        $expected =~ s/[\r\n\s\t]//g;
        $got      =~ s/[\r\n\s\t]//g;

        return $Test->is_eq($got, $expected);
    }

    return $ok;
}

sub read_file($) {
    my $file = shift;

    local $/ = undef;

    my $fh = FileHandle->new("<$file") or return;

    my $data = <$fh>;

    return $data;
}



( run in 0.532 second using v1.01-cache-2.11-cpan-1f129e94a17 )