rbzk 0.1.8 → 0.1.9
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/lib/rbzk/cli/commands.rb +44 -14
- data/lib/rbzk/version.rb +1 -1
- data/lib/rbzk/zk.rb +4 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 30de1318989db7b9f80b389d3ca68436938ac0a05b19946e605f852bff717cb1
|
|
4
|
+
data.tar.gz: c9eb7a35862c70f94a9b7e35ad0ca61866c073de69bb8b9f06f84cb2737c22bc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b9fa15daacc07d2b86b931ea453f16f4d29071bc760d2cd888a464a02b5281f90ceb855c29a2ec5a4eafaec6a0df5129163d4ef5c4c8c6739be08aa92d8121ca
|
|
7
|
+
data.tar.gz: 381807e8e37f62cf560dd61f3e6798d1727f4911df14454d59163c9894e6ca4df99b4cf499fcb2f85eddf9f5c7ad13ee2f34f70d647f25d2419ac98e1813ed03
|
data/lib/rbzk/cli/commands.rb
CHANGED
|
@@ -63,7 +63,7 @@ module RBZK
|
|
|
63
63
|
table = ::Terminal::Table.new do |t|
|
|
64
64
|
t.title = 'Device Information'
|
|
65
65
|
device_info.each do |key, value|
|
|
66
|
-
t << [key, value]
|
|
66
|
+
t << [ key, value ]
|
|
67
67
|
end
|
|
68
68
|
end
|
|
69
69
|
|
|
@@ -108,28 +108,28 @@ module RBZK
|
|
|
108
108
|
map 'logs-today' => 'logs'
|
|
109
109
|
|
|
110
110
|
def logs_today(ip = nil)
|
|
111
|
-
invoke :logs, [ip], { today: true }.merge(options)
|
|
111
|
+
invoke :logs, [ ip ], { today: true }.merge(options)
|
|
112
112
|
end
|
|
113
113
|
|
|
114
114
|
desc 'logs-yesterday [IP]', "Get yesterday's attendance logs"
|
|
115
115
|
map 'logs-yesterday' => 'logs'
|
|
116
116
|
|
|
117
117
|
def logs_yesterday(ip = nil)
|
|
118
|
-
invoke :logs, [ip], { yesterday: true }.merge(options)
|
|
118
|
+
invoke :logs, [ ip ], { yesterday: true }.merge(options)
|
|
119
119
|
end
|
|
120
120
|
|
|
121
121
|
desc 'logs-week [IP]', "Get this week's attendance logs"
|
|
122
122
|
map 'logs-week' => 'logs'
|
|
123
123
|
|
|
124
124
|
def logs_week(ip = nil)
|
|
125
|
-
invoke :logs, [ip], { week: true }.merge(options)
|
|
125
|
+
invoke :logs, [ ip ], { week: true }.merge(options)
|
|
126
126
|
end
|
|
127
127
|
|
|
128
128
|
desc 'logs-month [IP]', "Get this month's attendance logs"
|
|
129
129
|
map 'logs-month' => 'logs'
|
|
130
130
|
|
|
131
131
|
def logs_month(ip = nil)
|
|
132
|
-
invoke :logs, [ip], { month: true }.merge(options)
|
|
132
|
+
invoke :logs, [ ip ], { month: true }.merge(options)
|
|
133
133
|
end
|
|
134
134
|
|
|
135
135
|
desc 'logs-all [IP]', 'Get all attendance logs without limit'
|
|
@@ -153,7 +153,7 @@ module RBZK
|
|
|
153
153
|
# Pretty table output
|
|
154
154
|
table = ::Terminal::Table.new do |t|
|
|
155
155
|
t.title = 'All Attendance Logs (Showing All Records)'
|
|
156
|
-
t.headings = ['UID', 'User ID', 'Time', 'Status', 'Punch Type']
|
|
156
|
+
t.headings = [ 'UID', 'User ID', 'Time', 'Status', 'Punch Type' ]
|
|
157
157
|
|
|
158
158
|
# Show all logs in the table
|
|
159
159
|
logs.each do |log|
|
|
@@ -185,7 +185,7 @@ module RBZK
|
|
|
185
185
|
def logs_custom(start_date, end_date, ip = nil)
|
|
186
186
|
# Use IP from options if not provided as argument
|
|
187
187
|
ip ||= options[:ip] || @config['ip']
|
|
188
|
-
invoke :logs, [ip], { start_date: start_date, end_date: end_date }.merge(options)
|
|
188
|
+
invoke :logs, [ ip ], { start_date: start_date, end_date: end_date }.merge(options)
|
|
189
189
|
end
|
|
190
190
|
|
|
191
191
|
desc 'logs [IP]', 'Get attendance logs'
|
|
@@ -298,7 +298,7 @@ module RBZK
|
|
|
298
298
|
# Pretty table output
|
|
299
299
|
table = ::Terminal::Table.new do |t|
|
|
300
300
|
t.title = title || 'Attendance Logs'
|
|
301
|
-
t.headings = ['UID', 'User ID', 'Time', 'Status', 'Punch Type']
|
|
301
|
+
t.headings = [ 'UID', 'User ID', 'Time', 'Status', 'Punch Type' ]
|
|
302
302
|
|
|
303
303
|
# Show logs in the table based on limit
|
|
304
304
|
display_logs.each do |log|
|
|
@@ -429,6 +429,7 @@ module RBZK
|
|
|
429
429
|
|
|
430
430
|
# Disable device for exclusive access during modification
|
|
431
431
|
begin
|
|
432
|
+
puts '✓ Disabling device...'
|
|
432
433
|
conn.disable_device
|
|
433
434
|
rescue StandardError
|
|
434
435
|
nil
|
|
@@ -451,9 +452,11 @@ module RBZK
|
|
|
451
452
|
ensure
|
|
452
453
|
# Re-enable device after modification (always)
|
|
453
454
|
begin
|
|
455
|
+
puts '✓ Re-enabling device...'
|
|
454
456
|
conn.enable_device
|
|
455
|
-
rescue StandardError
|
|
456
|
-
|
|
457
|
+
rescue StandardError => e
|
|
458
|
+
# Do not raise - just log a warning if verbose
|
|
459
|
+
puts "Warning: failed to re-enable device: #{e.message}" if options[:verbose]
|
|
457
460
|
end
|
|
458
461
|
end
|
|
459
462
|
end
|
|
@@ -505,7 +508,7 @@ module RBZK
|
|
|
505
508
|
# Use Terminal::Table for pretty output
|
|
506
509
|
table = ::Terminal::Table.new do |t|
|
|
507
510
|
t.title = 'Fingerprint Templates'
|
|
508
|
-
t.headings = ['UID', 'Finger ID', 'Valid', 'Size']
|
|
511
|
+
t.headings = [ 'UID', 'Finger ID', 'Valid', 'Size' ]
|
|
509
512
|
|
|
510
513
|
templates.each do |template|
|
|
511
514
|
t << [
|
|
@@ -545,10 +548,9 @@ module RBZK
|
|
|
545
548
|
|
|
546
549
|
# Extract parameters from options
|
|
547
550
|
uid = options[:uid] || 0
|
|
548
|
-
user_id = options[:user_id] || ''
|
|
549
551
|
finger_id = options[:finger_id] || 0
|
|
550
552
|
|
|
551
|
-
template = conn.get_user_template(uid
|
|
553
|
+
template = conn.get_user_template(uid, finger_id)
|
|
552
554
|
|
|
553
555
|
if template
|
|
554
556
|
puts '✓ Found fingerprint template:'
|
|
@@ -663,6 +665,34 @@ module RBZK
|
|
|
663
665
|
end
|
|
664
666
|
end
|
|
665
667
|
|
|
668
|
+
desc 'enable-device [IP]', 'Enable the device'
|
|
669
|
+
map 'enable-device' => :enable_device
|
|
670
|
+
|
|
671
|
+
def enable_device(ip = nil)
|
|
672
|
+
# Use IP from options if not provided as argument
|
|
673
|
+
ip ||= options[:ip] || @config['ip']
|
|
674
|
+
|
|
675
|
+
with_connection(ip, options) do |conn|
|
|
676
|
+
puts 'Enabling device...'
|
|
677
|
+
result = conn.enable_device
|
|
678
|
+
puts '✓ Device enabled successfully!' if result
|
|
679
|
+
end
|
|
680
|
+
end
|
|
681
|
+
|
|
682
|
+
desc 'disable-device [IP]', 'Disable the device'
|
|
683
|
+
map 'disable-device' => :disable_device
|
|
684
|
+
|
|
685
|
+
def disable_device(ip = nil)
|
|
686
|
+
# Use IP from options if not provided as argument
|
|
687
|
+
ip ||= options[:ip] || @config['ip']
|
|
688
|
+
|
|
689
|
+
with_connection(ip, options) do |conn|
|
|
690
|
+
puts 'Disabling device...'
|
|
691
|
+
result = conn.disable_device
|
|
692
|
+
puts '✓ Device disabled successfully!' if result
|
|
693
|
+
end
|
|
694
|
+
end
|
|
695
|
+
|
|
666
696
|
desc 'poweroff [IP]', 'Power off the device'
|
|
667
697
|
|
|
668
698
|
def poweroff(ip = nil)
|
|
@@ -791,7 +821,7 @@ module RBZK
|
|
|
791
821
|
# Use Terminal::Table for pretty output
|
|
792
822
|
table = ::Terminal::Table.new do |t|
|
|
793
823
|
t.title = 'Users'
|
|
794
|
-
t.headings = ['UID', 'User ID', 'Name', 'Privilege', 'Password', 'Group ID', 'Card']
|
|
824
|
+
t.headings = [ 'UID', 'User ID', 'Name', 'Privilege', 'Password', 'Group ID', 'Card' ]
|
|
795
825
|
|
|
796
826
|
users.each do |user|
|
|
797
827
|
t << [
|
data/lib/rbzk/version.rb
CHANGED
data/lib/rbzk/zk.rb
CHANGED
|
@@ -178,8 +178,10 @@ module RBZK
|
|
|
178
178
|
end
|
|
179
179
|
|
|
180
180
|
def enable_device
|
|
181
|
-
send_command(CMD_ENABLEDEVICE)
|
|
182
|
-
|
|
181
|
+
cmd_response = send_command(CMD_ENABLEDEVICE)
|
|
182
|
+
raise RBZK::ZKErrorResponse, "Can't enable device" unless cmd_response && cmd_response[:status]
|
|
183
|
+
|
|
184
|
+
@is_enabled = true
|
|
183
185
|
true
|
|
184
186
|
end
|
|
185
187
|
|