jbarnette-pastejour 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = Pastejour
2
2
 
3
- Broadcast standard out.
3
+ Broadcast standard out using Bonjour.
4
4
 
5
5
  == Installation
6
6
 
@@ -52,4 +52,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
52
52
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
53
53
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
54
54
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
55
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
55
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/bin/pastejour CHANGED
@@ -4,6 +4,7 @@ require "rubygems"
4
4
  require "pastejour"
5
5
 
6
6
  multiple = ARGV.delete("-m")
7
+ teeing = ARGV.delete("-t") || false
7
8
  name = ARGV.shift
8
9
 
9
10
  if $stdin.tty?
@@ -12,5 +13,7 @@ if $stdin.tty?
12
13
  $stdout.flush
13
14
  else
14
15
  name = [ENV["USER"], name].compact.join("-")
15
- Pastejour.serve(name, multiple, $stdin.read)
16
+ contents = $stdin.read
17
+ Pastejour.serve(name, multiple, contents)
18
+ puts contents if teeing
16
19
  end
data/lib/pastejour.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  require "dnssd"
2
+ require "set"
2
3
  require "socket"
3
4
  require "webrick"
4
- require "set"
5
+
5
6
  require "pastejour/version"
6
7
 
7
8
  Thread.abort_on_exception = true
@@ -51,17 +52,14 @@ module Pastejour
51
52
  return sock.read
52
53
  end
53
54
  end
54
-
55
- # FIXME: actually read the paste contents
56
- # TCPSocket.open("localhost", PORT).read
57
55
  end
58
56
 
59
57
  def self.serve(name, multiple, contents)
60
58
  tr = DNSSD::TextRecord.new
61
- tr['description'] = File.read("#{path}/.git/description") rescue "a git project"
59
+ tr["description"] = "A paste."
62
60
 
63
61
  DNSSD.register(name, SERVICE, "local", PORT, tr.encode) do |reply|
64
- puts "Pasting #{name}..."
62
+ STDERR.puts "Pasting #{name}..."
65
63
  end
66
64
 
67
65
  log = WEBrick::Log.new(true) # true fools it
@@ -69,9 +67,11 @@ module Pastejour
69
67
 
70
68
  server = WEBrick::GenericServer.new(:Port => PORT, :Logger => log)
71
69
 
72
- trap "INT" do
73
- server.shutdown
74
- exit!
70
+ %w(INT TERM).each do |signal|
71
+ trap signal do
72
+ server.shutdown
73
+ exit!
74
+ end
75
75
  end
76
76
 
77
77
  server.start do |socket|
@@ -1,3 +1,3 @@
1
1
  module Pastejour
2
- VERSION = "1.0.3".freeze
2
+ VERSION = "1.0.4".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jbarnette-pastejour
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Barnette
@@ -10,7 +10,7 @@ autorequire: pastejour
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2008-06-03 00:00:00 -07:00
13
+ date: 2008-06-04 00:00:00 -07:00
14
14
  default_executable: pastejour
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency