Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adds discovery. Call with pastejour -f

  • Loading branch information...
commit 8a13daa5fad804606f08afcbd368e98c1efc7369 1 parent d69c327
C o u r t e n a y courtenay authored
Showing with 27 additions and 1 deletion.
  1. +7 −0 README.rdoc
  2. +4 −1 bin/pastejour
  3. +16 −0 lib/pastejour.rb
7 README.rdoc
View
@@ -18,6 +18,13 @@ Broadcast standard out using Bonjour.
alice$ git diff | pastejour monkeys
bob$ pastejour alice-monkeys | cat
+ alice$ git diff | pastejour monkeys
+ bob$ pastejour -f
+ Searching for servers (3 seconds)
+ alice-monkeys
+
+
+
== ORLY?
Yup. Pastejour gives you a simple, discoverable pipe for standard in and
5 bin/pastejour
View
@@ -4,10 +4,13 @@ require "rubygems"
require "pastejour"
multiple = ARGV.delete("-m")
+find = ARGV.delete("-f")
teeing = ARGV.delete("-t") || false
name = ARGV.shift
-if $stdin.tty?
+if find
+ Pastejour.list
+elsif $stdin.tty?
name = /#{ENV["USER"]}$/ if name.nil? || name.empty?
$stdout.write(Pastejour.get(name))
$stdout.flush
16 lib/pastejour.rb
View
@@ -14,6 +14,22 @@ module Pastejour
PORT = 42424
SERVICE = "_pastejour._tcp"
+ def self.list
+ servers = {}
+ service = DNSSD.browse(SERVICE) do |reply|
+ servers[reply.name] ||= reply
+ end
+ STDERR.puts "Searching for servers (3 seconds)"
+ # Wait for something to happen
+ sleep 3
+ service.stop
+ servers.each { |string,obj|
+ name, port = string.split ":"
+ STDERR.puts "Found pastejour at '#{name}'"
+ }
+ end
+
+
def self.find(name, first=true)
hosts = Set.new
Please sign in to comment.
Something went wrong with that request. Please try again.