create ReadChannel object to allow moving Shere logic into connect
[scpubgit/Object-Remote.git] / lib / Object / Remote / Connector / STDIO.pm
index 4ea49af..69ba95d 100644 (file)
@@ -1,7 +1,9 @@
 package Object::Remote::Connector::STDIO;
 
 use File::Spec;
+use IO::Handle;
 use Object::Remote::Connection;
+use Object::Remote::ReadChannel;
 use Moo;
 
 sub connect {
@@ -12,12 +14,12 @@ sub connect {
   # only potentially bloody confusing but results in warnings like:
   # "Filehandle STDOUT reopened as STDIN only for input"
   close STDIN or die "Closing stdin: $!";
-  open STDIN, '<', File::Spec->dev_null or die "Re-opening stdin: $!";
+  open STDIN, '<', File::Spec->devnull or die "Re-opening stdin: $!";
   close STDOUT or die "Closing stdout: $!";
-  open STDOUT, '>', File::Spec->dev_null or die "Re-opening stdout: $!";
-  Object::Remote::Connection->new(
+  open STDOUT, '>', File::Spec->devnull or die "Re-opening stdout: $!";
+  return Object::Remote::Connection->new(
     send_to_fh => $stdout,
-    receive_from_fh => $stdin
+    read_channel => Object::Remote::ReadChannel->new(fh => $stdin)
   );
 }