switchbot 0.5.1 → 0.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b35104bc79a51e707f6a2295423a135e5ee06380eb4f5b2ad14b1fea15a72288
4
- data.tar.gz: d01885018b1ff8759a6ac2c8b1e2c14704d2e15105b282e74c24cc2a937a8f84
3
+ metadata.gz: 63cae60c41beb637fe0fea73a634a4ef3e4f4d32354fe3691d16e0e88a24f9fd
4
+ data.tar.gz: 9a2aa83c764d5595142d2c07e31c5fd8404ab6ceb4e2f9481801498eeb135f3f
5
5
  SHA512:
6
- metadata.gz: a3ecbbc03b18cbf6e7650f0171b645055a25eb541f1115b689fb7cde2a34a622f2f6ee898944fd45dacbd6cc6ebbbb0b0478bcdfb0e9e6703938fe24716c76e9
7
- data.tar.gz: 6c0fcb55db5bb61d78ed247dc2dc9c40a269dc4bed68a27832b1a22f74a718d68055f1fa40483603fc33c771be6f77ff0cd4980deee43f89b9928703162ac7bd
6
+ metadata.gz: 90501fd6d95b927e0c2d4fb741c384777947765b305ce0e8672f2da72aa62158dc98179cb01f1924af71725cc0d5d2bcf3292e7990f293d543535ba38b16f3f5
7
+ data.tar.gz: faaf06892d72c0eaf1df45ad1091fcf05e30390d12bac1c3264932216742e2980606fb2b5f050978716b0eb40a0430f5af2f1d2f16c7905ac3b393902603c834
@@ -8,7 +8,7 @@ jobs:
8
8
  strategy:
9
9
  matrix:
10
10
  # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
11
- ruby: [2.5, 2.6, 2.7, '3.0', 3.1]
11
+ ruby: [2.6, 2.7, '3.0', 3.1]
12
12
  name: Ruby ${{ matrix.ruby }}
13
13
  steps:
14
14
  - uses: actions/checkout@v2
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.5
2
+ TargetRubyVersion: 2.6
3
3
  NewCops: enable
4
4
 
5
5
  Style/Documentation:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## Unreleased
