music_cast 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a965005abde257ee53fe729ddb08fb5a0ba2c584ef51e6b5d88586a61b5e7be5
4
+ data.tar.gz: 319c19401a84566bb99c12157023621a7dba1178a0cb10a616f2c026176870a1
5
+ SHA512:
6
+ metadata.gz: eae76f7e2e056cf455d0eb394684ab6e218f389e7b7deb7c50b982b759c200f43e7d37f661deaa03b4110a77f0e7afec1dcbdee4b0ad9dac350a5cdffbceb51d
7
+ data.tar.gz: 8bc0f33544b0e932b2c9fa43f350afcbb49a945140ade8330297083f8aa706458f22be17cde9ff0608dc4f625c984de75b63e534c7c8594fc361d08ba2ce1b6f
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ .byebug_history
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.0
5
+ before_install: gem install bundler -v 1.16.1
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) {|repo_name| 'https://github.com/#{repo_name}' }
4
+
5
+ # Specify your gem's dependencies in music_cast.gemspec
6
+ gemspec
@@ -0,0 +1,55 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ music_cast (0.1.0)
5
+ faraday (~> 0.14.0)
6
+ vcr (~> 4.0)
7
+ webmock (~> 3.3)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ addressable (2.5.2)
13
+ public_suffix (>= 2.0.2, < 4.0)
14
+ byebug (10.0.1)
15
+ crack (0.4.3)
16
+ safe_yaml (~> 1.0.0)
17
+ diff-lcs (1.3)
18
+ faraday (0.14.0)
19
+ multipart-post (>= 1.2, < 3)
20
+ hashdiff (0.3.7)
21
+ multipart-post (2.0.0)
22
+ public_suffix (3.0.2)
23
+ rake (10.5.0)
24
+ rspec (3.7.0)
25
+ rspec-core (~> 3.7.0)
26
+ rspec-expectations (~> 3.7.0)
27
+ rspec-mocks (~> 3.7.0)
28
+ rspec-core (3.7.1)
29
+ rspec-support (~> 3.7.0)
30
+ rspec-expectations (3.7.0)
31
+ diff-lcs (>= 1.2.0, < 2.0)
32
+ rspec-support (~> 3.7.0)
33
+ rspec-mocks (3.7.0)
34
+ diff-lcs (>= 1.2.0, < 2.0)
35
+ rspec-support (~> 3.7.0)
36
+ rspec-support (3.7.1)
37
+ safe_yaml (1.0.4)
38
+ vcr (4.0.0)
39
+ webmock (3.3.0)
40
+ addressable (>= 2.3.6)
41
+ crack (>= 0.3.2)
42
+ hashdiff
43
+
44
+ PLATFORMS
45
+ ruby
46
+
47
+ DEPENDENCIES
48
+ bundler (~> 1.16)
49
+ byebug (~> 10.0, >= 10.0.1)
50
+ music_cast!
51
+ rake (~> 10.0)
52
+ rspec (~> 3.0)
53
+
54
+ BUNDLED WITH
55
+ 1.16.1
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Karl Entwistle
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,46 @@
1
+ # MusicCast
2
+
3
+ Control System for Yamaha MusicCast written in Ruby
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'music_cast'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install music_cast
20
+
21
+ ## Configuration
22
+
23
+ The configuration options can be set by using the `configure` helper
24
+
25
+ ```ruby
26
+ MusicCast.configure do |c|
27
+ c.ip_address = '192.168.0.144'
28
+ end
29
+ ```
30
+
31
+ The following is the full list of available configuration options:
32
+
33
+ ```ruby
34
+ ip_address # The static IP address of your speaker
35
+ ```
36
+
37
+
38
+ ## Development
39
+
40
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests.
41
+
42
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
43
+
44
+ ## Contributing
45
+
46
+ Bug reports and pull requests are welcome on GitHub at https://github.com/karlentwistle/music_cast.
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,18 @@
1
+ module MusicCast
2
+ class << self
3
+ def configuration
4
+ @configuration ||= Configuration.new
5
+ end
6
+
7
+ alias_method :config, :configuration
8
+
9
+ def configure
10
+ yield configuration
11
+ end
12
+ end
13
+ end
14
+
15
+ require_relative 'music_cast/configuration'
16
+ require_relative 'music_cast/api'
17
+ require_relative 'music_cast/errors/request_error'
18
+ require_relative 'music_cast/version'
@@ -0,0 +1,30 @@
1
+ require 'faraday'
2
+ require 'json'
3
+
4
+ module MusicCast
5
+ class API
6
+ def configuration
7
+ MusicCast.configuration
8
+ end
9
+
10
+ protected
11
+
12
+ def ip_address
13
+ configuration.ip_address
14
+ end
15
+
16
+ def make_request(path)
17
+ request = Faraday.get("http://#{ip_address}/YamahaExtendedControl/v1/#{path}")
18
+ response_code = JSON.parse(request.body).fetch('response_code')
19
+
20
+ if response_code == 0
21
+ request
22
+ else
23
+ raise RequestError, response_code
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ require_relative 'api/set_power'
30
+ require_relative 'api/set_volume'
@@ -0,0 +1,23 @@
1
+ module MusicCast
2
+ class SetPower < API
3
+ def on
4
+ make_request('main/setPower?power=on')
5
+ end
6
+
7
+ def standby
8
+ make_request('main/setPower?power=standby')
9
+ end
10
+
11
+ def toggle
12
+ make_request('main/setPower?power=toggle')
13
+ end
14
+
15
+ def enable_auto_standby
16
+ make_request('system/setAutoPowerStandby?enable=true')
17
+ end
18
+
19
+ def disable_auto_standby
20
+ make_request('system/setAutoPowerStandby?enable=false')
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,11 @@
1
+ module MusicCast
2
+ class SetVolume < API
3
+ def to(value)
4
+ if (0..100).include?(value)
5
+ make_request("main/setVolume?volume=#{value.to_i}")
6
+ else
7
+ raise RequestError, "value #{value} out of bounds 0..100"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ module MusicCast
2
+ class Configuration
3
+ PROPERTIES = [
4
+ :ip_address,
5
+ ]
6
+
7
+ def property_names
8
+ PROPERTIES
9
+ end
10
+
11
+ attr_accessor(*PROPERTIES)
12
+ end
13
+ end
@@ -0,0 +1,4 @@
1
+ module MusicCast
2
+ class RequestError < StandardError
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module MusicCast
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,30 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "music_cast/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'music_cast'
7
+ spec.version = MusicCast::VERSION
8
+ spec.authors = ['Karl Entwistle']
9
+ spec.email = ['karl@entwistle.com']
10
+
11
+ spec.summary = 'Yamaha MusicCast Control System'
12
+ spec.description = 'Yamaha MusicCast HTTP simplified API for Control Systems'
13
+ spec.homepage = 'https://github.com/karlentwistle/music_cast'
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
16
+ f.match(%r{^(test|spec|features)/})
17
+ end
18
+ spec.bindir = 'exe'
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_dependency 'faraday', '~> 0.14.0'
23
+ spec.add_dependency 'vcr', '~> 4.0'
24
+ spec.add_dependency 'webmock', '~> 3.3'
25
+
26
+ spec.add_development_dependency 'bundler', '~> 1.16'
27
+ spec.add_development_dependency 'rake', '~> 10.0'
28
+ spec.add_development_dependency 'rspec', '~> 3.0'
29
+ spec.add_development_dependency 'byebug', '~> 10.0', '>= 10.0.1'
30
+ end
metadata ADDED
@@ -0,0 +1,164 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: music_cast
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Karl Entwistle
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-03-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.14.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.14.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: vcr
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '4.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '4.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: webmock
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.3'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.16'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.16'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: byebug
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '10.0'
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: 10.0.1
107
+ type: :development
108
+ prerelease: false
109
+ version_requirements: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - "~>"
112
+ - !ruby/object:Gem::Version
113
+ version: '10.0'
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: 10.0.1
117
+ description: Yamaha MusicCast HTTP simplified API for Control Systems
118
+ email:
119
+ - karl@entwistle.com
120
+ executables: []
121
+ extensions: []
122
+ extra_rdoc_files: []
123
+ files:
124
+ - ".gitignore"
125
+ - ".rspec"
126
+ - ".travis.yml"
127
+ - Gemfile
128
+ - Gemfile.lock
129
+ - LICENSE
130
+ - README.md
131
+ - Rakefile
132
+ - bin/setup
133
+ - lib/music_cast.rb
134
+ - lib/music_cast/api.rb
135
+ - lib/music_cast/api/set_power.rb
136
+ - lib/music_cast/api/set_volume.rb
137
+ - lib/music_cast/configuration.rb
138
+ - lib/music_cast/errors/request_error.rb
139
+ - lib/music_cast/version.rb
140
+ - music_cast.gemspec
141
+ homepage: https://github.com/karlentwistle/music_cast
142
+ licenses: []
143
+ metadata: {}
144
+ post_install_message:
145
+ rdoc_options: []
146
+ require_paths:
147
+ - lib
148
+ required_ruby_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ required_rubygems_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ requirements: []
159
+ rubyforge_project:
160
+ rubygems_version: 2.7.5
161
+ signing_key:
162
+ specification_version: 4
163
+ summary: Yamaha MusicCast Control System
164
+ test_files: []