findme 0.0.2 → 0.0.3
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/findme.gemspec +1 -1
- data/lib/findme.rb +28 -1
- data/lib/findme/version.rb +1 -1
- metadata +4 -3
data/findme.gemspec
CHANGED
@@ -4,7 +4,7 @@ require File.expand_path('../lib/findme/version', __FILE__)
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = ["c2h2"]
|
6
6
|
gem.email = ["yiling.cao@gmail.com"]
|
7
|
-
gem.description = "find neighborhood host and services with avahi / avahi-daemon."
|
7
|
+
gem.description = "find neighborhood host and services with avahi / avahi-daemon. run this for the first time to allow normal user to register services `sudo chmod a+w /etc/avahi/services/`"
|
8
8
|
gem.summary = "find neighborhood host and services with avahi / avahi-daemon."
|
9
9
|
gem.homepage = "https://github.com/c2h2/findme"
|
10
10
|
|
data/lib/findme.rb
CHANGED
@@ -65,11 +65,38 @@ class Findme
|
|
65
65
|
else
|
66
66
|
v.sort! {|x,y| _get_startup_time(x.txt) <=> _get_startup_time(y.txt) }
|
67
67
|
end
|
68
|
-
h_out[k]=v
|
68
|
+
h_out[k]=v.last #fix a bug here.
|
69
69
|
end
|
70
70
|
h_out
|
71
71
|
end
|
72
72
|
|
73
|
+
def self.discover_only_latest
|
74
|
+
services = discover
|
75
|
+
h = {}
|
76
|
+
h_out={}
|
77
|
+
|
78
|
+
#construct the hash, group the services of the same name
|
79
|
+
services.each do |s|
|
80
|
+
if h[s.service].nil?
|
81
|
+
h[s.service]=[]
|
82
|
+
else
|
83
|
+
#existing hash, do nothing
|
84
|
+
end
|
85
|
+
h[s.service] << s
|
86
|
+
end
|
87
|
+
|
88
|
+
h.each do |k, v|
|
89
|
+
if (_get_startup_time v[0].txt).nil?
|
90
|
+
#cant find the earliest time, just return the first one.
|
91
|
+
else
|
92
|
+
v.sort! {|x,y| _get_startup_time(x.txt) <=> _get_startup_time(y.txt) }
|
93
|
+
end
|
94
|
+
h_out[k]=v.first #latest registerd.
|
95
|
+
end
|
96
|
+
h_out
|
97
|
+
end
|
98
|
+
|
99
|
+
|
73
100
|
def self.discover
|
74
101
|
res = `avahi-browse -arpt`
|
75
102
|
services = []
|
data/lib/findme/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: findme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,9 +9,10 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-04 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
|
-
description: find neighborhood host and services with avahi / avahi-daemon.
|
14
|
+
description: find neighborhood host and services with avahi / avahi-daemon. run this
|
15
|
+
for the first time to allow normal user to register services `sudo chmod a+w /etc/avahi/services/`
|
15
16
|
email:
|
16
17
|
- yiling.cao@gmail.com
|
17
18
|
executables: []
|