Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Reboot.

  • Loading branch information...
commit a2085178c7e70d6ef31fb710a5df506d9b62306c 1 parent 8da36c7
@jbarnette authored
View
3  CHANGELOG.rdoc
@@ -0,0 +1,3 @@
+=== 1.0.0 (2009-02-27)
+
+* Birthday!
View
10 Manifest.txt
@@ -0,0 +1,10 @@
+.autotest
+CHANGELOG.rdoc
+Manifest.txt
+README.rdoc
+Rakefile
+bin/pastejour
+lib/pastejour.rb
+lib/pastejour/cli.rb
+lib/pastejour/version.rb
+test/pastejour/cli_test.rb
View
38 README.rdoc
@@ -2,12 +2,7 @@
Broadcast standard out using Bonjour.
-== Installation
-
- sudo gem install dnssd
- sudo gem install jbarnette-pastejour --source=http://gems.github.com
-
-== Usage
+== Examples
alice$ git diff | pastejour
bob$ pastejour alice
@@ -26,13 +21,13 @@ Broadcast standard out using Bonjour.
# Copy the clipboard contents from one machine to another
alice$ pbpaste | pastejour bob
bob$ pastejour | pbcopy
-
+
== ORLY?
-Yup. Pastejour gives you a simple, discoverable pipe for standard in and
-out. By default, Pastejour will only stay up until the first person
-grabs your paste. If you want to let a bunch of people grab the same
-thing, shoot it out in multiple mode:
+Yup. Pastejour gives you a simple, discoverable pipe for standard in
+and out. By default, Pastejour will only stay up until the first
+person grabs your paste. If you want to let a bunch of people grab the
+same thing, shoot it out in multiple mode:
alice$ git diff | pastejour -m # keeps on serving 'til you CTRL-C
@@ -40,13 +35,18 @@ thing, shoot it out in multiple mode:
You know it.
+== Installation
+
+ $ sudo gem install pastejour
+
== License
-Copyright (c) 2008 John Barnette, Evan Phoenix
+Copyright 2008 - 2009 John Barnette (jbarnette@rubyforge.org)
+ Evan Phoenix (evan@fallingsnow.net)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
+'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
@@ -55,10 +55,10 @@ the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
58 Rakefile
@@ -1,54 +1,18 @@
-require "date"
-require "fileutils"
require "rubygems"
-require "rake/gempackagetask"
-require "spec/rake/spectask"
+require "hoe"
require "./lib/pastejour/version.rb"
-pastejour_gemspec = Gem::Specification.new do |s|
- s.name = "pastejour"
- s.version = Pastejour::VERSION
- s.platform = Gem::Platform::RUBY
- s.has_rdoc = true
- s.extra_rdoc_files = ["README.rdoc"]
- s.summary = "Broadcast standard out."
- s.description = s.summary
- s.authors = ["John Barnette", "Evan Phoenix"]
- s.email = "jbarnette@rubyforge.org"
- s.homepage = "http://github.com/jbarnette/pastejour"
- s.require_path = "lib"
- s.autorequire = "pastejour"
- s.files = %w(README.rdoc Rakefile) + Dir.glob("{bin,lib,spec}/**/*")
- s.executables = %w(pastejour)
-
- s.add_dependency "dnssd", ">= 0.6.0"
-end
-
-Rake::GemPackageTask.new(pastejour_gemspec) do |pkg|
- pkg.gem_spec = pastejour_gemspec
-end
-
-namespace :gem do
- desc "Update pastejour.gemspec"
- task :spec do
- File.open("pastejour.gemspec", "w") do |f|
- f.puts(pastejour_gemspec.to_ruby)
- end
- end
-end
+Hoe.new "pastejour", Pastejour::VERSION do |p|
+ p.developer "John Barnette", "jbarnette@rubyforge.org"
-task :install => :package do
- sh %{sudo gem install --local pkg/pastejour-#{Pastejour::VERSION}}
-end
+ p.url = "http://github.com/jbarnette/pastejour"
+ p.history_file = "CHANGELOG.rdoc"
+ p.readme_file = "README.rdoc"
+ p.extra_rdoc_files = [p.readme_file]
+ p.need_tar = false
+ p.test_globs = %w(test/**/*_test.rb)
+ p.testlib = :minitest
-desc "Run all specs"
-Spec::Rake::SpecTask.new do |t|
- t.spec_files = FileList["spec/**/*_spec.rb"]
- t.spec_opts = ["--options", "spec/spec.opts"]
+ p.extra_deps << "dnssd"
end
-
-task :default => :spec
-
-desc "Remove all generated artifacts"
-task :clean => :clobber_package
View
32 bin/pastejour
@@ -1,22 +1,20 @@
#!/usr/bin/env ruby
-$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
-require "pastejour"
+require "pastejour/cli"
-multiple = ARGV.delete("-m")
-find = ARGV.delete("-f")
-teeing = ARGV.delete("-t") || false
-name = ARGV.shift
+opts = Pastejour::Cli.new STDOUT, ARGV
-if find
- Pastejour.list
-elsif $stdin.tty?
- name = /#{ENV["USER"]}$/ if name.nil? || name.empty?
- $stdout.write(Pastejour.get(name))
- $stdout.flush
-else
- name = [ENV["USER"], name].compact.join("-")
- contents = $stdin.read
- Pastejour.serve(name, multiple, contents)
- puts contents if teeing
+if opts.run?
+ if opts.list?
+ Pastejour.list
+ elsif $stdin.tty?
+ name = /#{ENV["USER"]}$/ if opts.name.nil? || opts.name.empty?
+ $stdout.write Pastejour.get(name)
+ $stdout.flush
+ else
+ name = [ENV["USER"], opts.name].compact.join "-"
+ contents = $stdin.read
+ Pastejour.serve name, opts.multiple?, contents
+ $stdout.puts contents if opts.tee?
+ end
end
View
3  lib/pastejour.rb
@@ -4,8 +4,6 @@
require "socket"
require "webrick"
-require "pastejour/version"
-
Thread.abort_on_exception = true
module Pastejour
@@ -29,7 +27,6 @@ def self.list
STDERR.puts "Found pastejour at '#{name}'"
}
end
-
def self.find(name, first=true)
hosts = Set.new
View
68 lib/pastejour/cli.rb
@@ -0,0 +1,68 @@
+require "optparse"
+require "pastejour"
+require "pastejour/version"
+
+module Pastejour
+ class Cli
+ attr_reader :name
+
+ def initialize out, args
+ @list = false
+ @multiple = false
+ @run = true
+ @tee = false
+ @verbose = false
+
+ OptionParser.new do |opts|
+ opts.separator ""
+
+ opts.on "--list", "-l", "List available pastes." do
+ @list = true
+ end
+
+ opts.on "--help", "-h", "-?", "Show this help." do
+ out.puts opts
+ @run = false
+ end
+
+ opts.on "--multiple", "-m", "Allow multiple slurps when pasting." do
+ @multiple = true
+ end
+
+ opts.on "--tee", "-t", "Tee to STDOUT when pasting." do
+ @tee = true
+ end
+
+ opts.on "--version", "-V", "Prints #{Pastejour::VERSION}." do
+ out.puts Pastejour::VERSION
+ @run = false
+ end
+
+ opts.separator ""
+
+ opts.parse! args
+ @name = args.shift
+ end
+ end
+
+ def list?
+ @list
+ end
+
+ def multiple?
+ @multiple
+ end
+
+ def run?
+ @run
+ end
+
+ def tee?
+ @tee
+ end
+
+ def verbose?
+ @verbose
+ end
+ end
+end
View
2  lib/pastejour/version.rb
@@ -1,3 +1,3 @@
module Pastejour
- VERSION = "1.0.5".freeze
+ VERSION = "1.1.0"
end
View
35 pastejour.gemspec
@@ -1,35 +0,0 @@
-# -*- encoding: utf-8 -*-
-
-Gem::Specification.new do |s|
- s.name = %q{pastejour}
- s.version = "1.0.5"
-
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.authors = ["John Barnette", "Evan Phoenix"]
- s.autorequire = %q{pastejour}
- s.date = %q{2008-11-24}
- s.default_executable = %q{pastejour}
- s.description = %q{Broadcast standard out.}
- s.email = %q{jbarnette@rubyforge.org}
- s.executables = ["pastejour"]
- s.extra_rdoc_files = ["README.rdoc"]
- s.files = ["README.rdoc", "Rakefile", "bin/pastejour", "lib/pastejour", "lib/pastejour/version.rb", "lib/pastejour.rb", "spec/helper.rb", "spec/pastejour", "spec/pastejour/pastejour_spec.rb", "spec/spec.opts"]
- s.has_rdoc = true
- s.homepage = %q{http://github.com/jbarnette/pastejour}
- s.require_paths = ["lib"]
- s.rubygems_version = %q{1.3.0}
- s.summary = %q{Broadcast standard out.}
-
- if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
- s.specification_version = 2
-
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
- s.add_runtime_dependency(%q<dnssd>, [">= 0.6.0"])
- else
- s.add_dependency(%q<dnssd>, [">= 0.6.0"])
- end
- else
- s.add_dependency(%q<dnssd>, [">= 0.6.0"])
- end
-end
View
11 spec/helper.rb
@@ -1,11 +0,0 @@
-$LOAD_PATH.unshift(File.expand_path("#{File.dirname(__FILE__)}/../lib"))
-
-require "spec"
-require "pastejour"
-
-module Spec::Expectations::ObjectExpectations
- alias_method :must, :should
- alias_method :must_not, :should_not
- undef_method :should
- undef_method :should_not
-end
View
7 spec/pastejour/pastejour_spec.rb
@@ -1,7 +0,0 @@
-require File.expand_path("#{File.dirname(__FILE__)}/../helper")
-
-describe "Pastejour" do
- it "is awesome" do
- "awesome".must == "awesome"
- end
-end
View
7 spec/spec.opts
@@ -1,7 +0,0 @@
---colour
---format
-progress
---loadby
-mtime
---reverse
---backtrace
View
24 test/pastejour/cli_test.rb
@@ -0,0 +1,24 @@
+require "minitest/unit"
+require "pastejour/cli"
+require "pastejour/version"
+
+module Pastejour
+ class CliTest < MiniTest::Unit::TestCase
+ def pastejour *args
+ stdout = StringIO.new
+ cli = Cli.new stdout, args
+
+ [cli, stdout.string]
+ end
+
+ def test_help
+ opts, out = pastejour "--help"
+ assert !opts.run?, "shouldn't run when asking for help"
+ end
+
+ def test_version
+ _, out = pastejour "--version"
+ assert_equal Pastejour::VERSION, out.strip
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.