rbzk 0.1.0 → 0.1.2

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: 05c19d8aa64a72f6ca80b430058d5956f2c8250a59c60fb26548c9f546d62c3f
4
- data.tar.gz: 3ddd33169741c8f2df4046e9add74e21b4f8e4faccc8b5beb25994ac4b546cdc
3
+ metadata.gz: c4e93719b6428a029bf767e708352ee0ac29e26735050288b5848eb9aea2c7b7
4
+ data.tar.gz: b40b96e9c5b4f123f93314a4f51730286a7b5a1d59b5f6e16322b6a583e9f766
5
5
  SHA512:
6
- metadata.gz: 296b1eba45da43e51ef8e228fec546ad6b14894f1279219e66ff8f546469bb81e3a848f857d30b352a6a9db201762eee41a438ff606d041fe2e574e254840eab
7
- data.tar.gz: 6132ea677b868d354db28fc26e32087b933234985a7aaccfc029da1f220bd1655865350b086ef1cc8756f6f190ba41162ef5deaa36f8aa55c8f947d1076b9d38
6
+ metadata.gz: be9a441a5718f1733bfd03181461767f4f2c3f76951f643e35d8c17efbfceef7b3db420fbf58ba757ab146a0b2756fcdfc4ad791dfea67536ed11b26019cdc29
7
+ data.tar.gz: 73687d3eb95d16bb53e6e2e1abb33e94e14afd8f235610933d3923284f213b4b73a61fbec2d8d20d8459bc33e03d8311bdff5e4cdd612907b45412b912535016
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  A Ruby implementation of the ZK protocol for fingerprint and biometric attendance devices.
4
4
 
