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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0168ee84709980d66f477982404c0d5cddbb2f92
4
- data.tar.gz: e105474bc17e7127c0d0f9427219152df7a83d0f
3
+ metadata.gz: 66c56df86793fd1624160851a47545719c55b087
4
+ data.tar.gz: a62913732101151597a1f8d3d3243e545c7c375a
5
5
  SHA512:
6
- metadata.gz: 508242daaf50dacc3c003d4e0d033ea0ed06df405dae77ce27d2ab34e3d0199e10a77143a1ab7b0fb1214b210873f5b1c29708616dcba7562109c984142064cc
7
- data.tar.gz: f2f2dfd1c2238ae09d217ce4128032bbb174ef2e027042d687c5b8a6c8869ac1493002ee42f6df3dde07274f747fc450064f83da8b43155295d5c725c36e77ae
6
+ metadata.gz: 0ec5d69af7e39d2ed18dd4ba99c8104c5943aa79e5dc5e4210242a049719b8c2c60cf5c1503437d161426fa238f664f96c05de37996198d129e1655733f61239
7
+ data.tar.gz: 87c00eeb87f5e09919fe4a4c3bd3e964e2e916cf34c4320ec0f145dfe18a274a401dc2632523aec05ca2d4a45ceffd43c614e5111b6756e85b965f708e3f834d
data/Gemfile CHANGED
@@ -2,5 +2,5 @@ gemspec
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- gem 'minitest', '~> 5.3.1'
6
- gem 'rubocop', '~> 0.21.0'
5
+ gem 'minitest', '~> 5.4.0'
6
+ gem 'rubocop', '~> 0.24.1'
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ YARD::Rake::YardocTask.new
8
8
  task test: :rubocop do
9
9
  end
10
10
 
11
- Rubocop::RakeTask.new(:rubocop) do |task|
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
- browser.browse(false)
33
- database = browser.devices.find do |device|
34
- @config['known_databases'].include? device.database_id
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.4'
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'
@@ -23,11 +23,10 @@ module DACPClient
23
23
  @devices = []
24
24
  end
25
25
 
26
- def browse(new_service = true)
27
- service_name = new_service ? DAAP_SERVICE : TOUCHABLE_SERVICE
26
+ def browse
28
27
  @devices = []
29
- timeout(2) do
30
- DNSSD.browse!(service_name) do |node|
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
- browser = DACPClient::Browser.new
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
@@ -1,4 +1,4 @@
1
1
  # The DACPClient module
2
2
  module DACPClient
3
- VERSION = '0.3.0'
3
+ VERSION = '0.3.1'
4
4
  end
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.0
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-04-26 00:00:00.000000000 Z
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.4
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.4
96
+ version: 2.1.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: yard
99
99
  requirement: !ruby/object:Gem::Requirement