tng 0.4.6 → 0.4.7

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: a4de2429d2ed196847183d8142115e1b99266d474704b0d2b9dfc6a794b1904c
4
- data.tar.gz: 001e994ec388b5e5bed712a506f6acb3267c0d163377390bff45c87e980fa52b
3
+ metadata.gz: 7727b2d4c08387a0e8c876ec10b2a8f6eccd489012bd9f67a0a603edc3ac2355
4
+ data.tar.gz: 7bcd5620b9d3f655a535a340bcdeff03dc55732026f3778e99cea0dba1bfea82
5
5
  SHA512:
6
- metadata.gz: 58dd488f1924aa1680f0f3f327042af5133bfc92f2c9eb56540f5b49d89f24905cd20a8baa88deb69d8cbe3bb519693a6b8fea98e14a852bbe5731cb4343d0ed
7
- data.tar.gz: 1e45869a87e3787f642bdeb245daa1b4776187b73a4a07712e81aa6518b7e9720c41d8ab1747460df5b12d803e158eb778fbc4c96816932aadaf93fe5e729369
6
+ metadata.gz: 54e4257601da9e968ce490c289d5bc51988d24940cc8c4879a172622edbb789c0512f3aa3b787c2262fe4370869ed21c15f3e0c8a9816b81458eff491f0cc62f
7
+ data.tar.gz: da6a48c02b0a509c80fbee1192737176b193743e21e34320aa4a868224ae9de3cc9ef3dcce1ade936ece5297c89f5770759adc18f6e4e56979aee18fdc66dc0a
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
data/binaries/tng.bundle CHANGED
Binary file
@@ -28,9 +28,7 @@ module Tng
28
28
  # Show main menu and return selected choice
29
29
  # Returns: "tests", "stats", "about", "exit"
30
30
  def show_menu
31
- output_file = Tempfile.new(["go_ui_menu", ".json"])
32
- output_path = output_file.path
33
- output_file.close
31
+ output_path = _create_temp_file("go_ui_menu", ".json")
34
32
 
35
33
  begin
36
34
  system(@binary_path, "menu", "--output", output_path)
@@ -42,15 +40,13 @@ module Tng
42
40
  rescue StandardError
43
41
  "exit"
44
42
  ensure
45
- File.unlink(output_path) if File.exist?(output_path)
43
+ _cleanup_temp_file(output_path)
46
44
  end
47
45
  end
48
46
 
49
47
  # Returns: "controller", "model", "service", "other", "back"
50
48
  def show_test_type_menu(mode = "test")
51
- output_file = Tempfile.new(["go_ui_test_type", ".json"])
52
- output_path = output_file.path
53
- output_file.close
49
+ output_path = _create_temp_file("go_ui_test_type", ".json")
54
50
 
55
51
  begin
56
52
  system(@binary_path, "rails-test-menu", "--output", output_path, "--mode", mode)
@@ -62,14 +58,12 @@ module Tng
62
58
  rescue StandardError
63
59
  "back"
64
60
  ensure
65
- File.unlink(output_path) if File.exist?(output_path)
61
+ _cleanup_temp_file(output_path)
66
62
  end
67
63
  end
68
64
  # Returns: "1", "2", "all", "back"
69
65
  def show_clone_menu
70
- output_file = Tempfile.new(["go_ui_clone_menu", ".json"])
71
- output_path = output_file.path
72
- output_file.close
66
+ output_path = _create_temp_file("go_ui_clone_menu", ".json")
73
67
 
74
68
  begin
75
69
  system(@binary_path, "clone-menu", "--output", output_path)
@@ -81,40 +75,34 @@ module Tng
81
75
  rescue StandardError
82
76
  "back"
83
77
  ensure
84
- File.unlink(output_path) if File.exist?(output_path)
78
+ _cleanup_temp_file(output_path)
85
79
  end
86
80
  end
87
81
 
88
- # @return [String] Selected item name or "back"
89
82
  def show_list_view(title, items)
