tng 0.2.5 → 0.2.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: 11458e5ed9eda12f4414dc98635ec95082b50246c8eb8dad8a49cf17ea5e9746
4
- data.tar.gz: edba8d3b38a64c8564a2e2a9f8ad76a3d39e1e4ba5b9748c4d1f4823f3284338
3
+ metadata.gz: c30c794fbce7688603e0535f1673b9c755627d090846074a55f49614eb61eb59
4
+ data.tar.gz: 487772b58677a33f9f54719bcac234a17f7be7905f0ef00001d1fae259e06704
5
5
  SHA512:
6
- metadata.gz: 6114f3dacbf6d98e8a33e5fec6d511aa0de333d0e59a58b1243af1211316849018fa60cc728c8bcc2fd0bd076c0d15f19052eb1509527ae98abeec9323c79f78
7
- data.tar.gz: 5b6876e63d05241f8b585e5491c83a7a39b6dc5bd32f64033cb27b3774ba9fd31646dc13d89ecde256b0d0a4e9261ca1ee696fc9801697ecd0f4ae31d9981d3e
6
+ metadata.gz: 720a2884c77eb6aa515a9fdcc765554725c08a45afbf7cf278ed03025067d13200550acf86d50edc34334d503fd76d61ef6114d26b5b4d0e6884166f1e74c302
7
+ data.tar.gz: b607b077576e8cddc418e58ad2647ea8a1e5e2079ce9ad34420cde5a8b41c6d66d8a1f69f80d105365acb1818be161352b051a1d01e91b2e494b73dd2e5bafd4
data/Rakefile CHANGED
@@ -61,6 +61,22 @@ task :redo do
61
61
  FileUtils.mkdir_p(destination_dir)
62
62
  FileUtils.cp(source_file, File.join(destination_dir, binary_name))
63
63
  puts "āœ… Copied #{binary_name} to #{destination_dir}/"
64
+
65
+ # Code sign the bundles on macOS
66
+ if RUBY_PLATFORM.include?("darwin")
67
+ puts "šŸ” Signing bundles..."
68
+ system("codesign --force --sign - #{source_file}")
69
+ system("codesign --force --sign - #{File.join(destination_dir, binary_name)}")
70
+
71
+ # Also sign the gem installation if it exists
72
+ ruby_version = RUBY_VERSION.split(".")[0..1].join(".")
73
+ gem_bundle = File.expand_path("~/.local/share/mise/installs/ruby/#{RUBY_VERSION}/lib/ruby/gems/#{ruby_version}.0/gems/tng-*/binaries/tng.bundle")
74
+ Dir.glob(gem_bundle).each do |bundle|
75
+ system("codesign --force --sign - #{bundle}")
76
+ end
77
+ puts "āœ… Bundles signed"
78
+ end
79
+
64
80
  break
65
81
  else
66
82
  retries += 1
data/binaries/tng.bundle CHANGED
Binary file
data/binaries/tng.so CHANGED
Binary file
@@ -42,12 +42,6 @@ module Tng
42
42
  end
43
43
  end
44
44
 
45
- def self.model_info_for_controller(file_path)
46
- raise "file_path is required" if file_path.nil?
47
-
48
- Tng::Analyzer::Controller.model_info_for_controller(file_path)
49
- end
50
-
51
45
  def self.methods_for_controller(controller_name)
52
46
  raise "controller_name is required" if controller_name.nil?
53
47
 
@@ -51,6 +51,19 @@ module Tng
51
51
  response
52
52
  end
53
53
 
54
+ def patch(path, payload: {}, headers: {})
55
+ merged_headers = json_default_headers.merge(headers)
56
+
57
+ response = HTTPX.with(timeout: @timeout).patch(
58
+ "#{@api_endpoint}/#{path}",
59
+ json: payload,
60
+ headers: merged_headers
61
+ )
62
+
63
+ debug_response("PATCH #{path}", response) if debug_enabled?
64
+ response
65
+ end
66
+
54
67
  def ping
