dacpclient 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/Rakefile +1 -1
- data/bin/dacpclient +17 -4
- data/dacpclient.gemspec +1 -1
- data/lib/dacpclient/browser.rb +3 -4
- data/lib/dacpclient/pairingserver.rb +3 -3
- data/lib/dacpclient/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66c56df86793fd1624160851a47545719c55b087
|
4
|
+
data.tar.gz: a62913732101151597a1f8d3d3243e545c7c375a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ec5d69af7e39d2ed18dd4ba99c8104c5943aa79e5dc5e4210242a049719b8c2c60cf5c1503437d161426fa238f664f96c05de37996198d129e1655733f61239
|
7
|
+
data.tar.gz: 87c00eeb87f5e09919fe4a4c3bd3e964e2e916cf34c4320ec0f145dfe18a274a401dc2632523aec05ca2d4a45ceffd43c614e5111b6756e85b965f708e3f834d
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -8,7 +8,7 @@ YARD::Rake::YardocTask.new
|
|
8
8
|
task test: :rubocop do
|
9
9
|
end
|
10
10
|
|
11
|
-
|
11
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
12
12
|
task.patterns = ['**/*.rb', 'Rakefile', 'dacpclient.gemspec', 'bin/*']
|
13
13
|
task.options = ['-a']
|
14
14
|
task.fail_on_error = true
|
data/bin/dacpclient
CHANGED
@@ -18,7 +18,7 @@ class CLIClient < Thor
|
|
18
18
|
@config = {}
|
19
19
|
@config['client_name'] ||= "DACPClient (#{Socket.gethostname})"
|
20
20
|
@config['host'] ||= 'localhost'
|
21
|
-
@config['known_databases'] ||= [
|
21
|
+
@config['known_databases'] ||= []
|
22
22
|
|
23
23
|
load_config
|
24
24
|
|
@@ -29,9 +29,16 @@ class CLIClient < Thor
|
|
29
29
|
end
|
30
30
|
|
31
31
|
browser = DACPClient::Browser.new
|
32
|
-
|
33
|
-
database =
|
34
|
-
|
32
|
+
|
33
|
+
database = nil
|
34
|
+
|
35
|
+
3.times do
|
36
|
+
browser.browse
|
37
|
+
database = browser.devices.find do |device|
|
38
|
+
@config['known_databases'].include? device.database_id
|
39
|
+
end
|
40
|
+
break if database
|
41
|
+
sleep 0.5
|
35
42
|
end
|
36
43
|
|
37
44
|
unless database
|
@@ -291,7 +298,13 @@ class CLIClient < Thor
|
|
291
298
|
end
|
292
299
|
end
|
293
300
|
|
301
|
+
def clean_config
|
302
|
+
@config['known_databases'].delete('')
|
303
|
+
@config['known_databases'].uniq!
|
304
|
+
end
|
305
|
+
|
294
306
|
def save_config
|
307
|
+
clean_config
|
295
308
|
File.open(File.join(config_dir, 'config.yml'), 'w') do |out|
|
296
309
|
YAML.dump(@config, out)
|
297
310
|
end
|
data/dacpclient.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_runtime_dependency 'plist', '~> 3.1.0'
|
25
25
|
spec.add_runtime_dependency 'dmapparser', '~> 0.1.0'
|
26
26
|
spec.add_runtime_dependency 'thor', '~> 0.19.1'
|
27
|
-
spec.add_runtime_dependency 'fuzzy_match', '~> 2.0
|
27
|
+
spec.add_runtime_dependency 'fuzzy_match', '~> 2.1.0'
|
28
28
|
|
29
29
|
spec.add_development_dependency 'yard'
|
30
30
|
spec.add_development_dependency 'redcarpet'
|
data/lib/dacpclient/browser.rb
CHANGED
@@ -23,11 +23,10 @@ module DACPClient
|
|
23
23
|
@devices = []
|
24
24
|
end
|
25
25
|
|
26
|
-
def browse
|
27
|
-
service_name = new_service ? DAAP_SERVICE : TOUCHABLE_SERVICE
|
26
|
+
def browse
|
28
27
|
@devices = []
|
29
|
-
timeout(
|
30
|
-
DNSSD.browse!(
|
28
|
+
timeout(5) do
|
29
|
+
DNSSD.browse!(TOUCHABLE_SERVICE) do |node|
|
31
30
|
resolve(node)
|
32
31
|
break unless node.flags.more_coming?
|
33
32
|
end
|
@@ -26,6 +26,8 @@ module DACPClient
|
|
26
26
|
@pairing_string = generate_pairing_string(@pair, @name, @device_type)
|
27
27
|
@expected = PairingServer.generate_pin_challenge(@pair, @pin)
|
28
28
|
@service = DNSSD.register!(@name, MDNS_TYPE, 'local', @port, text_record)
|
29
|
+
@browser = DACPClient::Browser.new
|
30
|
+
@browser.browse
|
29
31
|
|
30
32
|
PairInfo.new(DMAPParser::Parser.parse(@pairing_string))
|
31
33
|
super
|
@@ -45,9 +47,7 @@ module DACPClient
|
|
45
47
|
def serve(client)
|
46
48
|
data = client.gets
|
47
49
|
peer_addr = client.peeraddr[2]
|
48
|
-
|
49
|
-
browser.browse
|
50
|
-
@peer = browser.devices.find do |device|
|
50
|
+
@peer = @browser.devices.find do |device|
|
51
51
|
device.host == peer_addr
|
52
52
|
end
|
53
53
|
if data =~ /pairingcode=#{@expected}/i && @peer
|
data/lib/dacpclient/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dacpclient
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jurriaan Pruis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 2.0
|
89
|
+
version: 2.1.0
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 2.0
|
96
|
+
version: 2.1.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: yard
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|