DESCRIPTION

Test::Inline::IO::File is the default \s-1IO\s0 handler for Test::Inline.

Test::Inline 2.0 was conceived in an enterprise setting, and retains the flexibilty, power, and bulk that this created, although for most users the power and complexity that is available is largely hidden away under multiple layers of sensible defaults.

The intent with the \*(C`InputHandler\*(C' and \*(C`OutputHandle\*(C' parameters is to allow Test::Inline to be able to pull source data from anywhere, and write the resulting test scripts to anywhere.

Until a more powerful pure-OO file-system \s-1API\s0 comes along, this module serves as a minimalist implementation of the subset of functionality that Test::Inline needs in order to work.

An alternative \s-1IO\s0 Handler class need not subclass this one (although it is recommended), merely implement the same interface, taking whatever alternative arguments to the \*(C`new\*(C' constructor that it wishes.

All methods in this class are provided with unix-style paths, and should do the translating to the underlying filesystem themselves if required.

METHODS

new

  # Simplified usage
  $io_handler = Test::Inline::IO::File->new( $path );

  # Full key/value usage
  $io_handler = Test::Inline::IO::File->new(
          path     => $path,
          readonly => 1,
  );

The \*(C`new\*(C' constructor takes a root path on the local filesystem and returns a new \*(C`Test::Inline::IO::File\*(C' object to that location. The \*(C`exists_file\*(C' method checks to see if a particular file currently exists in the input handler.

Returns true if it exists, or false if not. The \*(C`exists_dir\*(C' method checks to see if a particular directory currently exists in the input handler.

Returns true if it exists, or false if not. The \*(C`read\*(C' method reads in the entire contents of a single file, returning it as a reference to a \s-1SCALAR\s0. It also localises the newlines as it does this, so files from different operating systems should read as you expect.

Returns a \s-1SCALAR\s0 reference, or \*(C`undef\*(C' on error. The \*(C`write\*(C' method writes a string to a file in one hit, creating it and it's path if needed. Assuming your input FileHandler is pointing at the root directory of a lib path (meaning that My::Module will be located at My/Module.pm within it) the \*(C`class_file\*(C' method will take a class name, and check to see if the file for that class exists in the FileHandler.

Returns a reference to an \s-1ARRAY\s0 containing the filename if it exists, or \*(C`undef\*(C' on error. The \*(C`find\*(C' method takes as argument a directory root class, and then scans within the input FileHandler to find all files contained in that class or any other classes under it's namespace.

Returns a reference to an \s-1ARRAY\s0 containing all the files within the class, or \*(C`undef\*(C' on error.

TO DO

- Convert to using FSI::FileSystem objects, once they exist

SUPPORT

See the main \s-1SUPPORT\s0 section.

AUTHOR

Adam Kennedy <[email protected]>, <http://ali.as/>

COPYRIGHT

Copyright 2004 - 2013 Adam Kennedy.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the \s-1LICENSE\s0 file included with this module.