Perl 5 version documentation

TAP::Parser::Source

NAME

TAP::Parser::Source - a TAP source & meta data about it

VERSION

Version 3.42

SYNOPSIS

  1. use TAP::Parser::Source;
  2. my $source = TAP::Parser::Source->new;
  3. $source->raw( \'reference to raw TAP source' )
  4. ->config( \%config )
  5. ->merge( $boolean )
  6. ->switches( \@switches )
  7. ->test_args( \@args )
  8. ->assemble_meta;
  9. do { ... } if $source->meta->{is_file};
  10. # see assemble_meta for a full list of data available

DESCRIPTION

A TAP source is something that produces a stream of TAP for the parser to consume, such as an executable file, a text file, an archive, an IO handle, a database, etc. TAP::Parser::Source s encapsulate these raw sources, and provide some useful meta data about them. They are used by TAP::Parser::SourceHandlers, which do whatever is required to produce & capture a stream of TAP from the raw source, and package it up in a TAP::Parser::Iterator for the parser to consume.

Unless you're writing a new TAP::Parser::SourceHandler, a plugin or subclassing TAP::Parser, you probably won't need to use this module directly.

METHODS

Class Methods

new

  1. my $source = TAP::Parser::Source->new;

Returns a new TAP::Parser::Source object.

Instance Methods

raw

  1. my $raw = $source->raw;
  2. $source->raw( $some_value );

Chaining getter/setter for the raw TAP source. This is a reference, as it may contain large amounts of data (eg: raw TAP).

meta

  1. my $meta = $source->meta;
  2. $source->meta({ %some_value });

Chaining getter/setter for meta data about the source. This defaults to an empty hashref. See assemble_meta for more info.

has_meta

True if the source has meta data.

config

  1. my $config = $source->config;
  2. $source->config({ %some_value });

Chaining getter/setter for the source's configuration, if any has been provided by the user. How it's used is up to you. This defaults to an empty hashref. See config_for for more info.

merge

  1. my $merge = $source->merge;
  2. $source->config( $bool );

Chaining getter/setter for the flag that dictates whether STDOUT and STDERR should be merged (where appropriate). Defaults to undef.

switches

  1. my $switches = $source->switches;
  2. $source->config([ @switches ]);

Chaining getter/setter for the list of command-line switches that should be passed to the source (where appropriate). Defaults to undef.

test_args

  1. my $test_args = $source->test_args;
  2. $source->config([ @test_args ]);

Chaining getter/setter for the list of command-line arguments that should be passed to the source (where appropriate). Defaults to undef.

assemble_meta

  1. my $meta = $source->assemble_meta;

Gathers meta data about the raw source, stashes it in meta and returns it as a hashref. This is done so that the TAP::Parser::SourceHandlers don't have to repeat common checks. Currently this includes:

  1. is_scalar => $bool,
  2. is_hash => $bool,
  3. is_array => $bool,
  4. # for scalars:
  5. length => $n
  6. has_newlines => $bool
  7. # only done if the scalar looks like a filename
  8. is_file => $bool,
  9. is_dir => $bool,
  10. is_symlink => $bool,
  11. file => {
  12. # only done if the scalar looks like a filename
  13. basename => $string, # including ext
  14. dir => $string,
  15. ext => $string,
  16. lc_ext => $string,
  17. # system checks
  18. exists => $bool,
  19. stat => [ ... ], # perldoc -f stat
  20. empty => $bool,
  21. size => $n,
  22. text => $bool,
  23. binary => $bool,
  24. read => $bool,
  25. write => $bool,
  26. execute => $bool,
  27. setuid => $bool,
  28. setgid => $bool,
  29. sticky => $bool,
  30. is_file => $bool,
  31. is_dir => $bool,
  32. is_symlink => $bool,
  33. # only done if the file's a symlink
  34. lstat => [ ... ], # perldoc -f lstat
  35. # only done if the file's a readable text file
  36. shebang => $first_line,
  37. }
  38. # for arrays:
  39. size => $n,

shebang

Get the shebang line for a script file.

  1. my $shebang = TAP::Parser::Source->shebang( $some_script );

May be called as a class method

config_for

  1. my $config = $source->config_for( $class );

Returns config for the $class given. Class names may be fully qualified or abbreviated, eg:

  1. # these are equivalent
  2. $source->config_for( 'Perl' );
  3. $source->config_for( 'TAP::Parser::SourceHandler::Perl' );

If a fully qualified $class is given, its abbreviated version is checked first.

AUTHORS

Steve Purkis.

SEE ALSO

TAP::Object, TAP::Parser, TAP::Parser::IteratorFactory, TAP::Parser::SourceHandler