agent_status_bulb 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c2183f0e22cc7a3779f409df20894bdf032f6e2c2a342c72553f838e00d27c76
4
+ data.tar.gz: 0def7cc82dcf2aaa15b031c9275c01da270d939841b59e7ca0a6c3b018544f94
5
+ SHA512:
6
+ metadata.gz: 517a923a5b5011fd1dccce4c9e53aec9610ce278f485b148000cf99660162867ff8e53868d89e792ac7ff1b7d5feaadf709ab929bdb2000d1f0f6354124a33c4
7
+ data.tar.gz: 6c7cd63f36191263c4ef9b7f0527e76b672bd8cf3ce2757e8f4fbfef21f584d461161698bdf8cf95239210acbbe0f8081d9f7f70732e826b787b7ab360526d62
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,10 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.0
3
+ NewCops: enable
4
+
5
+ plugins:
6
+ - rubocop-rake
7
+ - rubocop-rspec
8
+
9
+ Style/Documentation:
10
+ Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2025-11-18
4
+
5
+ - Initial release
@@ -0,0 +1,132 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official email address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ [INSERT CONTACT METHOD].
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
+ [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Yoshiki Takagi
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,50 @@
1
+ # AgentStatusBulb
2
+
3
+ Control a SwitchBot Color Bulb based on agent status.
4
+ Provides simple commands (`asb run`, `asb wait`, `asb idle`, `asb off`) to visualize the state of any agent or task through color changes.
5
+
6
+ ## Installation
7
+
8
+ Install the gem:
9
+
10
+ ```bash
11
+ gem install agent_status_bulb
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ Configure your SwitchBot credentials and bulb device:
17
+
18
+ ```bash
19
+ asb configure
20
+ # Token: (hidden input)
21
+ # Secret: (hidden input)
22
+ # Device ID: (visible input)
23
+ ```
24
+
25
+ Then control the bulb:
26
+
27
+ ```bash
28
+ asb run # blue
29
+ asb wait # orange
30
+ asb idle # green
31
+ asb off # turn off
32
+ ```
33
+
34
+ Config file is stored at `~/.config/agent_status_bulb.yml`.
35
+
36
+ ## Development
37
+
38
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
39
+
40
+ ## Contributing
41
+
42
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ytkg/agent_status_bulb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/ytkg/agent_status_bulb/blob/main/CODE_OF_CONDUCT.md).
43
+
44
+ ## License
45
+
46
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
47
+
48
+ ## Code of Conduct
49
+
50
+ Everyone interacting in the AgentStatusBulb project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ytkg/agent_status_bulb/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
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
+ require 'rubocop/rake_task'
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/exe/asb ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'agent_status_bulb/cli'
5
+
6
+ exit AgentStatusBulb::Cli.start(ARGV)
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'agent_status_bulb'
4
+ require 'switchbot'
5
+ require 'agent_status_bulb/configure'
6
+
7
+ module AgentStatusBulb
8
+ class Cli
9
+ def self.start(argv)
10
+ new(argv).run
11
+ end
12
+
13
+ def initialize(argv, io: $stdin, out: $stdout, err: $stderr)
14
+ @argv = argv.dup
15
+ @io = io
16
+ @out = out
17
+ @err = err
18
+ end
19
+
20
+ def run
21
+ command = @argv.shift
22
+ handle_command(command)
23
+ rescue StandardError => e
24
+ @err.puts(e.message)
25
+ 1
26
+ end
27
+
28
+ private
29
+
30
+ def handle_command(command)
31
+ return configure! if command == 'configure'
32
+ return apply!(command) if status_colors.key?(command) || command == 'off'
33
+
34
+ @err.puts usage
35
+ 1
36
+ end
37
+
38
+ def configure!
39
+ configurator.configure!
40
+ 0
41
+ end
42
+
43
+ def apply!(command)
44
+ bulb = build_bulb(configurator.load!)
45
+ apply_status(bulb, command)
46
+ 0
47
+ end
48
+
49
+ def build_bulb(config)
50
+ client = Switchbot::Client.new(config[:token], config[:secret])
51
+ bulb = client.color_bulb(config[:device_id])
52
+ bulb.on if bulb.off?
53
+ bulb
54
+ end
55
+
56
+ def apply_status(bulb, command)
57
+ return bulb.off if command == 'off'
58
+
59
+ bulb.color(status_colors.fetch(command))
60
+ end
61
+
62
+ def usage
63
+ "Usage: #{File.basename($PROGRAM_NAME)} [run|wait|idle|off|configure]"
64
+ end
65
+
66
+ def configurator
67
+ @configurator ||= AgentStatusBulb::Configure.new(io: @io, out: @out)
68
+ end
69
+
70
+ def status_colors
71
+ {
72
+ 'idle' => '0:255:0',
73
+ 'run' => '0:0:255',
74
+ 'wait' => '255:125:0'
75
+ }
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fileutils'
4
+ require 'yaml'
5
+ require 'io/console'
6
+
7
+ module AgentStatusBulb
8
+ class Configure
9
+ DEFAULT_PATH = File.expand_path('~/.config/agent_status_bulb.yml').freeze
10
+
11
+ def initialize(path: DEFAULT_PATH, io: $stdin, out: $stdout)
12
+ @path = path
13
+ @io = io
14
+ @out = out
15
+ end
16
+
17
+ def configure!
18
+ token = prompt('Token', conceal: true)
19
+ secret = prompt('Secret', conceal: true)
20
+ device_id = prompt('Device ID')
21
+
22
+ FileUtils.mkdir_p(File.dirname(@path))
23
+ File.write(@path, { 'token' => token, 'secret' => secret, 'device_id' => device_id }.to_yaml)
24
+ @out.puts "Saved config to: #{@path}"
25
+ end
26
+
27
+ def load!
28
+ raise "Config file not found: #{@path}" unless File.file?(@path)
29
+
30
+ data = YAML.safe_load_file(@path, permitted_classes: [], aliases: false) || {}
31
+ token = data['token'].to_s
32
+ secret = data['secret'].to_s
33
+ device_id = data['device_id'].to_s
34
+
35
+ if token.empty? || secret.empty? || device_id.empty?
36
+ raise "Config must contain token, secret, and device_id: #{@path}"
37
+ end
38
+
39
+ { token: token, secret: secret, device_id: device_id }
40
+ end
41
+
42
+ private
43
+
44
+ def prompt(label, conceal: false)
45
+ @out.print "#{label}: "
46
+ input = conceal ? @io.noecho(&:gets) : @io.gets
47
+ @out.puts if conceal
48
+ input.to_s.strip
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AgentStatusBulb
4
+ VERSION = '0.1.0'
5
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'agent_status_bulb/version'
4
+
5
+ module AgentStatusBulb
6
+ class Error < StandardError; end
7
+ # Your code goes here...
8
+ end
@@ -0,0 +1,4 @@
1
+ module AgentStatusBulb
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: agent_status_bulb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Yoshiki Takagi
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2025-11-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: switchbot
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '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'
27
+ description: Provides simple commands (asb run, asb wait, asb idle) to visualize the
28
+ state of any agent or task through color changes.
29
+ email:
30
+ - yoshiki.tkg@gmail.com
31
+ executables:
32
+ - asb
33
+ extensions: []
34
+ extra_rdoc_files: []
35
+ files:
36
+ - ".rspec"
37
+ - ".rubocop.yml"
38
+ - CHANGELOG.md
39
+ - CODE_OF_CONDUCT.md
40
+ - LICENSE.txt
41
+ - README.md
42
+ - Rakefile
43
+ - exe/asb
44
+ - lib/agent_status_bulb.rb
45
+ - lib/agent_status_bulb/cli.rb
46
+ - lib/agent_status_bulb/configure.rb
47
+ - lib/agent_status_bulb/version.rb
48
+ - sig/agent_status_bulb.rbs
49
+ homepage: https://github.com/ytkg/agent_status_bulb
50
+ licenses:
51
+ - MIT
52
+ metadata:
53
+ homepage_uri: https://github.com/ytkg/agent_status_bulb
54
+ source_code_uri: https://github.com/ytkg/agent_status_bulb
55
+ changelog_uri: https://github.com/ytkg/agent_status_bulb/blob/main/CHANGELOG.md
56
+ rubygems_mfa_required: 'true'
57
+ post_install_message:
58
+ rdoc_options: []
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: 3.0.0
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubygems_version: 3.5.16
73
+ signing_key:
74
+ specification_version: 4
75
+ summary: Control a SwitchBot Color Bulb based on agent status.
76
+ test_files: []