55
68
  response = HTTPX.with(timeout: @timeout).get("#{@api_endpoint}/ping")
56
69
  debug_response("GET /ping", response) if debug_enabled?
@@ -53,6 +53,15 @@ module Tng
53
53
  end
54
54
 
55
55
  job_data = JSON.parse(response.body)
56
+
57
+ # Check for forbidden responses (usage limits or invalid keys)
58
+ if response.status == 403
59
+ error_icon = Tng::UI::Theme.icon(:error)
60
+ error_color = Tng::UI::Theme.color(:error)
61
+ puts "#{error_icon} #{@pastel.decorate("Access denied:",
62
+ error_color)} Please check your API key and usage limits."
63
+ return
64
+ end
56
65
  job_id = job_data["job_id"]
57
66
 
58
67
  return unless job_id
@@ -67,6 +76,8 @@ module Tng
67
76
  file_result = Tng::Utils.save_test_file(result.to_json)
68
77
  return unless file_result
69
78
 
79
+ trigger_cleanup(job_id)
80
+
70
81
  file_result.merge(generation_time: generation_time)
71
82
  end
72
83
 
@@ -104,7 +115,7 @@ module Tng
104
115
 
105
116
  if seconds_elapsed > MAX_POLL_DURATION_SECONDS
106
117
  progress_bar.finish
107
- puts "āŒ Test generation timed out after #{MAX_POLL_DURATION_SECONDS} seconds (6 minutes)"
118
+ puts "āŒ Test generation timed out after #{MAX_POLL_DURATION_SECONDS} seconds (7 minutes)"
108
119
  return
109
120
  end
110
121
 
@@ -138,7 +149,7 @@ module Tng
138
149
  error_icon = Tng::UI::Theme.icon(:error)
139
150
  error_color = Tng::UI::Theme.color(:error)
140
151
  puts "#{error_icon} #{@pastel.decorate("Test generation failed:",
141
- error_color)} #{status_data["error"] || "Unknown error"}"
152
+ error_color)} An error occurred while generating tests. Please try again."
142
153
  return
143
154
  when "pending", "processing"
144
155
  # Progress bar updates smoothly above
@@ -195,6 +206,12 @@ module Tng
195
206
  end
196
207
  end
197
208
 
209
+ def trigger_cleanup(job_id)
210
+ @http_client.patch("#{CONTENT_RESPONSES_PATH}/#{job_id}/cleanup")
211
+ rescue StandardError => e
212
+ debug_log("Cleanup request failed: #{e.message}") if debug_enabled?
213
+ end
214
+
198
215
  def debug_enabled?
199
216
  ENV["DEBUG"] == "1"
200
217
  end
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.2.5"
4
+ VERSION = "0.2.7"
5
5
  end
data/lib/tng.rb CHANGED
@@ -43,8 +43,6 @@ rescue LoadError => e
43
43
  puts "Some functionality may not be available."
44
44
  end
45
45
 
46
- # Load Ruby analyzers after native binary to ensure Rust classes are available
47
- # Ruby analyzers depend on Rust classes (e.g., Tng::Analyzer::Controller)
48
46
  require_relative "tng/analyzers/controller"
49
47
  require_relative "tng/analyzers/model"
50
48
  require_relative "tng/analyzers/service"
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.2.5
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - ralucab
@@ -287,7 +287,7 @@ post_install_message: "ā”Œ TNG ────────────────
287
287
  \ │\n│ • bundle exec
288
288
  tng --help - Show help information │\n│ │\n│
289
289
  \ \U0001F4A1 Generate tests for individual methods with precision │\n└────────────────────────────────────────────────────────────
290
- v0.2.5 ā”˜\n"
290
+ v0.2.7 ā”˜\n"
291
291
  rdoc_options: []
292
292
  require_paths:
293
293
  - lib