Debian Codegraph @

lib/Test2/Harness/Util/File/Value.pm

raw
1 package Test2::Harness::Util::File::Value;
2 use strict;
3 use warnings;
4
5 our $VERSION = '1.000179';
6
7 use parent 'Test2::Harness::Util::File';
8 use Test2::Harness::Util::HashBase;
9
10 sub init {
11 my $self = shift;
12 $self->{+DONE} = 1;
13 }
14
15 sub read {
16 my $self = shift;
17 my $out = $self->SUPER::read(@_);
18 chomp($out) if defined $out;
19 return $out;
20 }
21
22 sub read_line {
23 my $self = shift;
24 my $out = $self->SUPER::read_line(@_);
25 chomp($out) if defined $out;
26 return $out;
27 }
28
29 1;
30
31 __END__
32
33 =pod
34
35 =encoding UTF-8
36
37 =head1 NAME
38
39 Test2::Harness::Util::File::Value - Utility class for a file that contains
40 exactly 1 value.
41
42 =head1 DESCRIPTION
43
44 This is a subclass of L<Test2::Harness::Util::File> for files expected to have
45 exactly 1 value stored in them.
46
47 =head1 SYNOPSIS
48
49 use Test2::Harness::Util::File::Value;
50
51 my $vf = Test2::Harness::Util::File::Value->new(name => 'path/to/file');
52 my $val = $vf->read;
53
54 =head1 METHODS
55
56 =over 4
57
58 =item $val = $vf->read()
59
60 Read all contents from the file, C<chomp()> it, and return it.
61
62 =item $val = $vf->read_line()
63
64 Read the first line from the file, C<chomp()> it, and return it. Note, this
65 may not return anything if the value in the file does not terminate with a
66 newline.
67
68 =back
69
70 =head1 SOURCE
71
72 The source code repository for Test2-Harness can be found at
73 F<http://github.com/Test-More/Test2-Harness/>.
74
75 =head1 MAINTAINERS
76
77 =over 4
78
79 =item Chad Granum E<lt>[email protected]<gt>
80
81 =back
82
83 =head1 AUTHORS
84
85 =over 4
86
87 =item Chad Granum E<lt>[email protected]<gt>
88
89 =back
90
91 =head1 COPYRIGHT
92
93 Copyright 2020 Chad Granum E<lt>[email protected]<gt>.
94
95 This program is free software; you can redistribute it and/or
96 modify it under the same terms as Perl itself.
97
98 See F<http://dev.perl.org/licenses/>
99
100 =cut