2
- [full changelog](http://github.com/ytkg/switchbot/compare/v0.5.1...main)
2
+ [full changelog](http://github.com/ytkg/switchbot/compare/v0.6.0...main)
3
+
4
+ ## v0.6.0
5
+ [full changelog](http://github.com/ytkg/switchbot/compare/v0.5.1...v0.6.0)
6
+
7
+ * Add ColorBulb
8
+ * https://github.com/ytkg/switchbot/pull/14
9
+ * :bomb: **[BREAKING CHANGE]** Update faraday v2 and Drop support ruby 2.5
10
+ * https://github.com/ytkg/switchbot/pull/12
3
11
 
4
12
  ## v0.5.1
5
13
  [full changelog](http://github.com/ytkg/switchbot/compare/v0.5.0...v0.5.1)
@@ -68,6 +68,10 @@ module Switchbot
68
68
  Humidifier.new(client: self, device_id: device_id)
69
69
  end
70
70
 
71
+ def color_bulb(device_id)
72
+ ColorBulb.new(client: self, device_id: device_id)
73
+ end
74
+
71
75
  private
72
76
 
73
77
  def headers
@@ -80,12 +84,13 @@ module Switchbot
80
84
  def connection
81
85
  Faraday.new(url: API_ENDPOINT, headers: headers) do |conn|
82
86
  conn.request :json
87
+ conn.response :json
83
88
  end
84
89
  end
85
90
 
86
91
  def request(http_method:, endpoint:, params: {})
87
92
  response = connection.public_send(http_method, endpoint, params)
88
- JSON.parse(response.body).deep_transform_keys(&:underscore).deep_symbolize_keys
93
+ response.body.deep_transform_keys(&:underscore).deep_symbolize_keys
89
94
  end
90
95
  end
91
96
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Switchbot
4
+ class ColorBulb < Device
5
+ def toggle
6
+ commands(command: 'toggle')
7
+ end
8
+
9
+ def brightness(value)
10
+ commands(command: 'setBrightness', parameter: value)
11
+ end
12
+
13
+ def color(value)
14
+ commands(command: 'setColor', parameter: value)
15
+ end
16
+
17
+ def color_temperature(value)
18
+ commands(command: 'setColorTemperature', parameter: value)
19
+ end
20
+ end
21
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Switchbot
4
- VERSION = '0.5.1'
4
+ VERSION = '0.6.0'
5
5
  end
data/lib/switchbot.rb CHANGED
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'faraday'
4
- require 'faraday_middleware'
5
- require 'json'
6
4
  require 'active_support/all'
7
5
  require_relative 'switchbot/version'
8
6
  require_relative 'switchbot/client'
@@ -11,6 +9,7 @@ require_relative 'switchbot/scene'
11
9
  require_relative 'switchbot/bot'
12
10
  require_relative 'switchbot/light'
13
11
  require_relative 'switchbot/humidifier'
12
+ require_relative 'switchbot/color_bulb'
14
13
 
15
14
  module Switchbot
16
15
  class Error < StandardError; end
data/switchbot.gemspec CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = 'SwitchBot API client for Ruby'
13
13
  spec.homepage = 'https://github.com/ytkg/switchbot'
14
14
  spec.license = 'MIT'
15
- spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
16
16
 
17
17
  # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
18
18
 
@@ -32,8 +32,7 @@ Gem::Specification.new do |spec|
32
32
 
33
33
  # Uncomment to register a new dependency of your gem
34
34
  spec.add_dependency 'activesupport'
35
- spec.add_dependency 'faraday', '~> 1.3.0'
36
- spec.add_dependency 'faraday_middleware'
35
+ spec.add_dependency 'faraday', '>= 2.0.0'
37
36
 
38
37
  spec.add_development_dependency 'rake', '~> 13.0'
39
38
  spec.add_development_dependency 'rspec', '~> 3.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: switchbot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoshiki Takagi
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-04 00:00:00.000000000 Z
11
+ date: 2022-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -26,32 +26,18 @@ dependencies:
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: faraday
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: 1.3.0
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: 1.3.0
41
- - !ruby/object:Gem::Dependency
42
- name: faraday_middleware
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
31
  - - ">="
46
32
  - !ruby/object:Gem::Version
47
- version: '0'
33
+ version: 2.0.0
48
34
  type: :runtime
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
38
  - - ">="
53
39
  - !ruby/object:Gem::Version
54
- version: '0'
40
+ version: 2.0.0
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: rake
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -144,6 +130,7 @@ files:
144
130
  - lib/switchbot.rb
145
131
  - lib/switchbot/bot.rb
146
132
  - lib/switchbot/client.rb
133
+ - lib/switchbot/color_bulb.rb
147
134
  - lib/switchbot/device.rb
148
135
  - lib/switchbot/humidifier.rb
149
136
  - lib/switchbot/light.rb
@@ -158,7 +145,7 @@ metadata:
158
145
  source_code_uri: https://github.com/ytkg/switchbot
159
146
  changelog_uri: https://github.com/ytkg/switchbot/blob/main/CHANGELOG.md
160
147
  rubygems_mfa_required: 'true'
161
- post_install_message:
148
+ post_install_message:
162
149
  rdoc_options: []
163
150
  require_paths:
164
151
  - lib
@@ -166,15 +153,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
166
153
  requirements:
167
154
  - - ">="
168
155
  - !ruby/object:Gem::Version
169
- version: 2.5.0
156
+ version: 2.6.0
170
157
  required_rubygems_version: !ruby/object:Gem::Requirement
171
158
  requirements:
172
159
  - - ">="
173
160
  - !ruby/object:Gem::Version
174
161
  version: '0'
175
162
  requirements: []
176
- rubygems_version: 3.3.3
177
- signing_key:
163
+ rubygems_version: 3.1.6
164
+ signing_key:
178
165
  specification_version: 4
179
166
  summary: SwitchBot API client for Ruby
180
167
  test_files: []