Source/Base/File.pm

filter: Statementstmt 100% 21 / 21 Branchbran 50.0% 1 / 2 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 90.6% 29 / 32 CC 3 SCAR 6.4
CC
3
Cov
92%
open_handle
3.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.9
« Source.pm ↑ Summary Source/Base/RandomDevice.pm »
1 package Crypt::Random::Source::Base::File;
2 # ABSTRACT: File (or device) random data sources
3  
4 3 our $VERSION = '0.14';
5  
6 3 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 extends qw(Crypt::Random::Source::Base::Handle);
11  
12 3 ▶use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 3 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 3 has path => (
16 is => "rw",
17 required => 1,
18 );
19  
20 3 ▶sub open_handle {
Subroutine open_handle: called CC=3 SCAR=11.3
Pod documented
21 3 my ( $self, $mode ) = @_;
22  
23 3 my $file = $self->path;
24  
25 3 my $fh = IO::File->new;
26  
27 3 ▶ $fh->open($file, $mode || "r")
Branch: 1 branch
BranchTrueFalseTotal
$fh->open($file, $mode || "r") or croak("open($file): $!") 3 0 3
Condition50%1/2
$mode || 'r'
l!l
03
MC/DC0%0/1
$mode || 'r'
$mode
Truth table50%1/2
A
A= $mode
Aresult
11
00
28 or croak "open($file): $!";
29  
30 3 return $fh;
31 }
32  
33 3 1;
34  
35 =pod
36  
37 =encoding UTF-8
38  
39 =head1 NAME
40  
41 Crypt::Random::Source::Base::File - File (or device) random data sources
42  
43 =head1 VERSION
44  
45 version 0.14
46  
47 =head1 SYNOPSIS
48  
49 use Moo;
50 extends qw(Crypt::Random::Source::Base::File);
51  
52 has '+path' => (
53 default => "/foo/bar",
54 );
55  
56 =head1 DESCRIPTION
57  
58 This is a base class for file (or file like) random data sources.
59  
60 =head1 ATTRIBUTES
61  
62 =head2 path
63  
64 A required attribute, the path to the file to open.
65  
66 =head1 METHODS
67  
68 =head2 open_handle
69  
70 Uses L<IO::File> to open C<path> for reading.
71  
72 =head1 SUPPORT
73  
74 Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Crypt-Random-Source>
75 (or L<bug-Crypt-Random-Source@rt.cpan.org|mailto:bug-Crypt-Random-Source@rt.cpan.org>).
76  
77 =head1 AUTHOR
78  
79 יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
80  
81 =head1 COPYRIGHT AND LICENCE
82  
83 This software is copyright (c) 2008 by Yuval Kogman.
84  
85 This is free software; you can redistribute it and/or modify it under
86 the same terms as the Perl 5 programming language system itself.
87  
88 =cut
89  
90 __END__
« Source.pm ↑ Summary Source/Base/RandomDevice.pm »