dacpclient 0.2.10 → 0.2.11

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: 98de2006393ea258320fc611a9d344d83d0feb58
4
- data.tar.gz: 841fb499caf9bc84be3c8475c178af7a4537ad80
3
+ metadata.gz: cf81a474e862f6f8c2bde6e929bc29a693b701df
4
+ data.tar.gz: dfaa5045aded28a3ab95474c938759c1e371af78
5
5
  SHA512:
6
- metadata.gz: 63854bcdbf6ee860bccf7844c8b054d5ef9e948cbdad86b843c9028b613a236b9645210f149ea073f028fc48cba1d2a9af1fb1e3328b4af283f70cf46c8cf5c2
7
- data.tar.gz: ab1071e5f4518088e9bbc52f90f1f654826c23f0dbf846f808c732b3cf6c268419e4a3a02daa6d636f13aa8ab25dc2f379f45d90763202885100b0fbfc2d5e6e
6
+ metadata.gz: af0b53555a31b9ad99cc4e3b334607520fa3a9225bd0da7c155abd9b919ba0fcea4cf43bc2949bf056b5969c77595eb14d8ca79ca9df557e3ffe2c998cce0cf8
7
+ data.tar.gz: a16eb079d959501146eeb3aadb8607c1233ff6f9fa1e94df2455995a09796da1d1fd1a146372deed65047e158a076e44936fa47489b7244477e1043f4c786f62
data/.rubocop.yml CHANGED
@@ -8,5 +8,5 @@ ClassVars:
8
8
  ClassLength:
9
9
  Enabled: false
10
10
  AllCops:
11
- Excludes:
12
- - flatter_params_encoder.rb
11
+ Exclude:
12
+ - lib/dacpclient/faraday/*
data/Gemfile CHANGED
@@ -1,3 +1,6 @@
1
1
  gemspec
2
2
 
3
- source 'https://rubygems.org'
3
+ source 'https://rubygems.org'
4
+
5
+ gem 'minitest', '~> 5.3.1'
6
+ gem 'rubocop', '~> 0.20.0'
data/Rakefile CHANGED
@@ -1,23 +1,16 @@
1
1
  require 'bundler/gem_tasks'
2
- require 'rake/testtask'
2
+ require 'rubocop/rake_task'
3
3
  require 'rubocop'
4
4
  require 'yard'
5
- require 'rubocop/rake_task'
6
- YARD::Rake::YardocTask.new
7
5
 
8
- # Rake::TestTask.new do |t|
9
- # t.libs << 'lib/docparser'
10
- # t.test_files = FileList['test/lib/**/*_test.rb']
11
- # t.verbose = true
12
- # end
6
+ YARD::Rake::YardocTask.new
13
7
 
14
8
  task test: :rubocop do
15
9
  end
16
10
 
17
11
  Rubocop::RakeTask.new(:rubocop) do |task|
18
12
  task.patterns = ['**/*.rb', 'Rakefile', 'dacpclient.gemspec', 'bin/*']
19
- # don't abort rake on failure
20
- task.options = ['-c', '.rubocop.yml']
13
+ task.options = ['-a']
21
14
  task.fail_on_error = true
22
15
  end
23
16
 
data/bin/dacpclient CHANGED
@@ -156,6 +156,15 @@ class CLIClient < Thor
156
156
  show_status
157
157
  end
158
158
 
159
+ desc :volume, 'Get or set volume'
160
+ def volume(vol = nil)
161
+ login
162
+
163
+ @client.volume = vol.to_i unless vol.nil?
164
+ puts "Volume: #{@client.volume}"
165
+ show_status
166
+ end
167
+
159
168
  # rubocop:disable Debugger
160
169
  desc :debug, 'Debuggin\''
161
170
  def debug
data/dacpclient.gemspec CHANGED
@@ -22,14 +22,12 @@ Gem::Specification.new do |spec|
22
22
  spec.add_runtime_dependency 'faraday', '~> 0.9.0'
23
23
  spec.add_runtime_dependency 'dnssd', '~> 2.0'
24
24
  spec.add_runtime_dependency 'plist', '~> 3.1.0'
25
- spec.add_runtime_dependency 'dmapparser', '~> 0.0.2'
25
+ spec.add_runtime_dependency 'dmapparser', '~> 0.1.0'
26
26
  spec.add_runtime_dependency 'thor', '~> 0.19.1'
27
27
 
28
28
  spec.add_development_dependency 'yard'
29
29
  spec.add_development_dependency 'redcarpet'
30
30
  spec.add_development_dependency 'github-markup'
31
- spec.add_development_dependency 'minitest', '~> 5.3.1'
32
- spec.add_development_dependency 'rubocop', '~> 0.19.1'
33
31
  spec.add_development_dependency 'rake'
34
32
 
35
33
  spec.required_ruby_version = '>= 2.0.0'
@@ -4,6 +4,7 @@ require 'plist'
4
4
  require 'dmapparser'
5
5
  require 'faraday'
6
6
  require 'dacpclient/faraday/flatter_params_encoder'
7
+ require 'dacpclient/faraday/gzip'
7
8
  require 'dacpclient/pairingserver'
8
9
  require 'dacpclient/browser'
9
10
  require 'dacpclient/version'
@@ -22,12 +23,12 @@ module DACPClient
22
23
  attr_writer :guid
23
24
  attr_reader :name, :host, :port, :session_id
24
25
 
