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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bde651d183da7dc9b3e17dcf9a4789fb1f2e16ca089909f8440b87056a23baf7
4
- data.tar.gz: eb0416ba45e6545674ff3cbf12172db87feee358fddd3eeedfa96056869e6f6a
3
+ metadata.gz: c2f2f0081d0d4b1874804b5bd5967531aa3b49672e5669c74d8d0b78ebc5deac
4
+ data.tar.gz: 73fbfa1bfb32019e32913ed3859ac9805742ba3d7c65c7fe1234d4b8b347933b
5
5
  SHA512:
6
- metadata.gz: 9ae0c01ddfcc21e87a38e3d5977ff54a7233ff73bbf9544bb1903534ca6cc26388abbc9c2871a34e00b271aec767f58e00d3191445e5abb6f3b984d0a55c92f0
7
- data.tar.gz: 3f8b61f1abdeae98b6ba07ce6f1126ea6142df78fe446d8a5933dab1b57384bb23e5ca68adcb2d9b654307a851ba67b4ded64b2eb105f7612ebc6e3643b0eb09
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Rbnput
4
4
  # Current version of the gem
5
- VERSION = "1.4.0"
5
+ VERSION = "1.4.1"
6
6
 
7
7
  # Gem Author
8
8
  AUTHOR = "Krist Ponpairin"
@@ -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.0
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
- - README.md
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