rbnput-darwin-minimal 1.4.0 → 1.4.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 +4 -4
- data/examples/keyboard_listener.rb +38 -0
- data/lib/rbnput/version.rb +1 -1
- data/rbnput-darwin-minimal.gemspec +35 -0
- metadata +7 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c2f2f0081d0d4b1874804b5bd5967531aa3b49672e5669c74d8d0b78ebc5deac
|
|
4
|
+
data.tar.gz: 73fbfa1bfb32019e32913ed3859ac9805742ba3d7c65c7fe1234d4b8b347933b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cce2cccc53b4aaadd515a6f6f594ab9d2efbbc81c70f020c6ec34577504e7e0738f3471e24cee5f87a6fe9bb954f8fb2d973ae5a8777e6c7ba547576a7ba9578
|
|
7
|
+
data.tar.gz: 97d32793cc1cf609be17c97a3037c0c8c325cef3bda65d5e8dada8467acf3802a7525493420f05b0cee99cd7771f842e7ba67f76e2ae9abafba6f07f3b7485c8
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
MODE = ENV.fetch("APP_MODE", "local").to_sym
|
|
5
|
+
|
|
6
|
+
# กำหนดการโหลด Library หรือไฟล์
|
|
7
|
+
# Load Library
|
|
8
|
+
case MODE
|
|
9
|
+
when :local; require_relative '../lib/rbnput-darwin-minimal' # โหลดจากไฟล์ในเครื่อง (local)
|
|
10
|
+
when :prod; require 'rbnput-darwin-minimal' # โหลดจาก gem ที่ติดตั้งแล้ว (production)
|
|
11
|
+
else; raise "Unknown MODE #{MODE.inspect}" # แสดงข้อผิดพลาดหากไม่รู้จักโหมด
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# ตัวอย่าง: การดักจับเหตุการณ์คีย์บอร์ด
|
|
15
|
+
# Example: Monitoring keyboard events
|
|
16
|
+
puts "=== Keyboard Listener Example (#{MODE}) ==="
|
|
17
|
+
puts "Press any keys. Press Ctrl+C to exit."
|
|
18
|
+
puts "กดปุ่มใดๆ บนคีย์บอร์ด. กด Ctrl+C เพื่อออกจากโปรแกรม."
|
|
19
|
+
puts
|
|
20
|
+
|
|
21
|
+
# สร้างและเริ่มตัวดักจับ (Create and start listener)
|
|
22
|
+
listener = Rbnput::Listener.new
|
|
23
|
+
listener.on_press do |key|
|
|
24
|
+
# ทำงานเมื่อมีการกดปุ่ม
|
|
25
|
+
puts "\b ⬇️ up : #{key} (กด)"
|
|
26
|
+
end
|
|
27
|
+
listener.on_release do |key|
|
|
28
|
+
# ทำงานเมื่อมีการปล่อยปุ่ม
|
|
29
|
+
puts "\b ⬆️ down : #{key} (ปล่อย)"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
begin
|
|
33
|
+
listener.start # เริ่ม thread การทำงาน (start thread)
|
|
34
|
+
listener.join # รอให้ thread ทำงานจนจบ (wait thread exit)
|
|
35
|
+
rescue Interrupt
|
|
36
|
+
puts "\nStopping listener..."
|
|
37
|
+
puts "Listener stopped. (หยุดการทำงาน)"
|
|
38
|
+
end
|
data/lib/rbnput/version.rb
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require_relative "lib/rbnput/version"
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |spec|
|
|
4
|
+
spec.name = "rbnput-darwin-minimal"
|
|
5
|
+
spec.version = Rbnput::VERSION
|
|
6
|
+
spec.authors = ["Krist Ponpairin"]
|
|
7
|
+
spec.email = ["krist7599555@gmail.com"]
|
|
8
|
+
|
|
9
|
+
spec.summary = "Minimal Ruby keyboard listener for macOS using FFI"
|
|
10
|
+
spec.description = "Lightweight Ruby library for low-level keyboard monitoring on macOS, implemented through FFI bindings to Darwin system libraries."
|
|
11
|
+
|
|
12
|
+
# 🏡 Project Links
|
|
13
|
+
spec.homepage = "https://github.com/krist7599555/rbnput-darwin-minimal"
|
|
14
|
+
spec.metadata = {
|
|
15
|
+
"homepage_uri" => "https://github.com/krist7599555/rbnput-darwin-minimal",
|
|
16
|
+
"source_code_uri" => "https://github.com/krist7599555/rbnput-darwin-minimal",
|
|
17
|
+
"bug_tracker_uri" => "https://github.com/krist7599555/rbnput-darwin-minimal/issues",
|
|
18
|
+
"documentation_uri" => "https://github.com/krist7599555/rbnput-darwin-minimal",
|
|
19
|
+
"changelog_uri" => "https://github.com/krist7599555/rbnput-darwin-minimal/releases"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# 📦 Files
|
|
24
|
+
spec.files = Dir["{lib,examples}/**/*.rb"] + ['rbnput-darwin-minimal.gemspec', "README.md", "LICENSE"]
|
|
25
|
+
spec.require_paths = ["lib"]
|
|
26
|
+
|
|
27
|
+
# 💎 Dependencies
|
|
28
|
+
spec.add_dependency "ffi", "~> 1.15"
|
|
29
|
+
|
|
30
|
+
# Ruby version
|
|
31
|
+
spec.required_ruby_version = ">= 3.0"
|
|
32
|
+
|
|
33
|
+
spec.rdoc_options = ['--main', 'README.md']
|
|
34
|
+
spec.extra_rdoc_files = ['LICENSE']
|
|
35
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rbnput-darwin-minimal
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.4.
|
|
4
|
+
version: 1.4.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Krist Ponpairin
|
|
@@ -30,10 +30,11 @@ email:
|
|
|
30
30
|
executables: []
|
|
31
31
|
extensions: []
|
|
32
32
|
extra_rdoc_files:
|
|
33
|
-
-
|
|
33
|
+
- LICENSE
|
|
34
34
|
files:
|
|
35
35
|
- LICENSE
|
|
36
36
|
- README.md
|
|
37
|
+
- examples/keyboard_listener.rb
|
|
37
38
|
- lib/rbnput-darwin-minimal.rb
|
|
38
39
|
- lib/rbnput/darwin_ffi.rb
|
|
39
40
|
- lib/rbnput/darwin_listener.rb
|
|
@@ -41,6 +42,7 @@ files:
|
|
|
41
42
|
- lib/rbnput/key_code_const.rb
|
|
42
43
|
- lib/rbnput/simple_mutex_thread.rb
|
|
43
44
|
- lib/rbnput/version.rb
|
|
45
|
+
- rbnput-darwin-minimal.gemspec
|
|
44
46
|
homepage: https://github.com/krist7599555/rbnput-darwin-minimal
|
|
45
47
|
licenses: []
|
|
46
48
|
metadata:
|
|
@@ -49,7 +51,9 @@ metadata:
|
|
|
49
51
|
bug_tracker_uri: https://github.com/krist7599555/rbnput-darwin-minimal/issues
|
|
50
52
|
documentation_uri: https://github.com/krist7599555/rbnput-darwin-minimal
|
|
51
53
|
changelog_uri: https://github.com/krist7599555/rbnput-darwin-minimal/releases
|
|
52
|
-
rdoc_options:
|
|
54
|
+
rdoc_options:
|
|
55
|
+
- "--main"
|
|
56
|
+
- README.md
|
|
53
57
|
require_paths:
|
|
54
58
|
- lib
|
|
55
59
|
required_ruby_version: !ruby/object:Gem::Requirement
|