File: DirHandle.pm

package info (click to toggle)
libtest-mockfile-perl 0.037-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 436 kB
  • sloc: perl: 4,110; makefile: 7
file content (112 lines) | stat: -rw-r--r-- 2,393 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# Copyright (c) 2018, cPanel, LLC.
# All rights reserved.
# http://cpanel.net
#
# This is free software; you can redistribute it and/or modify it under the
# same terms as Perl itself. See L<perlartistic>.

package Test::MockFile::DirHandle;

use strict;
use warnings;

our $VERSION = '0.037';

=head1 NAME

Test::MockFile::DirHandle - Provides a class object for
L<Test::MockFile> to give out for opendir calls.

=head1 VERSION

Version 0.037

=cut

=head1 SYNOPSIS

This is a helper class for L<Test::MockFile> its only purpose is to
provide a object to recognize that a the passed handle is a mocked
handle. L<Test::MockFile> has to mock the other calls since there is no
tie for B<opendir> handles.

    # This is what Test::MockFile does. You really shouldn't be doing it directly.
    use Test::MockFile::DirHandle;
    my $handle = Test::MockFile::DirHandle->new("/fake/path", [qw/. .. a bbb ccc dd/]);

=head1 EXPORT

No exports are provided by this module.

=head1 SUBROUTINES/METHODS

=head2 new

Args: ($class, $dir, $files_array_ref)

Returns a blessed object for Test::MockFile::DirHandle. There are no
error conditions handled here.

B<NOTE:> the permanent directory contents are stored in a hash in
Test::MockFile. However when opendir is called, a copy is stored here.
This is because through experimentation, we've determined that adding
files in a dir during a opendir/readdir does not affect the return of
readdir.

See L<Test::MockFile>.

=cut

sub new {
    my ( $class, $dir, $files_in_readdir ) = @_;

    return bless {
        files_in_readdir => $files_in_readdir,
        'dir'            => $dir,
        'tell'           => 0,
    }, $class;
}

=head1 AUTHOR

Todd Rinaldo, C<< <toddr at cpan.org> >>

=head1 BUGS

Please report any bugs or feature requests to
L<https://github.com/CpanelInc/Test-MockFile>.

=head1 SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Test::MockFile::DirHandle

You can also look for information at:

=over 4

=item * CPAN Ratings

L<https://cpanratings.perl.org/d/Test-MockFile>

=item * Search CPAN

L<https://metacpan.org/release/Test-MockFile>

=back

=head1 LICENSE AND COPYRIGHT

Copyright 2018 cPanel L.L.C.

All rights reserved.

L<http://cpanel.net>

This is free software; you can redistribute it and/or modify it under
the same terms as Perl itself. See L<perlartistic>.

=cut

1;