5
+ This project is inspired by and based on the [pyzk Python library](https://github.com/fananimi/pyzk), adapting its protocol implementation to Ruby while maintaining compatibility with ZKTeco devices.
6
+
5
7
  ## Installation
6
8
 
7
9
  Add this line to your application's Gemfile:
@@ -191,9 +193,168 @@ ensure
191
193
  end
192
194
  ```
193
195
 
194
- ### Complete Example
196
+ ## Command Line Interface
197
+
198
+ RBZK provides a powerful command-line interface for interacting with ZKTeco devices. The CLI is built using Thor, which provides a clean, intuitive interface similar to Git and other modern command-line tools.
199
+
200
+ ### Installation
201
+
202
+ After installing the gem, you can use the `rbzk` command directly:
203
+
204
+ ```bash
205
+ # Install the gem
206
+ gem install rbzk
207
+
208
+ # Use the command
209
+ bin/rbzk info 192.168.100.201
210
+ ```
211
+
212
+ If you're using Bundler, you can run the command through `bundle exec`:
213
+
214
+ ```bash
215
+ bundle exec rbzk info 192.168.100.201
216
+ ```
217
+
218
+ ### Available Commands
219
+
220
+ ```bash
221
+ # Get help
222
+ bin/rbzk help
223
+
224
+ # Get help for a specific command
225
+ bin/rbzk help logs
226
+ ```
227
+
228
+ #### Device Information
229
+
230
+ ```bash
231
+ # Get device information
232
+ bin/rbzk info 192.168.100.201 [options]
233
+ ```
234
+
235
+ #### Users
236
+
237
+ ```bash
238
+ # Get users from the device
239
+ bin/rbzk users 192.168.100.201 [options]
240
+ ```
241
+
242
+ #### Attendance Logs
243
+
244
+ ```bash
245
+ # Get all attendance logs
246
+ bin/rbzk logs 192.168.100.201 [options]
247
+
248
+ # Get today's logs
249
+ bin/rbzk logs 192.168.100.201 --today [options]
250
+
251
+ # Get yesterday's logs
252
+ bin/rbzk logs 192.168.100.201 --yesterday [options]
253
+
254
+ # Get this week's logs
255
+ bin/rbzk logs 192.168.100.201 --week [options]
256
+
257
+ # Get this month's logs
258
+ bin/rbzk logs 192.168.100.201 --month [options]
259
+
260
+ # Get logs for a custom date range
261
+ bin/rbzk logs 192.168.100.201 --start-date=2023-01-01 --end-date=2023-01-31 [options]
262
+ ```
263
+
264
+ #### Clear Logs
265
+
266
+ ```bash
267
+ # Clear attendance logs (will prompt for confirmation)
268
+ bin/rbzk clear_logs 192.168.100.201 [options]
269
+ ```
270
+
271
+ #### Test Voice
272
+
273
+ ```bash
274
+ # Test the device voice
275
+ bin/rbzk test_voice 192.168.100.201 [options]
276
+ ```
277
+
278
+ ### Global Options
279
+
280
+ These options can be used with any command:
281
+
282
+ ```
283
+ --ip=IP # Device IP address (default: from config or 192.168.100.201)
284
+ --port=PORT # Device port (default: from config or 4370)
285
+ --timeout=SECONDS # Connection timeout in seconds (default: from config or 30)
286
+ --password=PASSWORD # Device password (default: from config or 0)
287
+ --verbose # Enable verbose output (default: from config or false)
288
+ --force-udp # Use UDP instead of TCP (default: from config or false)
289
+ --no-ping # Skip ping check (default: from config or true)
290
+ --encoding=ENCODING # Character encoding (default: from config or UTF-8)
291
+ ```
292
+
293
+ ### Configuration
294
+
295
+ RBZK supports persistent configuration through a configuration file. This allows you to set default values for IP address and other options without having to specify them every time.
296
+
297
+ #### Configuration File Location
298
+
299
+ The configuration file is stored in one of the following locations (in order of precedence):
300
+
301
+ 1. `$XDG_CONFIG_HOME/rbzk/config.yml` (if `$XDG_CONFIG_HOME` is set)
302
+ 2. `$HOME/.config/rbzk/config.yml` (on most systems)
303
+ 3. `.rbzk.yml` in the current directory (fallback)
304
+
305
+ #### Configuration Commands
306
+
307
+ ```bash
308
+ # Show current configuration
309
+ bin/rbzk config
310
+
311
+ # Set a configuration value
312
+ bin/rbzk config-set ip 192.168.1.201
313
+ bin/rbzk config-set port 4371
314
+ bin/rbzk config-set password 12345
315
+ bin/rbzk config-set verbose true
316
+
317
+ # Reset configuration to defaults
318
+ bin/rbzk config-reset
319
+ ```
320
+
321
+ When you run commands, the CLI will use values from the configuration file as defaults. Command-line options will override the configuration file values.
322
+
323
+ ### Examples
324
+
325
+ ```bash
326
+ # Get device information
327
+ bin/rbzk info 192.168.100.201
328
+
329
+ # Get users with custom port and password
330
+ bin/rbzk users 192.168.100.201 --port=4371 --password=12345
331
+
332
+ # Get today's attendance logs with verbose output
333
+ bin/rbzk logs 192.168.100.201 --today --verbose
334
+
335
+ # Get logs for a custom date range (two ways)
336
+ bin/rbzk logs-custom 2023-01-01 2023-01-31 192.168.100.201
337
+ bin/rbzk logs 192.168.100.201 --start-date=2023-01-01 --end-date=2023-01-31
338
+
339
+ # Get logs from a specific date to today
340
+ bin/rbzk logs 192.168.100.201 --start-date=2023-01-01
341
+
342
+ # Get logs from 30 days before to a specific date
343
+ bin/rbzk logs 192.168.100.201 --end-date=2023-01-31
344
+
345
+ # Test voice with UDP connection
346
+ bin/rbzk test_voice 192.168.100.201 --force-udp
347
+ ```
348
+
349
+ ### Pretty Output
350
+
351
+ The command line interface uses the `terminal-table` gem for prettier output if it's available. To enable this feature, install the gem:
352
+
353
+ ```bash
354
+ gem install terminal-table
355
+ ```
195
356
 
196
- See the `examples/complete_example.rb` file for a comprehensive example that demonstrates all the main functionality of the gem.
357
+ If the gem is not available, the CLI will fall back to plain text output.
197
358
 
198
359
  ## Development
199
360
 
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rbzk"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/rbzk ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
5
+
6
+ require 'rbzk/cli/commands'
7
+
8
+ RBZK::CLI::Commands.start(ARGV)
data/bin/setup ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install