truenorth 0.2.5 → 0.2.6
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/truenorth/cli.rb +2 -1
- data/lib/truenorth/client.rb +37 -5
- data/lib/truenorth/version.rb +1 -1
- data/truenorth.gemspec +1 -1
- 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: 77aa3d893615956dc5dad5e8adc512bbdeb436aa99f6b04be100d246ca3d59f7
|
|
4
|
+
data.tar.gz: '0009efe2c7af6f8425018ebcbcf44b6d7c0295c83f08e90b00368358edd39205'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 53c557e2417576cfaf637ada5e8057e15ff6fda7db6cc898efb9b99d8620c0b09e15fd2dcf3a8dadb8c31fec3e038b0aa0c7db434bd7382532aea7970fba3f90
|
|
7
|
+
data.tar.gz: acc45f0794fb39ec448ba78abb8834568b0b8a050a91fd371fd55f1967a161bd1b2884f371329db24f1220454ddc00d9ecc7074ba48e42e5eae728741d97fed0
|
data/lib/truenorth/cli.rb
CHANGED
|
@@ -145,8 +145,9 @@ module Truenorth
|
|
|
145
145
|
desc 'cancel INDEX', 'Cancel a reservation by index (from reservations list)'
|
|
146
146
|
option :dry_run, type: :boolean, aliases: '-n', desc: 'Test without actually canceling'
|
|
147
147
|
option :all, type: :boolean, aliases: '-a', desc: 'Cancel from full list (use with --all view)'
|
|
148
|
+
option :debug, type: :boolean, desc: 'Show debug output'
|
|
148
149
|
def cancel(index)
|
|
149
|
-
client = Client.new
|
|
150
|
+
client = Client.new(debug: options[:debug])
|
|
150
151
|
|
|
151
152
|
say 'Fetching reservations...', :cyan
|
|
152
153
|
results = client.reservations
|
data/lib/truenorth/client.rb
CHANGED
|
@@ -302,14 +302,46 @@ module Truenorth
|
|
|
302
302
|
response = post_ajax(ajax_url, form_data)
|
|
303
303
|
|
|
304
304
|
if response.is_a?(Net::HTTPSuccess)
|
|
305
|
-
# Check for success indicators in response
|
|
306
305
|
body = response.body
|
|
307
|
-
|
|
308
|
-
|
|
306
|
+
|
|
307
|
+
# Log response for debugging
|
|
308
|
+
log "Response length: #{body.length}"
|
|
309
|
+
log "Response preview: #{body[0..500]}"
|
|
310
|
+
|
|
311
|
+
# Check for specific PrimeFaces success indicators
|
|
312
|
+
# Look for actual cancellation confirmation messages
|
|
313
|
+
success_indicators = [
|
|
314
|
+
/cancelled.*successfully/i,
|
|
315
|
+
/reservation.*cancelled/i,
|
|
316
|
+
/successfully.*cancelled/i,
|
|
317
|
+
/<update.*id=".*growl"/i # PrimeFaces growl messages usually indicate success/error
|
|
318
|
+
]
|
|
319
|
+
|
|
320
|
+
# Check for error indicators
|
|
321
|
+
error_indicators = [
|
|
322
|
+
/error/i,
|
|
323
|
+
/failed/i,
|
|
324
|
+
/unable/i,
|
|
325
|
+
/cannot.*cancel/i
|
|
326
|
+
]
|
|
327
|
+
|
|
328
|
+
has_error = error_indicators.any? { |pattern| body =~ pattern }
|
|
329
|
+
has_success = success_indicators.any? { |pattern| body =~ pattern }
|
|
330
|
+
|
|
331
|
+
if has_error
|
|
332
|
+
# Extract error message if present
|
|
333
|
+
error_msg = body[/error[^<]*|failed[^<]*/i] || 'Cancellation may have failed'
|
|
334
|
+
log "Error detected: #{error_msg}"
|
|
335
|
+
{ success: false, error: error_msg }
|
|
336
|
+
elsif has_success || body.length < 500
|
|
337
|
+
# Very short response likely means success (no error message)
|
|
338
|
+
log 'Cancellation appears successful'
|
|
309
339
|
{ success: true, message: 'Reservation cancelled' }
|
|
310
340
|
else
|
|
311
|
-
log
|
|
312
|
-
|
|
341
|
+
# Ambiguous - log full response for analysis
|
|
342
|
+
log "Ambiguous response (#{body.length} bytes)"
|
|
343
|
+
log "Full response: #{body}"
|
|
344
|
+
{ success: false, error: 'Uncertain if cancellation succeeded - please verify' }
|
|
313
345
|
end
|
|
314
346
|
else
|
|
315
347
|
{ success: false, error: "HTTP #{response.code}" }
|
data/lib/truenorth/version.rb
CHANGED
data/truenorth.gemspec
CHANGED