From: Matt S Trout <mst@shadowcat.co.uk>
Date: Mon, 11 Jun 2012 23:23:04 +0000 (+0100)
Subject: unix socket connector
X-Git-Tag: v0.001001~18
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0e547800d52ca183014b58016504fa2f9600a456;p=scpubgit%2FObject-Remote.git

unix socket connector
---

diff --git a/lib/Object/Remote/Connector/UNIX.pm b/lib/Object/Remote/Connector/UNIX.pm
new file mode 100644
index 0000000..614609a
--- /dev/null
+++ b/lib/Object/Remote/Connector/UNIX.pm
@@ -0,0 +1,26 @@
+package Object::Remote::Connector::UNIX;
+
+use IO::Socket::UNIX;
+use Moo;
+
+with 'Object::Remote::Role::Connector';
+
+sub _open2_for {
+  my ($self,$path) = @_;
+  my $sock = IO::Socket::UNIX->new($path)
+    or die "Couldn't open socket ${path}: $!";
+  ($sock, $sock, undef);
+}
+
+no warnings 'once';
+
+push @Object::Remote::Connection::Guess, sub { 
+  for ($_[0]) {
+    if (defined and !ref and /^(?:\.\/|\/)/) {
+      return __PACKAGE__->new->connect($_[0]);
+    }
+  }
+  return;
+};
+
+1;