90
83
  data_json = JSON.generate({ title: title, items: items })
91
-
92
- output_file = Tempfile.new(["go_ui_list", ".txt"])
93
- output_path = output_file.path
94
- output_file.close
84
+ output_path = _create_temp_file("go_ui_list", ".txt")
95
85
 
96
86
  begin
97
87
  system(@binary_path, "list-view", "--data", data_json, "--output", output_path)
98
88
 
99
89
  selected = File.read(output_path).strip
100
90
  selected.empty? ? "back" : selected
91
+ rescue StandardError
92
+ "back"
101
93
  ensure
102
- File.unlink(output_path) if File.exist?(output_path)
94
+ _cleanup_temp_file(output_path)
103
95
  end
104
96
  end
105
97
 
106
98
  def show_spinner(message)
107
- control_file = Tempfile.new(["go_ui_spinner", ".json"])
108
- control_path = control_file.path
109
- control_file.close
99
+ control_path = _create_temp_file("go_ui_spinner", ".json")
110
100
 
111
- # Start spinner in background
112
101
  pid = spawn(@binary_path, "spinner", "--message", message, "--control", control_path)
113
102
 
114
103
  begin
115
104
  result = yield
116
105
 
117
- # Write completion status
118
106
  status = {
119
107
  status: result&.dig(:success) ? "success" : "error",
120
108
  message: result&.dig(:message) || "Done!"
@@ -129,18 +117,12 @@ module Tng
129
117
  Process.wait(pid)
130
118
  raise
131
119
  ensure
132
- File.unlink(control_path) if File.exist?(control_path)
120
+ _cleanup_temp_file(control_path)
133
121
  end
134
122
  end
135
123
 
136
- # Show progress bar with steps
137
- # @param title [String] Progress title
138
- # @yield [ProgressUpdater] Block receives updater and returns Hash with :message and :result
139
- # @return [Hash] Result from block
140
124
  def show_progress(title)
141
- control_file = Tempfile.new(["go_ui_progress", ".json"])
142
- control_path = control_file.path
143
- control_file.close
125
+ control_path = _create_temp_file("go_ui_progress", ".json")
144
126
 
145
127
  # Start progress in background (inherit TTY)
146
128
  pid = spawn(@binary_path, "progress", "--title", title, "--control", control_path)
@@ -165,7 +147,7 @@ module Tng
165
147
  Process.wait(pid)
166
148
  raise
167
149
  ensure
168
- File.unlink(control_path) if File.exist?(control_path)
150
+ _cleanup_temp_file(control_path)
169
151
  end
170
152
  end
171
153
 
@@ -206,10 +188,7 @@ module Tng
206
188
  # @return [String] Selected choice ("run_tests", "copy_command", "back")
207
189
  def show_post_generation_menu(file_path, run_command)
208
190
  data_json = JSON.generate({ file_path: file_path, run_command: run_command })
209
-
210
- output_file = Tempfile.new(["go_ui_post_gen", ".txt"])
211
- output_path = output_file.path
212
- output_file.close
191
+ output_path = _create_temp_file("go_ui_post_gen", ".txt")
213
192
 
214
193
  begin
215
194
  system(@binary_path, "post-generation-menu", "--data", data_json, "--output", output_path)
@@ -217,7 +196,7 @@ module Tng
217
196
  choice = File.read(output_path).strip
218
197
  choice.empty? ? "back" : choice
219
198
  ensure
220
- File.unlink(output_path) if File.exist?(output_path)
199
+ _cleanup_temp_file(output_path)
221
200
  end
222
201
  end
223
202
 
@@ -259,17 +238,14 @@ module Tng
259
238
 
260
239
  # Send full result object via temp file to avoid CLI argument limits
261
240
  data_json = JSON.generate(audit_result)
262
-
263
- input_file = Tempfile.new(["go_ui_audit", ".json"])
264
- input_path = input_file.path
241
+ input_path = _create_temp_file("go_ui_audit", ".json")
265
242
  File.write(input_path, data_json)
266
- input_file.close
267
243
 
268
244
  system(@binary_path, command, "--file", input_path)
269
245
  rescue StandardError => e
270
246
  puts "Audit results error: #{e.message}"
271
247
  ensure
272
- File.unlink(input_path) if input_path && File.exist?(input_path)
248
+ _cleanup_temp_file(input_path)
273
249
  end
274
250
 
275
251
  # Show symbolic trace results
@@ -286,17 +262,14 @@ module Tng
286
262
  def show_clones(file_path, results)
287
263
  data = { file_path: file_path, matches: results[:matches] }
288
264
  data_json = JSON.generate(data)
289
-
290
- input_file = Tempfile.new(["go_ui_clones", ".json"])
291
- input_path = input_file.path
265
+ input_path = _create_temp_file("go_ui_clones", ".json")
292
266
  File.write(input_path, data_json)
293
- input_file.close
294
267
 
295
268
  system(@binary_path, "clones", "--file", input_path)
296
269
  rescue StandardError => e
297
270
  puts "Clones results error: #{e.message}"
298
271
  ensure
299
- File.unlink(input_path) if input_path && File.exist?(input_path)
272
+ _cleanup_temp_file(input_path)
300
273
  end
301
274
 
302
275
  # Show authentication error
@@ -429,8 +402,6 @@ module Tng
429
402
  items.each { |item| puts " - #{item}" }
430
403
  end
431
404
 
432
- # Show system status
433
- # @param status [Hash] Status data from testng
434
405
  def show_system_status(status)
435
406
  data = {
436
407
  status: status[:status].to_s,
@@ -441,13 +412,44 @@ module Tng
441
412
  server_base_url: status[:server_base_url]
442
413
  }
443
414
  data_json = JSON.generate(data)
444
- system(@binary_path, "system-status", "--data", data_json)
445
- rescue StandardError => e
446
- puts "System status error: #{e.message}"
415
+ input_path = _create_temp_file("go_ui_status", ".json")
416
+ File.write(input_path, data_json)
417
+
418
+ begin
419
+ system(@binary_path, "system-status", "--file", input_path)
420
+ rescue StandardError => e
421
+ puts "System status error: #{e.message}"
422
+ ensure
423
+ _cleanup_temp_file(input_path)
424
+ end
447
425
  end
448
426
 
449
427
  private
450
428
 
429
+ def _create_temp_file(prefix, suffix)
430
+ tmp_dir = Dir.tmpdir
431
+ file_name = "tng-#{prefix}-#{Time.now.to_i}-#{rand(1000)}#{suffix}"
432
+ file_path = File.join(tmp_dir, file_name)
433
+
434
+ begin
435
+ File.write(file_path, "")
436
+ file_path
437
+ rescue StandardError
438
+ # Fallback to local directory if system tmp is not writable
439
+ local_tmp = File.join(Dir.pwd, ".tng-tmp")
440
+ FileUtils.mkdir_p(local_tmp) unless Dir.exist?(local_tmp)
441
+ file_path = File.join(local_tmp, file_name)
442
+ File.write(file_path, "")
443
+ file_path
444
+ end
445
+ end
446
+
447
+ def _cleanup_temp_file(file_path)
448
+ File.unlink(file_path) if file_path && File.exist?(file_path)
449
+ rescue StandardError
450
+ # Ignore cleanup errors
451
+ end
452
+
451
453
  def find_go_ui_binary
452
454
  # Detect platform
453
455
  platform = RUBY_PLATFORM
data/lib/tng/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tng
4
- VERSION = "0.4.6"
4
+ VERSION = "0.4.7"
5
5
  end
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.6
4
+ version: 0.4.7
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.6 ┘\n"
225
+ v0.4.7 ┘\n"
226
226
  rdoc_options: []
227
227
  require_paths:
228
228
  - lib