move the actual doing stuff code for FS lib into a Guts.pm
[scpubgit/DKit.git] / lib / DX / Lib / FS / Observation / FileContent.pm
index f0e2bb4..ee5a441 100644 (file)
@@ -1,18 +1,15 @@
 package DX::Lib::FS::Observation::FileContent;
 
 use DX::Lib::FS::Fact::FileContent;
+use DX::Lib::FS::Guts;
 use Moo;
 
 has path => (is => 'ro', required => 1);
 
 sub run {
   my ($self) = @_;
-  return () unless -e $self->path;
-  my $data = do {
-    open my $fh, '<', $self->path or die "Couldn't open ${\$self->path}: $!";
-    local $/;
-    readline($fh)
-  };
+  my $data = DX::Lib::FS::Guts->file_content($self->path);
+  return () unless defined($data);
   +(file_content => DX::Lib::FS::Fact::FileContent->new(
     path => $self->path,
     data => $data