refactor Lib::FS
[scpubgit/DKit.git] / lib / DX / Lib / FS / Observation / FileContent.pm
CommitLineData
8c3eab7b 1package DX::Lib::FS::Observation::FileContent;
2
3use DX::Lib::FS::Fact::FileContent;
4use Moo;
5
6has path => (is => 'ro', required => 1);
7
8sub run {
9 my ($self) = @_;
dd866f63 10 return () unless -e $self->path;
8c3eab7b 11 my $data = do {
12 open my $fh, '<', $self->path or die "Couldn't open ${\$self->path}: $!";
13 local $/;
14 readline($fh)
15 };
16 +(file_content => DX::Lib::FS::Fact::FileContent->new(
17 path => $self->path,
18 data => $data
19 ));
20}
21
221;