tng 0.4.8 ā 0.4.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/bin/tng +131 -15
- data/binaries/go-ui-darwin-amd64 +0 -0
- data/binaries/go-ui-darwin-arm64 +0 -0
- data/binaries/go-ui-linux-amd64 +0 -0
- data/binaries/go-ui-linux-arm64 +0 -0
- data/binaries/tng-darwin-arm64.bundle +0 -0
- data/binaries/tng-darwin-x86_64.bundle +0 -0
- data/binaries/tng-linux-arm64.so +0 -0
- data/binaries/tng-linux-x86_64.so +0 -0
- data/binaries/tng.bundle +0 -0
- data/lib/tng/services/direct_generation.rb +31 -2
- data/lib/tng/services/test_generator.rb +72 -8
- data/lib/tng/ui/go_ui_session.rb +37 -2
- data/lib/tng/ui/json_session.rb +18 -0
- data/lib/tng/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3ff0f5e157285f7bd53cc4d5d73333bececaa05877d9564862a5d5828531bbe2
|
|
4
|
+
data.tar.gz: f4f56d75d0ab3beab4fe07c7533dc91ff35a8241ac4137fdade944cc38a56f17
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0ca98f50fbf918c9ff10d7c0b913283d1ecd2a3bfc9146ec2c0677f2992a8d7101d031b92fa5c5c4d61b13560aaa4da790791aac821771bcff1dd2b321e2d266
|
|
7
|
+
data.tar.gz: 4f7dc85deec32ca9566b2048de29fe18e18b5270ed0892c7104e4e8395336664370feb05aed5a3a0fee47062f00ff2e6f17837db1b7c0b75f77d548abd501594
|
data/bin/tng
CHANGED
|
@@ -52,6 +52,10 @@ class CLI
|
|
|
52
52
|
example "Dead Code Detection:", ""
|
|
53
53
|
example " bundle exec tng app/models/user.rb --deadcode", ""
|
|
54
54
|
example " bundle exec tng --file=app/services/auth_service.rb -d", ""
|
|
55
|
+
example ""
|
|
56
|
+
example "X-Ray Visualization:", ""
|
|
57
|
+
example " bundle exec tng app/services/payment_processor.rb process_payment --xray", ""
|
|
58
|
+
example " bundle exec tng --file=users_controller.rb --method=create --xray --json", ""
|
|
55
59
|
end
|
|
56
60
|
|
|
57
61
|
option :file do
|
|
@@ -95,6 +99,11 @@ class CLI
|
|
|
95
99
|
desc "Generate and visualize a symbolic trace"
|
|
96
100
|
end
|
|
97
101
|
|
|
102
|
+
flag :xray do
|
|
103
|
+
long "--xray"
|
|
104
|
+
desc "Generate X-Ray visualization (Mermaid flowchart)"
|
|
105
|
+
end
|
|
106
|
+
|
|
98
107
|
flag :json do
|
|
99
108
|
short "-j"
|
|
100
109
|
long "--json"
|
|
@@ -152,6 +161,8 @@ class CLI
|
|
|
152
161
|
run_direct_trace
|
|
153
162
|
elsif params[:deadcode] && params[:file]
|
|
154
163
|
run_dead_code_detection
|
|
164
|
+
elsif params[:xray] && params[:file]
|
|
165
|
+
run_direct_xray
|
|
155
166
|
elsif params[:file]
|
|
156
167
|
run_direct_generation
|
|
157
168
|
else
|
|
@@ -190,6 +201,8 @@ class CLI
|
|
|
190
201
|
normalized << "--audit"
|
|
191
202
|
when /^(?:--)?(trace)$/
|
|
192
203
|
normalized << "--trace"
|
|
204
|
+
when /^(?:--)?(xray)$/
|
|
205
|
+
normalized << "--xray"
|
|
193
206
|
when /^(?:--)?(json|j)$/
|
|
194
207
|
normalized << "--json"
|
|
195
208
|
when /^(?:--)?(fix|x)$/
|
|
@@ -257,6 +270,8 @@ class CLI
|
|
|
257
270
|
handle_audit_method
|
|
258
271
|
when "trace"
|
|
259
272
|
handle_trace_method
|
|
273
|
+
when "xray"
|
|
274
|
+
handle_xray_method
|
|
260
275
|
when "clones"
|
|
261
276
|
handle_clone_detection
|
|
262
277
|
when "deadcode"
|
|
@@ -533,21 +548,16 @@ class CLI
|
|
|
533
548
|
end
|
|
534
549
|
|
|
535
550
|
absolute_path = File.expand_path(file_path)
|
|
536
|
-
json_output = params[:json] || false
|
|
537
551
|
|
|
538
552
|
begin
|
|
539
553
|
# Always get JSON from Rust for flexibility
|
|
540
554
|
result = Tng.detect_dead_code(absolute_path, true)
|
|
541
555
|
|
|
542
|
-
if
|
|
543
|
-
|
|
556
|
+
if @go_ui
|
|
557
|
+
@go_ui.show_dead_code_results(absolute_path, result)
|
|
544
558
|
else
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
else
|
|
548
|
-
# Fallback to text output
|
|
549
|
-
puts Tng.detect_dead_code(absolute_path, false)
|
|
550
|
-
end
|
|
559
|
+
# Fallback to text output
|
|
560
|
+
puts Tng.detect_dead_code(absolute_path, false)
|
|
551
561
|
end
|
|
552
562
|
rescue => e
|
|
553
563
|
puts @pastel.red("Error detecting dead code: #{e.message}")
|
|
@@ -1217,13 +1227,18 @@ class CLI
|
|
|
1217
1227
|
end
|
|
1218
1228
|
|
|
1219
1229
|
def show_post_generation_menu(result)
|
|
1230
|
+
if @go_ui.is_a?(Tng::UI::JsonSession)
|
|
1231
|
+
@go_ui.show_generation_result(result)
|
|
1232
|
+
return
|
|
1233
|
+
end
|
|
1234
|
+
|
|
1220
1235
|
is_direct_mode = params[:file]
|
|
1221
1236
|
|
|
1222
1237
|
# Direct mode - just print info and exit
|
|
1223
1238
|
if is_direct_mode
|
|
1224
1239
|
puts "\nš Test Generated Successfully!"
|
|
1225
1240
|
puts "š File: #{result[:file_path]}"
|
|
1226
|
-
puts "
|
|
1241
|
+
puts "ā¶\u{fe0f} Run: #{result[:run_command]}"
|
|
1227
1242
|
puts "ā
Test generation completed successfully!"
|
|
1228
1243
|
return
|
|
1229
1244
|
end
|
|
@@ -1244,19 +1259,19 @@ class CLI
|
|
|
1244
1259
|
end
|
|
1245
1260
|
end
|
|
1246
1261
|
|
|
1247
|
-
def copy_to_clipboard(command)
|
|
1262
|
+
def copy_to_clipboard(command, silent: false)
|
|
1248
1263
|
if RUBY_PLATFORM.include?("darwin")
|
|
1249
1264
|
IO.popen("pbcopy", "w") { |io| io.print command }
|
|
1250
|
-
@go_ui.show_clipboard_success(command)
|
|
1265
|
+
@go_ui.show_clipboard_success(command) unless silent
|
|
1251
1266
|
elsif RUBY_PLATFORM.include?("linux")
|
|
1252
1267
|
begin
|
|
1253
1268
|
IO.popen("xclip -selection clipboard", "w") { |io| io.print command }
|
|
1254
|
-
@go_ui.show_clipboard_success(command)
|
|
1269
|
+
@go_ui.show_clipboard_success(command) unless silent
|
|
1255
1270
|
rescue Errno::ENOENT
|
|
1256
|
-
puts "\nš Copy this command:\n#{command}\n"
|
|
1271
|
+
puts "\nš Copy this command:\n#{command}\n" unless silent
|
|
1257
1272
|
end
|
|
1258
1273
|
else
|
|
1259
|
-
puts "\nš Copy this command:\n#{command}\n"
|
|
1274
|
+
puts "\nš Copy this command:\n#{command}\n" unless silent
|
|
1260
1275
|
end
|
|
1261
1276
|
end
|
|
1262
1277
|
|
|
@@ -1303,6 +1318,21 @@ class CLI
|
|
|
1303
1318
|
end
|
|
1304
1319
|
end
|
|
1305
1320
|
|
|
1321
|
+
def handle_xray_method
|
|
1322
|
+
choice = @go_ui.show_test_type_menu("xray")
|
|
1323
|
+
|
|
1324
|
+
case choice
|
|
1325
|
+
when "controller"
|
|
1326
|
+
xray_controller_method
|
|
1327
|
+
when "model"
|
|
1328
|
+
xray_model_method
|
|
1329
|
+
when "service"
|
|
1330
|
+
xray_service_method
|
|
1331
|
+
when "other"
|
|
1332
|
+
xray_other_method
|
|
1333
|
+
end
|
|
1334
|
+
end
|
|
1335
|
+
|
|
1306
1336
|
def trace_controller_method
|
|
1307
1337
|
select_controller_and_method("Trace") do |controller, method_info|
|
|
1308
1338
|
run_trace_for_method(controller, method_info)
|
|
@@ -1327,6 +1357,30 @@ class CLI
|
|
|
1327
1357
|
end
|
|
1328
1358
|
end
|
|
1329
1359
|
|
|
1360
|
+
def xray_controller_method
|
|
1361
|
+
select_controller_and_method("X-Ray") do |controller, method_info|
|
|
1362
|
+
run_xray_for_method(controller, method_info)
|
|
1363
|
+
end
|
|
1364
|
+
end
|
|
1365
|
+
|
|
1366
|
+
def xray_model_method
|
|
1367
|
+
select_model_and_method("X-Ray") do |model, method_info|
|
|
1368
|
+
run_xray_for_method(model, method_info)
|
|
1369
|
+
end
|
|
1370
|
+
end
|
|
1371
|
+
|
|
1372
|
+
def xray_service_method
|
|
1373
|
+
select_service_and_method("X-Ray") do |service, method_info|
|
|
1374
|
+
run_xray_for_method(service, method_info)
|
|
1375
|
+
end
|
|
1376
|
+
end
|
|
1377
|
+
|
|
1378
|
+
def xray_other_method
|
|
1379
|
+
select_other_and_method("X-Ray") do |file, method_info|
|
|
1380
|
+
run_xray_for_method(file, method_info)
|
|
1381
|
+
end
|
|
1382
|
+
end
|
|
1383
|
+
|
|
1330
1384
|
def run_trace_for_method(file_info, method_info)
|
|
1331
1385
|
result_path = nil
|
|
1332
1386
|
|
|
@@ -1380,6 +1434,68 @@ class CLI
|
|
|
1380
1434
|
run_trace_for_method(file_info, method_info)
|
|
1381
1435
|
end
|
|
1382
1436
|
|
|
1437
|
+
def run_direct_xray
|
|
1438
|
+
return unless check_configuration
|
|
1439
|
+
|
|
1440
|
+
return unless check_authentication_configuration
|
|
1441
|
+
|
|
1442
|
+
file_path = params[:file]
|
|
1443
|
+
method_name = params[:method]
|
|
1444
|
+
|
|
1445
|
+
unless method_name
|
|
1446
|
+
puts @pastel.decorate("Please specify a method name with --method or -m", Tng::UI::Theme.color(:error))
|
|
1447
|
+
return
|
|
1448
|
+
end
|
|
1449
|
+
|
|
1450
|
+
full_path = File.expand_path(file_path)
|
|
1451
|
+
unless File.exist?(full_path)
|
|
1452
|
+
puts @pastel.decorate("File not found: #{full_path}", Tng::UI::Theme.color(:error))
|
|
1453
|
+
return
|
|
1454
|
+
end
|
|
1455
|
+
|
|
1456
|
+
file_info = { path: full_path, name: File.basename(full_path) }
|
|
1457
|
+
method_info = { name: method_name }
|
|
1458
|
+
|
|
1459
|
+
run_xray_for_method(file_info, method_info)
|
|
1460
|
+
end
|
|
1461
|
+
|
|
1462
|
+
def run_xray_for_method(file_info, method_info)
|
|
1463
|
+
xray_result = nil
|
|
1464
|
+
|
|
1465
|
+
@go_ui.show_spinner("Generating X-Ray for #{method_info[:name]}...") do
|
|
1466
|
+
begin
|
|
1467
|
+
type = Tng::Services::FileTypeDetector.detect_type(file_info[:path])
|
|
1468
|
+
file_object = Tng::Services::FileTypeDetector.build_file_object(file_info[:path], type)
|
|
1469
|
+
generator = Tng::Services::TestGenerator.new(@http_client)
|
|
1470
|
+
|
|
1471
|
+
xray_result = case type
|
|
1472
|
+
when "controller"
|
|
1473
|
+
generator.run_xray_for_controller_method(file_object, method_info)
|
|
1474
|
+
when "model"
|
|
1475
|
+
generator.run_xray_for_model_method(file_object, method_info)
|
|
1476
|
+
when "service"
|
|
1477
|
+
generator.run_xray_for_service_method(file_object, method_info)
|
|
1478
|
+
else
|
|
1479
|
+
generator.run_xray_for_other_method(file_object, method_info)
|
|
1480
|
+
end
|
|
1481
|
+
|
|
1482
|
+
if xray_result&.dig(:error)
|
|
1483
|
+
{ success: false, message: xray_result[:message] || "X-Ray failed" }
|
|
1484
|
+
else
|
|
1485
|
+
{ success: true, message: "X-Ray generated" }
|
|
1486
|
+
end
|
|
1487
|
+
rescue => e
|
|
1488
|
+
{ success: false, message: e.message }
|
|
1489
|
+
end
|
|
1490
|
+
end
|
|
1491
|
+
|
|
1492
|
+
return @go_ui.show_auth_error(xray_result[:message] || "X-Ray failed") if xray_result&.dig(:error)
|
|
1493
|
+
|
|
1494
|
+
if xray_result && xray_result[:mermaid_code]
|
|
1495
|
+
@go_ui.show_xray_results(xray_result, method_info)
|
|
1496
|
+
end
|
|
1497
|
+
end
|
|
1498
|
+
|
|
1383
1499
|
def select_controller_and_method(action_name)
|
|
1384
1500
|
controllers = nil
|
|
1385
1501
|
@go_ui.show_spinner("Analyzing controllers...") do
|
data/binaries/go-ui-darwin-amd64
CHANGED
|
Binary file
|
data/binaries/go-ui-darwin-arm64
CHANGED
|
Binary file
|
data/binaries/go-ui-linux-amd64
CHANGED
|
Binary file
|
data/binaries/go-ui-linux-arm64
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/binaries/tng-linux-arm64.so
CHANGED
|
Binary file
|
|
Binary file
|
data/binaries/tng.bundle
CHANGED
|
Binary file
|
|
@@ -96,19 +96,41 @@ module Tng
|
|
|
96
96
|
return
|
|
97
97
|
end
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
action =
|
|
100
|
+
if @params[:trace]
|
|
101
|
+
"Tracing"
|
|
102
|
+
elsif @params[:xray]
|
|
103
|
+
"Generating X-Ray for"
|
|
104
|
+
elsif @params[:audit]
|
|
105
|
+
"Auditing"
|
|
106
|
+
else
|
|
107
|
+
"Generating test for"
|
|
108
|
+
end
|
|
109
|
+
@go_ui.display_info(@pastel.bright_white("šÆ #{action} #{file_object[:name]}##{method_info[:name]}..."))
|
|
100
110
|
|
|
101
111
|
result = @go_ui.show_progress("Processing...") do |progress|
|
|
102
112
|
generate_test_result(file_object, method_info, type, progress)
|
|
103
113
|
end
|
|
104
114
|
|
|
105
115
|
if result&.dig(:error)
|
|
106
|
-
|
|
116
|
+
label =
|
|
117
|
+
if @params[:trace]
|
|
118
|
+
"Trace"
|
|
119
|
+
elsif @params[:xray]
|
|
120
|
+
"X-Ray"
|
|
121
|
+
elsif @params[:audit]
|
|
122
|
+
"Audit"
|
|
123
|
+
else
|
|
124
|
+
"Test generation"
|
|
125
|
+
end
|
|
126
|
+
@go_ui.display_error(@pastel.red("ā #{label} failed: #{result[:message]}"))
|
|
107
127
|
elsif result&.dig(:trace_generated)
|
|
108
128
|
if result[:file_path]
|
|
109
129
|
@go_ui.show_trace_results(result[:file_path])
|
|
110
130
|
File.unlink(result[:file_path]) if File.exist?(result[:file_path])
|
|
111
131
|
end
|
|
132
|
+
elsif @params[:xray]
|
|
133
|
+
@go_ui.show_xray_results(result, method_info) if result
|
|
112
134
|
elsif @params[:audit]
|
|
113
135
|
display_audit_results(result)
|
|
114
136
|
elsif result && result[:file_path]
|
|
@@ -147,6 +169,13 @@ module Tng
|
|
|
147
169
|
|
|
148
170
|
if @params[:trace]
|
|
149
171
|
perform_trace_analysis(file_object, method_info, progress)
|
|
172
|
+
elsif @params[:xray]
|
|
173
|
+
case type
|
|
174
|
+
when "controller" then generator.run_xray_for_controller_method(file_object, method_info, progress: progress)
|
|
175
|
+
when "model" then generator.run_xray_for_model_method(file_object, method_info, progress: progress)
|
|
176
|
+
when "service" then generator.run_xray_for_service_method(file_object, method_info, progress: progress)
|
|
177
|
+
else generator.run_xray_for_other_method(file_object, method_info, progress: progress)
|
|
178
|
+
end
|
|
150
179
|
elsif @params[:audit]
|
|
151
180
|
case type
|
|
152
181
|
when "controller" then generator.run_audit_for_controller_method(file_object, method_info, progress: progress)
|
|
@@ -36,6 +36,7 @@ module Tng
|
|
|
36
36
|
generate_test_for_type(other_file, method_info, :other, progress: progress)
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
+
|
|
39
40
|
# Audit mode - async, polls for completion
|
|
40
41
|
def run_audit_for_controller_method(controller, method_info, progress: nil)
|
|
41
42
|
run_audit_for_type(controller, method_info, :controller, progress: progress)
|
|
@@ -53,6 +54,23 @@ module Tng
|
|
|
53
54
|
run_audit_for_type(other_file, method_info, :other, progress: progress)
|
|
54
55
|
end
|
|
55
56
|
|
|
57
|
+
# X-Ray mode - async, polls for completion
|
|
58
|
+
def run_xray_for_controller_method(controller, method_info, progress: nil)
|
|
59
|
+
run_xray_for_type(controller, method_info, :controller, progress: progress)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def run_xray_for_model_method(model, method_info, progress: nil)
|
|
63
|
+
run_xray_for_type(model, method_info, :model, progress: progress)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def run_xray_for_service_method(service, method_info, progress: nil)
|
|
67
|
+
run_xray_for_type(service, method_info, :service, progress: progress)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def run_xray_for_other_method(other_file, method_info, progress: nil)
|
|
71
|
+
run_xray_for_type(other_file, method_info, :other, progress: progress)
|
|
72
|
+
end
|
|
73
|
+
|
|
56
74
|
def run_audit_for_type(file_object, method_info, type, progress: nil)
|
|
57
75
|
response = send_audit_request_for_type(file_object, method_info, type)
|
|
58
76
|
return { error: :network_error, message: "Network error" } unless response
|
|
@@ -90,13 +108,59 @@ module Tng
|
|
|
90
108
|
# Pass audit_mode: true as 8th parameter
|
|
91
109
|
case type
|
|
92
110
|
when :controller
|
|
93
|
-
Tng.send_request_for_controller(name, file_object[:path], method_info, *config, true)
|
|
111
|
+
Tng.send_request_for_controller(name, file_object[:path], method_info, *config, true, false)
|
|
112
|
+
when :model
|
|
113
|
+
Tng.send_request_for_model(name, file_object[:path], method_info, *config, true, false)
|
|
114
|
+
when :service
|
|
115
|
+
Tng.send_request_for_service(name, file_object[:path], method_info, *config, true, false)
|
|
116
|
+
when :other
|
|
117
|
+
Tng.send_request_for_other(name, file_object[:path], method_info, *config, true, false)
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def run_xray_for_type(file_object, method_info, type, progress: nil)
|
|
122
|
+
response = send_xray_request_for_type(file_object, method_info, type)
|
|
123
|
+
return { error: :network_error, message: "Network error" } unless response
|
|
124
|
+
|
|
125
|
+
if response.is_a?(HTTPX::ErrorResponse)
|
|
126
|
+
return { error: :network_error, message: response.error&.message || "Network error" }
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
return { error: :auth_failed, message: "Invalid or missing API key" } if response.status == 401
|
|
130
|
+
return { error: :auth_failed, message: "API key expired" } if response.status == 403
|
|
131
|
+
|
|
132
|
+
begin
|
|
133
|
+
job_data = JSON.parse(response.body)
|
|
134
|
+
return { error: :server_error, message: job_data["error"] } if job_data["error"]
|
|
135
|
+
|
|
136
|
+
job_id = job_data["job_id"]
|
|
137
|
+
return { error: :server_error, message: "No job_id returned" } unless job_id
|
|
138
|
+
|
|
139
|
+
# Poll for completion (similar to audit)
|
|
140
|
+
result = poll_for_completion(job_id, progress: progress)
|
|
141
|
+
return { error: :timeout, message: "X-Ray generation timed out" } unless result
|
|
142
|
+
|
|
143
|
+
# X-Ray results should contain mermaid_code and explanation
|
|
144
|
+
result
|
|
145
|
+
rescue JSON::ParserError => e
|
|
146
|
+
{ error: :parse_error, message: "Failed to parse X-Ray response: #{e.message}" }
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def send_xray_request_for_type(file_object, method_info, type)
|
|
151
|
+
config = request_config
|
|
152
|
+
name = file_object[:name] || File.basename(file_object[:path], ".rb")
|
|
153
|
+
|
|
154
|
+
# Pass xray_mode: true as 9th parameter (audit_mode: false, xray_mode: true)
|
|
155
|
+
case type
|
|
156
|
+
when :controller
|
|
157
|
+
Tng.send_request_for_controller(name, file_object[:path], method_info, *config, false, true)
|
|
94
158
|
when :model
|
|
95
|
-
Tng.send_request_for_model(name, file_object[:path], method_info, *config, true)
|
|
159
|
+
Tng.send_request_for_model(name, file_object[:path], method_info, *config, false, true)
|
|
96
160
|
when :service
|
|
97
|
-
Tng.send_request_for_service(name, file_object[:path], method_info, *config, true)
|
|
161
|
+
Tng.send_request_for_service(name, file_object[:path], method_info, *config, false, true)
|
|
98
162
|
when :other
|
|
99
|
-
Tng.send_request_for_other(name, file_object[:path], method_info, *config, true)
|
|
163
|
+
Tng.send_request_for_other(name, file_object[:path], method_info, *config, false, true)
|
|
100
164
|
end
|
|
101
165
|
end
|
|
102
166
|
|
|
@@ -144,13 +208,13 @@ module Tng
|
|
|
144
208
|
# Pass audit_mode: false as 8th parameter for normal test generation
|
|
145
209
|
case type
|
|
146
210
|
when :controller
|
|
147
|
-
Tng.send_request_for_controller(name, file_object[:path], method_info, *config, false)
|
|
211
|
+
Tng.send_request_for_controller(name, file_object[:path], method_info, *config, false, false)
|
|
148
212
|
when :model
|
|
149
|
-
Tng.send_request_for_model(name, file_object[:path], method_info, *config, false)
|
|
213
|
+
Tng.send_request_for_model(name, file_object[:path], method_info, *config, false, false)
|
|
150
214
|
when :service
|
|
151
|
-
Tng.send_request_for_service(name, file_object[:path], method_info, *config, false)
|
|
215
|
+
Tng.send_request_for_service(name, file_object[:path], method_info, *config, false, false)
|
|
152
216
|
when :other
|
|
153
|
-
Tng.send_request_for_other(name, file_object[:path], method_info, *config, false)
|
|
217
|
+
Tng.send_request_for_other(name, file_object[:path], method_info, *config, false, false)
|
|
154
218
|
end
|
|
155
219
|
end
|
|
156
220
|
|
data/lib/tng/ui/go_ui_session.rb
CHANGED
|
@@ -256,6 +256,37 @@ module Tng
|
|
|
256
256
|
puts "Trace results error: #{e.message}"
|
|
257
257
|
end
|
|
258
258
|
|
|
259
|
+
# Show X-Ray visualization results
|
|
260
|
+
# @param xray_result [Hash] X-Ray result with mermaid_code
|
|
261
|
+
# @param method_info [Hash] Optional method info for context
|
|
262
|
+
def show_xray_results(xray_result, method_info = {})
|
|
263
|
+
data = {
|
|
264
|
+
mermaid_code: xray_result[:mermaid_code] || xray_result["mermaid_code"] || "",
|
|
265
|
+
explanation: xray_result[:explanation] || xray_result["explanation"] || "Logic flow visualization generated by TNG.",
|
|
266
|
+
method_name: method_info[:name] || method_info["name"] || "",
|
|
267
|
+
class_name: method_info[:class_name] || method_info["class_name"] || ""
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
# Silently copy to clipboard for mermaid.live
|
|
271
|
+
mermaid_code = data[:mermaid_code]
|
|
272
|
+
if RUBY_PLATFORM.include?("darwin")
|
|
273
|
+
IO.popen("pbcopy", "w") { |io| io.print mermaid_code } rescue nil
|
|
274
|
+
elsif RUBY_PLATFORM.include?("linux")
|
|
275
|
+
IO.popen("xclip -selection clipboard", "w") { |io| io.print mermaid_code } rescue nil
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
input_path = _create_temp_file("go_ui_xray", ".json")
|
|
279
|
+
File.write(input_path, JSON.generate(data))
|
|
280
|
+
|
|
281
|
+
begin
|
|
282
|
+
system(@binary_path, "xray-results", "--file", input_path)
|
|
283
|
+
rescue StandardError => e
|
|
284
|
+
puts "X-Ray results error: #{e.message}"
|
|
285
|
+
ensure
|
|
286
|
+
_cleanup_temp_file(input_path)
|
|
287
|
+
end
|
|
288
|
+
end
|
|
289
|
+
|
|
259
290
|
# Show clone detection results
|
|
260
291
|
# @param file_path [String] Original file path analyzed
|
|
261
292
|
# @param results [Hash] Clone detection results { matches: [...] }
|
|
@@ -376,7 +407,8 @@ module Tng
|
|
|
376
407
|
{ cmd: "bundle exec tng --file=FILE --method=METHOD --audit", desc: "Direct audit mode" },
|
|
377
408
|
{ cmd: "bundle exec tng --file=FILE --method=METHOD --trace", desc: "Symbolic trace mode" },
|
|
378
409
|
{ cmd: "bundle exec tng --file=FILE --clones", desc: "Check for code duplicates" },
|
|
379
|
-
{ cmd: "bundle exec tng --file=FILE --deadcode", desc: "Run dead code detection" }
|
|
410
|
+
{ cmd: "bundle exec tng --file=FILE --deadcode", desc: "Run dead code detection" },
|
|
411
|
+
{ cmd: "bundle exec tng --file=FILE --method=METHOD --xray", desc: "X-Ray visualization" }
|
|
380
412
|
],
|
|
381
413
|
features: [
|
|
382
414
|
"Controllers, Models, Services",
|
|
@@ -386,6 +418,7 @@ module Tng
|
|
|
386
418
|
"Symbolic execution traces",
|
|
387
419
|
"Duplicate code detection (Clones)",
|
|
388
420
|
"Dead code detection (Rust-powered)",
|
|
421
|
+
"X-Ray Logic Flow Visualization",
|
|
389
422
|
"Searchable method lists"
|
|
390
423
|
],
|
|
391
424
|
options: [
|
|
@@ -396,12 +429,14 @@ module Tng
|
|
|
396
429
|
{ flag: "--trace", desc: "Run symbolic trace mode" },
|
|
397
430
|
{ flag: "--clones", desc: "Run clone detection mode" },
|
|
398
431
|
{ flag: "--level=1|2|3|all", desc: "Set clone detection level (default: all)" },
|
|
399
|
-
{ flag: "--deadcode", desc: "Run dead code detection" }
|
|
432
|
+
{ flag: "--deadcode", desc: "Run dead code detection" },
|
|
433
|
+
{ flag: "--xray", desc: "Generate X-Ray visualization" }
|
|
400
434
|
],
|
|
401
435
|
how_to: [
|
|
402
436
|
"Run 'bundle exec tng' for interactive mode",
|
|
403
437
|
"Run 'tng [file] --clones' for duplicate detection",
|
|
404
438
|
"Run 'tng [file] --deadcode' for dead code analysis",
|
|
439
|
+
"Run 'tng [file] [method] --xray' for visualization",
|
|
405
440
|
"Select Controller, Model, or Service to start",
|
|
406
441
|
"Choose a method to generate/audit or select 'Check Duplicates'"
|
|
407
442
|
],
|
data/lib/tng/ui/json_session.rb
CHANGED
|
@@ -96,6 +96,20 @@ module Tng
|
|
|
96
96
|
emit_event("clones", { file_path: file_path, matches: results[:matches] })
|
|
97
97
|
end
|
|
98
98
|
|
|
99
|
+
def show_trace_results(trace_file_path)
|
|
100
|
+
trace_json = JSON.parse(File.read(trace_file_path))
|
|
101
|
+
emit_event("result", trace_json)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def show_dead_code_results(file_path, results_json)
|
|
105
|
+
parsed = JSON.parse(results_json)
|
|
106
|
+
emit_event("dead_code", parsed)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def show_xray_results(xray_result, method_info = {})
|
|
110
|
+
emit_event("result", xray_result.merge(method_info: method_info))
|
|
111
|
+
end
|
|
112
|
+
|
|
99
113
|
def show_test_results(title, passed, failed, errors, total, results = [])
|
|
100
114
|
emit_event("test_results", {
|
|
101
115
|
title: title,
|
|
@@ -107,6 +121,10 @@ module Tng
|
|
|
107
121
|
})
|
|
108
122
|
end
|
|
109
123
|
|
|
124
|
+
def show_generation_result(result)
|
|
125
|
+
emit_event("result", result)
|
|
126
|
+
end
|
|
127
|
+
|
|
110
128
|
# ------------------------------------------------------------------
|
|
111
129
|
# Errors & Warnings
|
|
112
130
|
# ------------------------------------------------------------------
|
data/lib/tng/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tng
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ralucab
|
|
@@ -222,7 +222,7 @@ post_install_message: "ā TNG āāāāāāāāāāāāāāāā
|
|
|
222
222
|
\ ā\nā ⢠bundle exec
|
|
223
223
|
tng --help - Show help information ā\nā ā\nā
|
|
224
224
|
\ \U0001F4A1 Generate tests for individual methods with precision ā\nāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
225
|
-
v0.4.
|
|
225
|
+
v0.4.9 ā\n"
|
|
226
226
|
rdoc_options: []
|
|
227
227
|
require_paths:
|
|
228
228
|
- lib
|