easyjour 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/Rakefile +2 -2
- data/easyjour.gemspec +2 -2
- data/lib/easyjour.rb +12 -5
- data/lib/easyjour/version.rb +1 -1
- metadata +2 -2
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rake'
|
|
2
2
|
require 'rake/testtask'
|
3
3
|
require 'rake/rdoctask'
|
4
4
|
require 'spec/rake/spectask'
|
5
|
-
require
|
5
|
+
require 'lib/easyjour/version'
|
6
6
|
|
7
7
|
require 'echoe'
|
8
8
|
Echoe.new 'easyjour', Easyjour::Version do |p|
|
@@ -10,7 +10,7 @@ Echoe.new 'easyjour', Easyjour::Version do |p|
|
|
10
10
|
p.url = "http://easyjour.rubyforge.org"
|
11
11
|
p.author = "Elijah Miller"
|
12
12
|
p.email = "elijah.miller@gmail.com"
|
13
|
-
# p.extra_deps = [['
|
13
|
+
# p.extra_deps = [['dnssd', '>= 0.7.0']]
|
14
14
|
p.need_tar_gz = false
|
15
15
|
end
|
16
16
|
|
data/easyjour.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{easyjour}
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.4"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Elijah Miller"]
|
9
|
-
s.date = %q{2008-12-
|
9
|
+
s.date = %q{2008-12-07}
|
10
10
|
s.description = %q{Super simple access to service announcing and discovery using Bonjour aka DNSSD.}
|
11
11
|
s.email = %q{elijah.miller@gmail.com}
|
12
12
|
s.extra_rdoc_files = ["CHANGELOG", "lib/easyjour/version.rb", "lib/easyjour.rb", "LICENSE", "README"]
|
data/lib/easyjour.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
require '
|
1
|
+
require 'rubygems'
|
2
|
+
require 'dnssd'
|
2
3
|
|
3
4
|
module Easyjour
|
4
5
|
# Turns a service and protocol into _service._protocol format, automatically
|
@@ -21,8 +22,14 @@ module Easyjour
|
|
21
22
|
end
|
22
23
|
|
23
24
|
class Service
|
24
|
-
def initialize(name, service, port,
|
25
|
-
|
25
|
+
def initialize(name, service, port, text_record_hash = {}, protocol = :tcp)
|
26
|
+
text_record = DNSSD::TextRecord.new
|
27
|
+
text_record_hash.each do |key, value|
|
28
|
+
text_record[key] = value
|
29
|
+
end
|
30
|
+
|
31
|
+
@service = DNSSD.register(name, Easyjour.type_from_parts(service, protocol), 'local', port, text_record.encode, DNSSD::Flags::Add) do |reply|
|
32
|
+
end
|
26
33
|
end
|
27
34
|
|
28
35
|
# Stops a service from being discoverable.
|
@@ -72,8 +79,8 @@ module Easyjour
|
|
72
79
|
@results = []
|
73
80
|
@results_mutex = Mutex.new
|
74
81
|
|
75
|
-
@query =
|
76
|
-
|
82
|
+
@query = DNSSD.browse(Easyjour.type_from_parts(service, protocol)) do |reply|
|
83
|
+
DNSSD.resolve(reply.name, reply.type, reply.domain) do |reply|
|
77
84
|
yield(reply) if block_given?
|
78
85
|
|
79
86
|
@results_mutex.synchronize do
|
data/lib/easyjour/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easyjour
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elijah Miller
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-12-
|
12
|
+
date: 2008-12-07 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|