25
- HOME_SHARING_HOST = 'https://homesharing.itunes.apple.com'
26
- HOME_SHARING_PATH = '/WebObjects/MZHomeSharing.woa/wa/getShareIdentifiers'
26
+ HOME_SHARING_HOST = 'https://homesharing.itunes.apple.com'.freeze
27
+ HOME_SHARING_PATH = '/WebObjects/MZHomeSharing.woa/wa/getShareIdentifiers'.freeze
27
28
 
28
29
  DEFAULT_HEADERS = {
29
30
  'Viewer-Only-Client' => '1',
30
- # 'Accept-Encoding' => 'gzip',
31
+ 'Accept-Encoding' => 'gzip',
31
32
  'Connection' => 'keep-alive',
32
33
  'User-Agent' => 'RubyDACPClient/' + VERSION
33
34
  }.freeze
@@ -122,7 +123,7 @@ module DACPClient
122
123
  end
123
124
 
124
125
  def seek(ms)
125
- do_action(:setproperty, 'dacp.playingtime' => ms)
126
+ set_property('dacp.playingtime', ms)
126
127
  end
127
128
 
128
129
  def position
@@ -152,7 +153,7 @@ module DACPClient
152
153
  end
153
154
 
154
155
  def volume=(volume)
155
- do_action(:setproperty, :'dmcp.volume' => volume)
156
+ set_property('dmcp.volume', volume)
156
157
  end
157
158
 
158
159
  def repeat
@@ -161,7 +162,7 @@ module DACPClient
161
162
  end
162
163
 
163
164
  def repeat=(repeatstate)
164
- do_action(:setproperty, 'dacp.repeatstate' => repeatstate)
165
+ set_property('dacp.repeatstate', repeatstate)
165
166
  end
166
167
 
167
168
  def shuffle
@@ -170,7 +171,7 @@ module DACPClient
170
171
  end
171
172
 
172
173
  def shuffle=(shufflestate)
173
- do_action(:setproperty, 'dmcp.shufflestate' => shufflestate)
174
+ set_property('dmcp.shufflestate', shufflestate)
174
175
  end
175
176
 
176
177
  def ctrl_int
@@ -261,6 +262,11 @@ module DACPClient
261
262
  @uri = URI::HTTP.build(host: @host, port: @port)
262
263
  Faraday::Utils.default_params_encoder = Faraday::FlatterParamsEncoder
263
264
  @client = Faraday.new(@uri.to_s)
265
+ @client.use FaradayMiddleware::Gzip
266
+ end
267
+
268
+ def set_property(property, value)
269
+ do_action(:setproperty, property => value)
264
270
  end
265
271
 
266
272
  def do_action(action, clean_url: false, model: nil, **params)
@@ -0,0 +1,45 @@
1
+ # Copied from github.com/lostisland/faraday_middleware
2
+ require 'zlib'
3
+ module FaradayMiddleware
4
+ # A middleware that ensures that the client requests are sent with the
5
+ # headers that encourage servers to send compressed data, and then
6
+ # uncompresses it.
7
+ # The Content-Length will reflect the actual body length.
8
+ class Gzip < Faraday::Middleware
9
+ ACCEPT_ENCODING = 'Accept-Encoding'.freeze
10
+ ENCODINGS = 'gzip,deflate'.freeze
11
+
12
+ def initialize(app, options = nil)
13
+ @app = app
14
+ end
15
+
16
+ def call(curenv)
17
+ (curenv[:request_headers] ||= {})[ACCEPT_ENCODING] = ENCODINGS
18
+ @app.call(curenv).on_complete do |env|
19
+ encoding = env[:response_headers]['content-encoding'].to_s.downcase
20
+ if %w(gzip deflate).include?(encoding)
21
+ case encoding
22
+ when 'gzip'
23
+ env[:body] = uncompress_gzip(env[:body])
24
+ when 'deflate'
25
+ env[:body] = Zlib::Inflate.inflate(env[:body])
26
+ end
27
+ env[:response_headers].delete('content-encoding')
28
+ env[:response_headers]['content-length'] = env[:body].length
29
+ end
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ def uncompress_gzip(body)
36
+ io = StringIO.new(body)
37
+ gzip_reader = if '1.9'.respond_to?(:force_encoding)
38
+ Zlib::GzipReader.new(io, encoding: 'ASCII-8BIT')
39
+ else
40
+ Zlib::GzipReader.new(io)
41
+ end
42
+ gzip_reader.read
43
+ end
44
+ end
45
+ end
@@ -1,4 +1,4 @@
1
1
  # The DACPClient module
2
2
  module DACPClient
3
- VERSION = '0.2.10'
3
+ VERSION = '0.2.11'
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.2.10
4
+ version: 0.2.11
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-03-30 00:00:00.000000000 Z
11
+ date: 2014-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.0.2
61
+ version: 0.1.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.0.2
68
+ version: 0.1.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: thor
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -122,34 +122,6 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: minitest
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: 5.3.1
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: 5.3.1
139
- - !ruby/object:Gem::Dependency
140
- name: rubocop
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: 0.19.1
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: 0.19.1
153
125
  - !ruby/object:Gem::Dependency
154
126
  name: rake
155
127
  requirement: !ruby/object:Gem::Requirement
@@ -186,6 +158,7 @@ files:
186
158
  - lib/dacpclient/browser.rb
187
159
  - lib/dacpclient/client.rb
188
160
  - lib/dacpclient/faraday/flatter_params_encoder.rb
161
+ - lib/dacpclient/faraday/gzip.rb
189
162
  - lib/dacpclient/model.rb
190
163
  - lib/dacpclient/models/pair_info.rb
191
164
  - lib/dacpclient/models/play_queue.rb