lex-sonos 0.2.1

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 35e3666710144998aa49fef10596ad5fda17e6fd7d24978d34a2c8df038d437d
4
+ data.tar.gz: 68f463e152dbdd8c4b2273c46042493ff876fe03eb2e7ac37e390e9f0ef17605
5
+ SHA512:
6
+ metadata.gz: 4c1f0e51e2ec95204bc6381b2ed59e57bb7aecb1e41f842bc01c8597656b84b76489ac43e329cd8075320fb0c304219d5a40c215909415d498d23c7a648b2cce
7
+ data.tar.gz: a9c2c8b7018d73db487f08bc222b6e114273fea7abb061e6db3fad5d39f81d3dc077004a63f9e6d28d893fff5c573c36ef65076bf481c2e1f8b9f11718927ef6
@@ -0,0 +1,7 @@
1
+ # Auto-generated from team-config.yml
2
+ # Team: extensions
3
+ #
4
+ # To apply: scripts/apply-codeowners.sh lex-sonos
5
+
6
+ * @LegionIO/maintainers
7
+ * @LegionIO/extensions
@@ -0,0 +1,18 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: /
5
+ schedule:
6
+ interval: weekly
7
+ day: monday
8
+ open-pull-requests-limit: 5
9
+ labels:
10
+ - "type:dependencies"
11
+ - package-ecosystem: github-actions
12
+ directory: /
13
+ schedule:
14
+ interval: weekly
15
+ day: monday
16
+ open-pull-requests-limit: 5
17
+ labels:
18
+ - "type:dependencies"
@@ -0,0 +1,34 @@
1
+ name: CI
2
+ on:
3
+ push:
4
+ branches: [main]
5
+ pull_request:
6
+ schedule:
7
+ - cron: '0 9 * * 1'
8
+
9
+ jobs:
10
+ ci:
11
+ uses: LegionIO/.github/.github/workflows/ci.yml@main
12
+
13
+ lint:
14
+ uses: LegionIO/.github/.github/workflows/lint-patterns.yml@main
15
+
16
+ security:
17
+ uses: LegionIO/.github/.github/workflows/security-scan.yml@main
18
+
19
+ version-changelog:
20
+ uses: LegionIO/.github/.github/workflows/version-changelog.yml@main
21
+
22
+ dependency-review:
23
+ uses: LegionIO/.github/.github/workflows/dependency-review.yml@main
24
+
25
+ stale:
26
+ if: github.event_name == 'schedule'
27
+ uses: LegionIO/.github/.github/workflows/stale.yml@main
28
+
29
+ release:
30
+ needs: [ci, lint]
31
+ if: github.event_name == 'push' && github.ref == 'refs/heads/main'
32
+ uses: LegionIO/.github/.github/workflows/release.yml@main
33
+ secrets:
34
+ rubygems-api-key: ${{ secrets.RUBYGEMS_API_KEY }}
data/.gitignore ADDED
@@ -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
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,52 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.4
3
+ NewCops: enable
4
+ SuggestExtensions: false
5
+
6
+ Layout/LineLength:
7
+ Max: 160
8
+
9
+ Layout/SpaceAroundEqualsInParameterDefault:
10
+ EnforcedStyle: space
11
+
12
+ Layout/HashAlignment:
13
+ EnforcedHashRocketStyle: table
14
+ EnforcedColonStyle: table
15
+
16
+ Metrics/MethodLength:
17
+ Max: 50
18
+
19
+ Metrics/ClassLength:
20
+ Max: 1500
21
+
22
+ Metrics/ModuleLength:
23
+ Max: 1500
24
+
25
+ Metrics/BlockLength:
26
+ Max: 40
27
+ AllowedMethods:
28
+ - describe
29
+ - context
30
+ - shared_examples
31
+
32
+ Metrics/AbcSize:
33
+ Max: 60
34
+
35
+ Metrics/CyclomaticComplexity:
36
+ Max: 15
37
+
38
+ Metrics/PerceivedComplexity:
39
+ Max: 17
40
+
41
+ Style/Documentation:
42
+ Enabled: false
43
+
44
+ Style/SymbolArray:
45
+ Enabled: true
46
+
47
+ Style/FrozenStringLiteralComment:
48
+ Enabled: true
49
+ EnforcedStyle: always
50
+
51
+ Naming/FileName:
52
+ Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,23 @@
1
+ # Changelog
2
+
3
+ ## [0.2.1] - 2026-03-22
4
+
5
+ ### Changed
6
+ - Add legion-cache, legion-crypt, legion-data, legion-json, legion-logging, legion-settings, and legion-transport as runtime dependencies
7
+ - Update spec_helper with real sub-gem helper stubs for Legion::Extensions::Helpers::Lex
8
+
9
+ ## [0.2.0] - 2026-03-21
10
+
11
+ ### Added
12
+ - `Helpers::Client` module with Faraday connection builder (default base URL: `http://localhost:5005`)
13
+ - `Runners::Player` module: play, pause, stop, next_track, previous_track, volume, mute
14
+ - `Runners::Zones` module: list (all zones), get (single room state)
15
+ - `Runners::Favorites` module: list (all favorites), play (play favorite by name in room)
16
+ - Standalone `Client` class including all runner modules
17
+ - Full spec suite (21 examples)
18
+ - faraday ~> 2.0 runtime dependency
19
+
20
+ ## [0.1.0] - 2026-03-13
21
+
22
+ ### Added
23
+ - Initial release
data/CLAUDE.md ADDED
@@ -0,0 +1,78 @@
1
+ # lex-sonos: Sonos Integration for LegionIO
2
+
3
+ **Repository Level 3 Documentation**
4
+ - **Parent**: `/Users/miverso2/rubymine/legion/extensions-other/CLAUDE.md`
5
+ - **Grandparent**: `/Users/miverso2/rubymine/legion/CLAUDE.md`
6
+
7
+ ## Purpose
8
+
9
+ Legion Extension that connects LegionIO to Sonos speakers via a local Sonos HTTP API bridge (e.g., node-sonos-http-api). Provides runners for player control, zone inspection, and favorites playback.
10
+
11
+ **GitHub**: https://github.com/LegionIO/lex-sonos
12
+ **License**: MIT
13
+ **Version**: 0.2.1
14
+
15
+ ## Architecture
16
+
17
+ ```
18
+ Legion::Extensions::Sonos
19
+ ├── Runners/
20
+ │ ├── Player # play, pause, stop, next_track, previous_track, volume, mute
21
+ │ ├── Zones # list, get
22
+ │ └── Favorites # list, play
23
+ ├── Helpers/
24
+ │ └── Client # Faraday connection to local Sonos HTTP API bridge (default: localhost:5005)
25
+ └── Client # Standalone client class (includes all runners)
26
+ ```
27
+
28
+ ## Key Files
29
+
30
+ | Path | Purpose |
31
+ |------|---------|
32
+ | `lib/legion/extensions/sonos.rb` | Entry point, extension registration |
33
+ | `lib/legion/extensions/sonos/runners/player.rb` | Playback control runners |
34
+ | `lib/legion/extensions/sonos/runners/zones.rb` | Zone listing and info runners |
35
+ | `lib/legion/extensions/sonos/runners/favorites.rb` | Favorites list and play runners |
36
+ | `lib/legion/extensions/sonos/helpers/client.rb` | Faraday connection to Sonos HTTP API bridge |
37
+ | `lib/legion/extensions/sonos/client.rb` | Standalone Client class |
38
+
39
+ ## Requirements
40
+
41
+ Sonos speakers do not expose a direct HTTP API. This extension targets a local HTTP bridge such as [node-sonos-http-api](https://github.com/jishi/node-sonos-http-api) running at `http://localhost:5005` (configurable).
42
+
43
+ ## Configuration
44
+
45
+ ```json
46
+ {
47
+ "lex-sonos": {
48
+ "url": "http://localhost:5005"
49
+ }
50
+ }
51
+ ```
52
+
53
+ ## Dependencies
54
+
55
+ | Gem | Purpose |
56
+ |-----|---------|
57
+ | `faraday` (~> 2.0) | HTTP client for local Sonos HTTP API bridge |
58
+ | `legion-cache` (>= 1.3.11) | Cache helper (transitive via Helpers::Lex) |
59
+ | `legion-crypt` (>= 1.4.9) | Vault/crypt helper (transitive via Helpers::Lex) |
60
+ | `legion-data` (>= 1.4.17) | Data helper (transitive via Helpers::Lex) |
61
+ | `legion-json` (>= 1.2.1) | JSON helper (transitive via Helpers::Lex) |
62
+ | `legion-logging` (>= 1.3.2) | Logging helper (transitive via Helpers::Lex) |
63
+ | `legion-settings` (>= 1.3.14) | Settings helper (transitive via Helpers::Lex) |
64
+ | `legion-transport` (>= 1.3.9) | Transport helper (transitive via Helpers::Lex) |
65
+
66
+ ## Development
67
+
68
+ 18 specs total.
69
+
70
+ ```bash
71
+ bundle install
72
+ bundle exec rspec
73
+ bundle exec rubocop
74
+ ```
75
+
76
+ ---
77
+
78
+ **Maintained By**: Matthew Iverson (@Esity)
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
6
+
7
+ gem 'rake'
8
+ gem 'rspec', '~> 3.0'
9
+ gem 'rubocop'
10
+ gem 'rubocop-rspec'
11
+ gem 'simplecov'
data/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2021 Esity
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Esity
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # lex-sonos
2
+
3
+ Sonos speaker control for [LegionIO](https://github.com/LegionIO/LegionIO). Control Sonos devices from within Legion task chains via the [node-sonos-http-api](https://github.com/jishi/node-sonos-http-api) bridge (or compatible local HTTP API).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ gem install lex-sonos
9
+ ```
10
+
11
+ Or add to your Gemfile:
12
+
13
+ ```ruby
14
+ gem 'lex-sonos'
15
+ ```
16
+
17
+ ## Requirements
18
+
19
+ - Ruby >= 3.4
20
+ - [LegionIO](https://github.com/LegionIO/LegionIO) framework
21
+ - Sonos speakers on local network
22
+ - A local Sonos HTTP API bridge (e.g. [node-sonos-http-api](https://github.com/jishi/node-sonos-http-api)) running at `http://localhost:5005` (configurable)
23
+
24
+ ## Usage
25
+
26
+ ### Standalone Client
27
+
28
+ ```ruby
29
+ require 'lex-sonos'
30
+
31
+ client = Legion::Extensions::Sonos::Client.new(url: 'http://localhost:5005')
32
+
33
+ # Player controls
34
+ client.play(room: 'Living Room')
35
+ client.pause(room: 'Living Room')
36
+ client.stop(room: 'Living Room')
37
+ client.next_track(room: 'Living Room')
38
+ client.previous_track(room: 'Living Room')
39
+ client.volume(room: 'Living Room', level: 50)
40
+ client.mute(room: 'Living Room')
41
+
42
+ # Zone information
43
+ client.list # => { zones: [...] }
44
+ client.get(room: 'Living Room') # => { state: { playbackState: 'PLAYING', ... } }
45
+
46
+ # Favorites
47
+ client.list # => { favorites: [...] }
48
+ client.play(room: 'Living Room', name: 'My Radio Station')
49
+ ```
50
+
51
+ ## Runners
52
+
53
+ | Module | Methods |
54
+ |--------|---------|
55
+ | `Runners::Player` | `play`, `pause`, `stop`, `next_track`, `previous_track`, `volume`, `mute` |
56
+ | `Runners::Zones` | `list`, `get` |
57
+ | `Runners::Favorites` | `list`, `play` |
58
+
59
+ ## Configuration
60
+
61
+ The default base URL is `http://localhost:5005`. Override it when constructing the client:
62
+
63
+ ```ruby
64
+ client = Legion::Extensions::Sonos::Client.new(url: 'http://192.168.1.100:5005')
65
+ ```
66
+
67
+ ## License
68
+
69
+ MIT
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'legion/extensions/sonos'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -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
data/lex-sonos.gemspec ADDED
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/legion/extensions/sonos/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'lex-sonos'
7
+ spec.version = Legion::Extensions::Sonos::VERSION
8
+ spec.authors = ['Esity']
9
+ spec.email = ['matthewdiverson@gmail.com']
10
+
11
+ spec.summary = 'LEX::Sonos'
12
+ spec.description = 'Used to connect Legion to Sonos speakers'
13
+ spec.homepage = 'https://github.com/LegionIO/lex-sonos'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = '>= 3.4'
16
+
17
+ spec.metadata['homepage_uri'] = spec.homepage
18
+ spec.metadata['source_code_uri'] = 'https://github.com/LegionIO/lex-sonos'
19
+ spec.metadata['documentation_uri'] = 'https://github.com/LegionIO/lex-sonos'
20
+ spec.metadata['changelog_uri'] = 'https://github.com/LegionIO/lex-sonos/blob/main/CHANGELOG.md'
21
+ spec.metadata['bug_tracker_uri'] = 'https://github.com/LegionIO/lex-sonos/issues'
22
+ spec.metadata['rubygems_mfa_required'] = 'true'
23
+
24
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
25
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ end
27
+ spec.bindir = 'exe'
28
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ['lib']
30
+
31
+ spec.add_dependency 'faraday', '~> 2.0'
32
+ spec.add_dependency 'legion-cache', '>= 1.3.11'
33
+ spec.add_dependency 'legion-crypt', '>= 1.4.9'
34
+ spec.add_dependency 'legion-data', '>= 1.4.17'
35
+ spec.add_dependency 'legion-json', '>= 1.2.1'
36
+ spec.add_dependency 'legion-logging', '>= 1.3.2'
37
+ spec.add_dependency 'legion-settings', '>= 1.3.14'
38
+ spec.add_dependency 'legion-transport', '>= 1.3.9'
39
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'helpers/client'
4
+ require_relative 'runners/player'
5
+ require_relative 'runners/zones'
6
+ require_relative 'runners/favorites'
7
+
8
+ module Legion
9
+ module Extensions
10
+ module Sonos
11
+ class Client
12
+ include Helpers::Client
13
+ include Runners::Player
14
+ include Runners::Zones
15
+ include Runners::Favorites
16
+
17
+ attr_reader :opts
18
+
19
+ def initialize(url: 'http://localhost:5005', **extra)
20
+ @opts = { url: url, **extra }
21
+ end
22
+
23
+ def settings
24
+ { options: @opts }
25
+ end
26
+
27
+ def connection(**override)
28
+ Helpers::Client.connection(**@opts, **override)
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'faraday'
4
+
5
+ module Legion
6
+ module Extensions
7
+ module Sonos
8
+ module Helpers
9
+ module Client
10
+ module_function
11
+
12
+ def connection(url: 'http://localhost:5005', **_opts)
13
+ Faraday.new(url: url) do |conn|
14
+ conn.request :json
15
+ conn.response :json, content_type: /\bjson$/
16
+ conn.adapter Faraday.default_adapter
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'uri'
4
+
5
+ module Legion
6
+ module Extensions
7
+ module Sonos
8
+ module Runners
9
+ module Favorites
10
+ def list_favorites(**)
11
+ resp = connection(**).get('/favorites')
12
+ { favorites: resp.body }
13
+ end
14
+
15
+ def play_favorite(room:, name:, **)
16
+ encoded_room = URI.encode_www_form_component(room)
17
+ encoded_name = URI.encode_www_form_component(name)
18
+ resp = connection(**).get("/#{encoded_room}/favorite/#{encoded_name}")
19
+ { status: resp.body }
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'uri'
4
+
5
+ module Legion
6
+ module Extensions
7
+ module Sonos
8
+ module Runners
9
+ module Player
10
+ def play(room:, **)
11
+ resp = connection(**).get("/#{URI.encode_www_form_component(room)}/play")
12
+ { status: resp.body }
13
+ end
14
+
15
+ def pause(room:, **)
16
+ resp = connection(**).get("/#{URI.encode_www_form_component(room)}/pause")
17
+ { status: resp.body }
18
+ end
19
+
20
+ def stop(room:, **)
21
+ resp = connection(**).get("/#{URI.encode_www_form_component(room)}/stop")
22
+ { status: resp.body }
23
+ end
24
+
25
+ def next_track(room:, **)
26
+ resp = connection(**).get("/#{URI.encode_www_form_component(room)}/next")
27
+ { status: resp.body }
28
+ end
29
+
30
+ def previous_track(room:, **)
31
+ resp = connection(**).get("/#{URI.encode_www_form_component(room)}/previous")
32
+ { status: resp.body }
33
+ end
34
+
35
+ def volume(room:, level:, **)
36
+ resp = connection(**).get("/#{URI.encode_www_form_component(room)}/volume/#{level}")
37
+ { status: resp.body }
38
+ end
39
+
40
+ def mute(room:, **)
41
+ resp = connection(**).get("/#{URI.encode_www_form_component(room)}/mute")
42
+ { status: resp.body }
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'uri'
4
+
5
+ module Legion
6
+ module Extensions
7
+ module Sonos
8
+ module Runners
9
+ module Zones
10
+ def list_zones(**)
11
+ resp = connection(**).get('/zones')
12
+ { zones: resp.body }
13
+ end
14
+
15
+ def zone_state(room:, **)
16
+ resp = connection(**).get("/#{URI.encode_www_form_component(room)}/state")
17
+ { state: resp.body }
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module Sonos
6
+ VERSION = '0.2.1'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'legion/extensions/sonos/version'
4
+ require 'legion/extensions/sonos/helpers/client'
5
+ require 'legion/extensions/sonos/runners/player'
6
+ require 'legion/extensions/sonos/runners/zones'
7
+ require 'legion/extensions/sonos/runners/favorites'
8
+ require 'legion/extensions/sonos/client'
9
+
10
+ module Legion
11
+ module Extensions
12
+ module Sonos
13
+ extend Legion::Extensions::Core if Legion::Extensions.const_defined? :Core
14
+ end
15
+ end
16
+ end
metadata ADDED
@@ -0,0 +1,181 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lex-sonos
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
5
+ platform: ruby
6
+ authors:
7
+ - Esity
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: faraday
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '2.0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '2.0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: legion-cache
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.3.11
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 1.3.11
40
+ - !ruby/object:Gem::Dependency
41
+ name: legion-crypt
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 1.4.9
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 1.4.9
54
+ - !ruby/object:Gem::Dependency
55
+ name: legion-data
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 1.4.17
61
+ type: :runtime
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: 1.4.17
68
+ - !ruby/object:Gem::Dependency
69
+ name: legion-json
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 1.2.1
75
+ type: :runtime
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: 1.2.1
82
+ - !ruby/object:Gem::Dependency
83
+ name: legion-logging
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: 1.3.2
89
+ type: :runtime
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: 1.3.2
96
+ - !ruby/object:Gem::Dependency
97
+ name: legion-settings
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: 1.3.14
103
+ type: :runtime
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: 1.3.14
110
+ - !ruby/object:Gem::Dependency
111
+ name: legion-transport
112
+ requirement: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: 1.3.9
117
+ type: :runtime
118
+ prerelease: false
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: 1.3.9
124
+ description: Used to connect Legion to Sonos speakers
125
+ email:
126
+ - matthewdiverson@gmail.com
127
+ executables: []
128
+ extensions: []
129
+ extra_rdoc_files: []
130
+ files:
131
+ - ".github/CODEOWNERS"
132
+ - ".github/dependabot.yml"
133
+ - ".github/workflows/ci.yml"
134
+ - ".gitignore"
135
+ - ".rspec"
136
+ - ".rubocop.yml"
137
+ - CHANGELOG.md
138
+ - CLAUDE.md
139
+ - Gemfile
140
+ - LICENSE
141
+ - LICENSE.txt
142
+ - README.md
143
+ - Rakefile
144
+ - bin/console
145
+ - bin/setup
146
+ - lex-sonos.gemspec
147
+ - lib/legion/extensions/sonos.rb
148
+ - lib/legion/extensions/sonos/client.rb
149
+ - lib/legion/extensions/sonos/helpers/client.rb
150
+ - lib/legion/extensions/sonos/runners/favorites.rb
151
+ - lib/legion/extensions/sonos/runners/player.rb
152
+ - lib/legion/extensions/sonos/runners/zones.rb
153
+ - lib/legion/extensions/sonos/version.rb
154
+ homepage: https://github.com/LegionIO/lex-sonos
155
+ licenses:
156
+ - MIT
157
+ metadata:
158
+ homepage_uri: https://github.com/LegionIO/lex-sonos
159
+ source_code_uri: https://github.com/LegionIO/lex-sonos
160
+ documentation_uri: https://github.com/LegionIO/lex-sonos
161
+ changelog_uri: https://github.com/LegionIO/lex-sonos/blob/main/CHANGELOG.md
162
+ bug_tracker_uri: https://github.com/LegionIO/lex-sonos/issues
163
+ rubygems_mfa_required: 'true'
164
+ rdoc_options: []
165
+ require_paths:
166
+ - lib
167
+ required_ruby_version: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ version: '3.4'
172
+ required_rubygems_version: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ version: '0'
177
+ requirements: []
178
+ rubygems_version: 3.6.9
179
+ specification_version: 4
180
+ summary: LEX::Sonos
181
+ test_files: []