logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Test2::Harness::Util::File::Stream - Utility class for manipulating a file that serves as an output

Attributes

       See Test2::Harness::File for additional attributes.

       These can be passed in as construction arguments if desired.

       $bool = $stream->use_write_lock
       $stream->use_write_lock($bool)
           Lock the file for every write() operation.

       $bool = $stream->tail
           Start near the end of the file and only poll for updates appended to it.

Authors

       Chad Granum <exodist@cpan.org>

Description

       Subclass of Test2::Harness::File that streams the contents of a file, even if the file is still being
       written.

Maintainers

       Chad Granum <exodist@cpan.org>

Methods

       See Test2::Harness::File for additional methods.

       @lines = $stream->read()
           Read all lines from the beginning. Every time it is called it returns ALL lines.

       @lines = $stream->poll()
       @lines = $stream->poll(max => $int)
           Poll  for lines. This is an iterator, it should not return the same line more than once, you can call
           it multiple times to get any additional lines that have been added since the last poll.

       $stream->write(@content)
           Append @content to the file.

Name

       Test2::Harness::Util::File::Stream - Utility class for manipulating a file that serves as an output
       stream.

Source

       The source code repository for Test2-Harness can be found at http://github.com/Test-More/Test2-Harness/.

Synopsis

           use Test2::Harness::Util::File::Stream;

           my $stream = Test2::Harness::Util::File::Stream->new(name => 'path/to/file');

           # Read some lines
           my @lines = $stream->poll;

           ...

           # Read more lines, if any.
           push @lines => $stream->poll;

See Also