sonos 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ module DiscoveryMacros
2
+ def stub_discovery
3
+ Sonos::Discovery.any_instance.stubs(:initialize_socket)
4
+ Sonos::Discovery.any_instance.stubs(:send_discovery_message)
5
+ Sonos::Discovery.any_instance.stubs(:listen_for_responses).returns('10.0.1.10')
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ VCR.configure do |c|
2
+ c.cassette_library_dir = 'test/cassettes'
3
+ c.hook_into :fakeweb
4
+ end
@@ -0,0 +1,15 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.require :test
4
+ require 'minitest/autorun'
5
+ require 'mocha/setup'
6
+ require 'sonos'
7
+
8
+ # Support files
9
+ Dir["#{File.expand_path(File.dirname(__FILE__))}/support/*.rb"].each do |file|
10
+ require file
11
+ end
12
+
13
+ class SonosTest < MiniTest::Unit::TestCase
14
+ include DiscoveryMacros
15
+ end
@@ -0,0 +1,21 @@
1
+ require 'test_helper'
2
+
3
+ class SystemTest < SonosTest
4
+ def before_suites
5
+ super
6
+ stub_discovery
7
+ end
8
+
9
+ def test_singleton
10
+ VCR.use_cassette('topology', match_requests_on: [:path]) do
11
+ assert_equal Sonos.system.object_id, Sonos.system.object_id
12
+ end
13
+ end
14
+
15
+ def test_group_detection
16
+ VCR.use_cassette('topology', match_requests_on: [:path]) do
17
+ system = Sonos.system
18
+ assert_equal 1, system.groups.length
19
+ end
20
+ end
21
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sonos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-12-24 00:00:00.000000000 Z
13
+ date: 2013-02-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: savon
@@ -70,6 +70,7 @@ extensions: []
70
70
  extra_rdoc_files: []
71
71
  files:
72
72
  - .gitignore
73
+ - .travis.yml
73
74
  - Changelog.markdown
74
75
  - Gemfile
75
76
  - LICENSE
@@ -78,18 +79,29 @@ files:
78
79
  - bin/sonos
79
80
  - lib/sonos.rb
80
81
  - lib/sonos/cli.rb
82
+ - lib/sonos/device.rb
83
+ - lib/sonos/device/base.rb
84
+ - lib/sonos/device/bridge.rb
85
+ - lib/sonos/device/speaker.rb
81
86
  - lib/sonos/discovery.rb
82
87
  - lib/sonos/endpoint.rb
88
+ - lib/sonos/endpoint/a_v_transport.rb
83
89
  - lib/sonos/endpoint/content_directory.rb
84
90
  - lib/sonos/endpoint/device.rb
85
91
  - lib/sonos/endpoint/rendering.rb
86
- - lib/sonos/endpoint/transport.rb
87
- - lib/sonos/speaker.rb
88
- - lib/sonos/topology.rb
92
+ - lib/sonos/group.rb
93
+ - lib/sonos/system.rb
94
+ - lib/sonos/topology_node.rb
89
95
  - lib/sonos/version.rb
90
96
  - sonos.gemspec
97
+ - test/cassettes/topology.yml
98
+ - test/support/discovery_macros.rb
99
+ - test/support/vcr.rb
100
+ - test/test_helper.rb
101
+ - test/units/system_test.rb
91
102
  homepage: https://github.com/soffes/sonos
92
- licenses: []
103
+ licenses:
104
+ - MIT
93
105
  post_install_message:
94
106
  rdoc_options: []
95
107
  require_paths:
@@ -99,10 +111,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
99
111
  requirements:
100
112
  - - ! '>='
101
113
  - !ruby/object:Gem::Version
102
- version: '0'
103
- segments:
104
- - 0
105
- hash: -2990383853655204370
114
+ version: 1.9.2
106
115
  required_rubygems_version: !ruby/object:Gem::Requirement
107
116
  none: false
108
117
  requirements:
@@ -111,12 +120,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
120
  version: '0'
112
121
  segments:
113
122
  - 0
114
- hash: -2990383853655204370
123
+ hash: -1378351241916050478
115
124
  requirements: []
116
125
  rubyforge_project:
117
126
  rubygems_version: 1.8.23
118
127
  signing_key:
119
128
  specification_version: 3
120
129
  summary: Control Sonos speakers with Ruby
121
- test_files: []
130
+ test_files:
131
+ - test/cassettes/topology.yml
132
+ - test/support/discovery_macros.rb
133
+ - test/support/vcr.rb
134
+ - test/test_helper.rb
135
+ - test/units/system_test.rb
122
136
  has_rdoc:
data/lib/sonos/speaker.rb DELETED
@@ -1,44 +0,0 @@
1
- require 'savon'
2
- require 'open-uri'
3
- require 'sonos/endpoint'
4
- require 'sonos/topology'
5
-
6
- module Sonos
7
- class Speaker
8
- include Endpoint::Transport
9
- include Endpoint::Rendering
10
- include Endpoint::Device
11
- include Endpoint::ContentDirectory
12
- include Topology
13
-
14
- attr_reader :ip, :zone_name, :zone_icon, :uid, :serial_number, :software_version, :hardware_version, :mac_address
15
-
16
- def initialize(ip)
17
- @ip = ip
18
-
19
- # Get the speaker's status
20
- get_status
21
- end
22
-
23
- # URL for giant dump of device information
24
- def device_description_url
25
- "http://#{self.ip}:#{PORT}/xml/device_description.xml"
26
- end
27
-
28
- private
29
-
30
- # Get information about the speaker.
31
- def get_status
32
- doc = Nokogiri::XML(open("http://#{@ip}:#{PORT}/status/zp"))
33
-
34
- @zone_name = doc.xpath('.//ZoneName').inner_text
35
- @zone_icon = doc.xpath('.//ZoneIcon').inner_text
36
- @uid = doc.xpath('.//LocalUID').inner_text
37
- @serial_number = doc.xpath('.//SerialNumber').inner_text
38
- @software_version = doc.xpath('.//SoftwareVersion').inner_text
39
- @hardware_version = doc.xpath('.//HardwareVersion').inner_text
40
- @mac_address = doc.xpath('.//MACAddress').inner_text
41
- self
42
- end
43
- end
44
- end
@@ -1,35 +0,0 @@
1
- require 'uri'
2
-
3
- module Sonos
4
- module Topology
5
- def topology
6
- doc = Nokogiri::XML(open("http://#{@ip}:#{PORT}/status/topology"))
7
-
8
- doc.xpath('//ZonePlayers/ZonePlayer').map do |node|
9
- Node.new(node)
10
- end
11
- end
12
-
13
- protected
14
-
15
- class Node
16
- attr_accessor :name, :group, :coordinator, :location, :version, :uuid
17
-
18
- def initialize(node)
19
- node.attributes.each do |k, v|
20
- self.send("#{k}=", v) if self.respond_to?(k.to_sym)
21
- end
22
-
23
- self.name = node.inner_text
24
- end
25
-
26
- def ip
27
- @ip ||= URI.parse(location).host
28
- end
29
-
30
- def speaker
31
- @speaker || Sonos::Speaker.new(ip)
32
- end
33
- end
34
- end
35
- end