| 1 | package Statocles::File; | ||
| 2 | 101 | our $VERSION = '0.099'; | |
| 3 | # ABSTRACT: A wrapper for a file on the filesystem | ||
| 4 | |||
| 5 | #pod =head1 SYNOPSIS | ||
| 6 | #pod | ||
| 7 | #pod my $store = Statocles::Store->new( path => 'my/store' ); | ||
| 8 | #pod my $file = Statocles::File->new( | ||
| 9 | #pod store => $store, | ||
| 10 | #pod path => 'file.txt', # my/store/file.txt | ||
| 11 | #pod ); | ||
| 12 | #pod | ||
| 13 | #pod =head1 DESCRIPTION | ||
| 14 | #pod | ||
| 15 | #pod This class encapsulates the information for a file on the filesystem and provides | ||
| 16 | #pod methods to read the file. | ||
| 17 | #pod | ||
| 18 | #pod =head1 SEE ALSO | ||
| 19 | #pod | ||
| 20 | #pod L<Statocles::Store>, L<Statocles::Document> | ||
| 21 | #pod | ||
| 22 | #pod =cut | ||
| 23 | |||
| 24 | 101 | ▶ | use Statocles::Base 'Class'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 25 | |||
| 26 | #pod =attr store | ||
| 27 | #pod | ||
| 28 | #pod The store that contains this file | ||
| 29 | #pod | ||
| 30 | #pod =cut | ||
| 31 | |||
| 32 | 101 | has store => ( | |
| 33 | is => 'ro', | ||
| 34 | isa => StoreType, | ||
| 35 | coerce => StoreType->coercion, | ||
| 36 | ); | ||
| 37 | |||
| 38 | #pod =attr path | ||
| 39 | #pod | ||
| 40 | #pod The path to this file, relative to the store | ||
| 41 | #pod | ||
| 42 | #pod =cut | ||
| 43 | |||
| 44 | 101 | has path => ( | |
| 45 | is => 'ro', | ||
| 46 | isa => Path, | ||
| 47 | coerce => Path->coercion, | ||
| 48 | ); | ||
| 49 | |||
| 50 | #pod =attr fh | ||
| 51 | #pod | ||
| 52 | #pod The file handle containing the contents of the page. | ||
| 53 | #pod | ||
| 54 | #pod =cut | ||
| 55 | |||
| 56 | has fh => ( | ||
| 57 | is => 'ro', | ||
| 58 | isa => FileHandle, | ||
| 59 | lazy => 1, | ||
| 60 | 0 | ▶ | default => sub { |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 61 | 0 | return shift->path->openr_utf8; | |
| 62 | }, | ||
| 63 | 101 | ); | |
| 64 | |||
| 65 | 101 | 1; | |
| 66 | |||
| 67 | __END__ | ||