-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6be2c6c
Showing
6 changed files
with
173 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
= Dejour | ||
|
||
Discover awesome services near you. | ||
|
||
== Installation | ||
|
||
sudo gem install dnssd | ||
sudo gem install ruby-growl | ||
sudo gem install aaronp-dejour --source=http://gems.github.com | ||
|
||
== Usage | ||
|
||
$ dejour | ||
|
||
Then watch the growl notifications fly! | ||
|
||
== YOU CAN HAS NOTIFICATIONS | ||
|
||
Of new services on the network. dejour looks for pastejour and gitjour | ||
services by default. | ||
|
||
== License | ||
|
||
Copyright (c) 2008 Aaron Patterson | ||
|
||
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 | ||
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 | ||
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, | ||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
require "date" | ||
require "fileutils" | ||
require "rubygems" | ||
require "rake/gempackagetask" | ||
require "spec/rake/spectask" | ||
|
||
require "./lib/dejour/version.rb" | ||
|
||
dejour_gemspec = Gem::Specification.new do |s| | ||
s.name = "dejour" | ||
s.version = Dejour::VERSION | ||
s.platform = Gem::Platform::RUBY | ||
s.has_rdoc = true | ||
s.extra_rdoc_files = ["README.rdoc"] | ||
s.summary = "Find awesome stuff" | ||
s.description = s.summary | ||
s.authors = ["Aaron Patterson"] | ||
s.email = "aaronp@rubyforge.org" | ||
s.homepage = "http://github.com/aaronp/dejour" | ||
s.require_path = "lib" | ||
s.autorequire = "dejour" | ||
s.files = %w(README.rdoc Rakefile) + Dir.glob("{bin,lib,spec}/**/*") | ||
s.executables = %w(dejour) | ||
|
||
s.add_dependency "dnssd", ">= 0.6.0" | ||
s.add_dependency "ruby-growl" | ||
end | ||
|
||
Rake::GemPackageTask.new(dejour_gemspec) do |pkg| | ||
pkg.gem_spec = dejour_gemspec | ||
end | ||
|
||
namespace :gem do | ||
namespace :spec do | ||
desc "Update dejour.gemspec" | ||
task :generate do | ||
File.open("dejour.gemspec", "w") do |f| | ||
f.puts(dejour_gemspec.to_ruby) | ||
end | ||
end | ||
end | ||
end | ||
|
||
task :install => :package do | ||
sh %{sudo gem install pkg/dejour-#{Dejour::VERSION}} | ||
end | ||
|
||
desc "Run all specs" | ||
Spec::Rake::SpecTask.new do |t| | ||
t.spec_files = FileList["spec/**/*_spec.rb"] | ||
t.spec_opts = ["--options", "spec/spec.opts"] | ||
end | ||
|
||
task :default => :spec | ||
|
||
desc "Remove all generated artifacts" | ||
task :clean => :clobber_package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require "rubygems" | ||
require "dejour" | ||
|
||
Dejour.find(*(ARGV.length > 0 ? ARGV : ['git', 'pastejour'])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Gem::Specification.new do |s| | ||
s.name = %q{dejour} | ||
s.version = "1.0.0" | ||
|
||
s.specification_version = 2 if s.respond_to? :specification_version= | ||
|
||
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= | ||
s.authors = ["Aaron Patterson"] | ||
s.autorequire = %q{dejour} | ||
s.date = %q{2008-06-04} | ||
s.default_executable = %q{dejour} | ||
s.description = %q{Find awesome stuff} | ||
s.email = %q{aaronp@rubyforge.org} | ||
s.executables = ["dejour"] | ||
s.extra_rdoc_files = ["README.rdoc"] | ||
s.files = ["README.rdoc", "Rakefile", "bin/dejour", "lib/dejour", "lib/dejour/version.rb", "lib/dejour.rb"] | ||
s.has_rdoc = true | ||
s.homepage = %q{http://github.com/aaronp/dejour} | ||
s.require_paths = ["lib"] | ||
s.rubygems_version = %q{1.1.1} | ||
s.summary = %q{Find awesome stuff} | ||
|
||
s.add_dependency(%q<dnssd>, [">= 0.6.0"]) | ||
s.add_dependency(%q<ruby-growl>, [">= 0"]) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require 'rubygems' | ||
require "dnssd" | ||
require 'ruby-growl' | ||
|
||
Thread.abort_on_exception = true | ||
|
||
module Dejour | ||
KNOWN_SERVICES = { | ||
'git' => lambda { |reply, rr| | ||
[ "git repository", "git clone #{reply.name}" ] | ||
}, | ||
'pastejour' => lambda { |reply, rr| | ||
(from, to) = *reply.name.split('-') | ||
['pastejour', "Paste from #{from} to #{to}"] | ||
} | ||
} | ||
NOTIFICATION_NAME = 'ruby-growl Notification' | ||
def self.find(*names) | ||
g = Growl.new('localhost', 'ruby-growl', [NOTIFICATION_NAME]) | ||
seen_services = Hash.new { |h,k| h[k] = {} } | ||
mutex = Mutex.new | ||
services = names.map do |name| | ||
DNSSD.browse("_#{name}._tcp") do |reply| | ||
DNSSD.resolve(reply.name, reply.type, reply.domain) do |rr| | ||
mutex.synchronize { | ||
unless seen_services[name].key?(reply.name) | ||
seen_services[name][reply.name] = true | ||
g.notify( NOTIFICATION_NAME, | ||
*KNOWN_SERVICES[name].call(reply, rr) | ||
) | ||
end | ||
} | ||
end | ||
end | ||
end | ||
|
||
services.each { |s| s.instance_variable_get(:@thread).join } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module Dejour | ||
VERSION = "1.0.0".freeze | ||
end |