tng 0.1.3 → 0.1.5

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.
@@ -4,6 +4,7 @@ require "tty-box"
4
4
  require "tty-progressbar"
5
5
  require "pastel"
6
6
  require "tty-screen"
7
+ require_relative "theme"
7
8
 
8
9
  class UserStatsDisplay
9
10
  def initialize(pastel, prompt)
@@ -17,8 +18,8 @@ class UserStatsDisplay
17
18
  end
18
19
 
19
20
  def display(stats_data)
20
- header = @pastel.bright_white.bold("šŸ“Š User Statistics")
21
- puts center_text(header)
21
+ header = @pastel.public_send(Tng::UI::Theme.color(:primary)).bold("#{Tng::UI::Theme.icon(:stats)} User Statistics")
22
+ puts Tng::UI::Theme.center_text(header, @terminal_width)
22
23
 
23
24
  if stats_data
24
25
  display_stats_box(stats_data)
@@ -29,32 +30,40 @@ class UserStatsDisplay
29
30
  end
30
31
 
31
32
  puts
32
- tip_msg = @pastel.dim("šŸ’” Tip: Contact support if you need more test generations")
33
- puts center_text(tip_msg)
34
- @prompt.keypress(center_text(@pastel.dim("Press any key to continue...")))
33
+ tip_msg = @pastel.public_send(Tng::UI::Theme.color(:muted),
34
+ "#{Tng::UI::Theme.icon(:lightbulb)} Tip: Contact support if you need more test generations")
35
+ puts Tng::UI::Theme.center_text(tip_msg, @terminal_width)
36
+ @prompt.keypress(Tng::UI::Theme.center_text(
37
+ @pastel.public_send(Tng::UI::Theme.color(:muted),
38
+ "Press any key to continue..."), @terminal_width
39
+ ))
35
40
  end
36
41
 
37
42
  def display_stats_box(stats_data)
38
43
  stats_content = [
39
- @pastel.cyan.bold("Account Information"),
44
+ @pastel.public_send(Tng::UI::Theme.color(:secondary)).bold("Account Information"),
40
45
  "",
41
- @pastel.bright_white("Test Runs: ") + @pastel.green.bold(stats_data["runs"].to_s),
42
- @pastel.bright_white("Max Runs: ") + @pastel.yellow.bold(stats_data["max_runs"].to_s),
43
- @pastel.bright_white("Gem Version: ") + @pastel.magenta(stats_data["gem_version"] || "N/A"),
46
+ @pastel.public_send(Tng::UI::Theme.color(:primary), "Test Runs: ") + @pastel.public_send(Tng::UI::Theme.color(:success)).bold(stats_data["runs"].to_s),
47
+ @pastel.public_send(Tng::UI::Theme.color(:primary), "Max Runs: ") + @pastel.public_send(Tng::UI::Theme.color(:warning)).bold(stats_data["max_runs"].to_s),
48
+ @pastel.public_send(Tng::UI::Theme.color(:primary),
49
+ "Gem Version: ") + @pastel.public_send(Tng::UI::Theme.color(:accent),
50
+ stats_data["gem_version"] || "N/A"),
44
51
  "",
45
- @pastel.dim("Request ID: #{stats_data["request_id"]}")
52
+ @pastel.public_send(Tng::UI::Theme.color(:muted), "Request ID: #{stats_data["request_id"]}")
46
53
  ].join("\n")
47
54
 
48
- box_width = 50
55
+ box_width = Tng::UI::Theme.calculate_box_width(@terminal_width)
56
+ style = Tng::UI::Theme.box_style(:success)
57
+
49
58
  box = TTY::Box.frame(
50
59
  title: { top_left: " Your TNG Stats " },
51
- style: { fg: :bright_white, border: { fg: :green }, title: { fg: :bright_green } },
52
- padding: [1, 2],
60
+ style: style[:style],
61
+ padding: style[:padding],
53
62
  align: :left,
54
63
  width: box_width
55
64
  ) { stats_content }
56
65
 
57
- puts center_box(box, box_width)
66
+ puts Tng::UI::Theme.center_box(box, box_width, @terminal_width)
58
67
  end
59
68
 
60
69
  def display_usage_progress(stats_data)
@@ -66,7 +75,8 @@ class UserStatsDisplay
66
75
  bar_color = determine_bar_color(usage_percent)
67
76
 
68
77
  puts
69
- puts center_text(@pastel.bright_white.bold("Usage Overview"))
78
+ puts Tng::UI::Theme.center_text(@pastel.public_send(Tng::UI::Theme.color(:primary)).bold("Usage Overview"),
79
+ @terminal_width)
70
80
  puts
71
81
 
72
82
  progress_width = 40
@@ -79,7 +89,7 @@ class UserStatsDisplay
79
89
  total: max_runs,
80
90
  width: progress_width,
81
91
  complete: bar_color,
82
- incomplete: @pastel.dim("ā–‘"),
92
+ incomplete: @pastel.public_send(Tng::UI::Theme.color(:muted), "ā–‘"),
83
93
  head: bar_color)
84
94
 
85
95
  current_progress = 0
@@ -98,56 +108,53 @@ class UserStatsDisplay
98
108
 
99
109
  status_msg = case usage_percent
100
110
  when 0..50
101
- @pastel.green("🟢 Good usage - plenty of runs remaining")
111
+ @pastel.public_send(Tng::UI::Theme.color(:success),
112
+ "#{Tng::UI::Theme.icon(:success)} Good usage - plenty of runs remaining")
102
113
  when 51..80
103
- @pastel.yellow("🟔 Moderate usage - consider monitoring")
114
+ @pastel.public_send(Tng::UI::Theme.color(:warning),
115
+ "#{Tng::UI::Theme.icon(:warning)} Moderate usage - consider monitoring")
104
116
  when 81..95
105
- @pastel.cyan("🟠 High usage - approaching limit")
117
+ @pastel.public_send(Tng::UI::Theme.color(:info),
118
+ "#{Tng::UI::Theme.icon(:warning)} High usage - approaching limit")
106
119
  else
107
- @pastel.red("šŸ”“ Limit reached - contact support for more runs")
120
+ @pastel.public_send(Tng::UI::Theme.color(:error),
121
+ "#{Tng::UI::Theme.icon(:error)} Limit reached - contact support for more runs")
108
122
  end
109
123
 
110
- puts center_text(status_msg)
124
+ puts Tng::UI::Theme.center_text(status_msg, @terminal_width)
111
125
  end
112
126
 
113
127
  def determine_bar_color(usage_percent)
114
128
  case usage_percent
115
129
  when 0..50
116
- @pastel.on_green(" ")
130
+ @pastel.public_send(Tng::UI::Theme.color(:success), "ā–ˆ")
117
131
  when 51..80
118
- @pastel.on_yellow(" ")
132
+ @pastel.public_send(Tng::UI::Theme.color(:warning), "ā–ˆ")
119
133
  when 81..95
120
- @pastel.on_cyan(" ")
134
+ @pastel.public_send(Tng::UI::Theme.color(:info), "ā–ˆ")
121
135
  else
122
- @pastel.on_red(" ")
136
+ @pastel.public_send(Tng::UI::Theme.color(:error), "ā–ˆ")
123
137
  end
124
138
  end
125
139
 
126
140
  def display_usage_info(stats_data)
127
141
  usage_remaining = stats_data["max_runs"] - stats_data["runs"]
128
142
  usage_msg = if usage_remaining.positive?
129
- @pastel.green("āœ… You have #{usage_remaining} test generations remaining")
143
+ @pastel.public_send(Tng::UI::Theme.color(:success),
144
+ "#{Tng::UI::Theme.icon(:success)} You have #{usage_remaining} test generations remaining")
130
145
  else
131
- @pastel.red("āš ļø You have reached your test generation limit")
146
+ @pastel.public_send(Tng::UI::Theme.color(:error),
147
+ "#{Tng::UI::Theme.icon(:warning)} You have reached your test generation limit")
132
148
  end
133
- puts center_text(usage_msg)
149
+ puts Tng::UI::Theme.center_text(usage_msg, @terminal_width)
134
150
  end
135
151
 
136
152
  def display_error
137
- error_msg = @pastel.red.bold("āŒ Failed to fetch user statistics")
138
- puts center_text(error_msg)
139
- puts center_text(@pastel.dim("Please check your API key and internet connection"))
140
- end
141
-
142
- def center_text(text)
143
- padding = (@terminal_width - @pastel.strip(text).length) / 2
144
- padding = 0 if padding.negative?
145
- (" " * padding) + text
146
- end
147
-
148
- def center_box(box_string, box_width)
149
- padding = (@terminal_width - box_width) / 2
150
- padding = 0 if padding.negative?
151
- box_string.lines.map { |line| (" " * padding) + line.chomp }.join("\n")
153
+ error_msg = @pastel.public_send(Tng::UI::Theme.color(:error)).bold("#{Tng::UI::Theme.icon(:error)} Failed to fetch user statistics")
154
+ puts Tng::UI::Theme.center_text(error_msg, @terminal_width)
155
+ puts Tng::UI::Theme.center_text(
156
+ @pastel.public_send(Tng::UI::Theme.color(:muted),
157
+ "Please check your API key and internet connection"), @terminal_width
158
+ )
152
159
  end
153
160
  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.1.3"
4
+ VERSION = "0.1.5"
5
5
  end
data/lib/tng.rb CHANGED
@@ -5,7 +5,9 @@ $VERBOSE = nil
5
5
  require_relative "tng/version"
6
6
  require_relative "tng/utils"
7
7
  require_relative "tng/api/http_client"
8
+ require_relative "tng/ui/theme"
8
9
  require_relative "tng/ui/post_install_box"
10
+ require_relative "tng/ui/authentication_warning_display"
9
11
  require_relative "tng/services/test_generator"
10
12
 
11
13
  require_relative "tng/railtie" if defined?(Rails)
@@ -258,6 +260,18 @@ module Tng
258
260
  @config[:subject_style]
259
261
  end
260
262
 
263
+ def self.authentication_configured?
264
+ return false unless authentication_enabled
265
+ return false if authentication_methods.nil? || authentication_methods.empty?
266
+
267
+ authentication_methods.all? do |method|
268
+ method.is_a?(Hash) &&
269
+ method.key?(:method) && !method[:method].to_s.strip.empty? &&
270
+ method.key?(:file_location) && !method[:file_location].to_s.strip.empty? &&
271
+ method.key?(:auth_type) && !method[:auth_type].to_s.strip.empty?
272
+ end
273
+ end
274
+
261
275
  def self.initialize_framework_defaults(framework)
262
276
  if framework == "minitest"
263
277
  @config.merge!({
data/tng.gemspec CHANGED
@@ -5,11 +5,11 @@ require_relative "lib/tng/version"
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "tng"
7
7
  spec.version = Tng::VERSION
8
- spec.authors = ["claudiug"]
8
+ spec.authors = ["ralucab"]
9
9
  spec.email = ["claudiu.garba@gmail.com"]
10
10
 
11
11
  spec.summary = "TNG generates tests using static code analysis and LLM"
12
- spec.description = "TNG generates tests using static code analysis and LLM"
12
+ spec.description = "TNG (Test Next Generation) is a Rails gem that automatically generates comprehensive test files by analyzing your Ruby code using static analysis and AI. It supports models, controllers, and services with intelligent test case generation."
13
13
  spec.homepage = "https://tng.sh/"
14
14
  spec.required_ruby_version = ">= 3.1.0"
15
15
  spec.required_rubygems_version = ">= 3.3.11"
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.metadata["allowed_push_host"] = "https://rubygems.org"
18
18
  spec.metadata["homepage_uri"] = spec.homepage
19
19
  spec.metadata["source_code_uri"] = "https://github.com/tng-sh/tng-rails"
20
- spec.license = "Commercial"
20
+ spec.license = "Nonstandard"
21
21
  spec.metadata["license_uri"] = "https://github.com/tng-sh/tng-rails/blob/master/LICENSE.md"
22
22
 
23
23
  # Package pre-compiled binaries and exclude the Rust source code.
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tng
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
- - claudiug
7
+ - ralucab
8
8
  bindir: bin
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
@@ -191,7 +191,9 @@ dependencies:
191
191
  - - "~>"
192
192
  - !ruby/object:Gem::Version
193
193
  version: '0.12'
194
- description: TNG generates tests using static code analysis and LLM
194
+ description: TNG (Test Next Generation) is a Rails gem that automatically generates
195
+ comprehensive test files by analyzing your Ruby code using static analysis and AI.
196
+ It supports models, controllers, and services with intelligent test case generation.
195
197
  email:
196
198
  - claudiu.garba@gmail.com
197
199
  executables:
@@ -219,6 +221,7 @@ files:
219
221
  - lib/tng/services/testng.rb
220
222
  - lib/tng/services/user_app_config.rb
221
223
  - lib/tng/ui/about_display.rb
224
+ - lib/tng/ui/authentication_warning_display.rb
222
225
  - lib/tng/ui/configuration_display.rb
223
226
  - lib/tng/ui/controller_test_flow_display.rb
224
227
  - lib/tng/ui/display_banner.rb
@@ -228,13 +231,14 @@ files:
228
231
  - lib/tng/ui/service_test_flow_display.rb
229
232
  - lib/tng/ui/show_help.rb
230
233
  - lib/tng/ui/system_status_display.rb
234
+ - lib/tng/ui/theme.rb
231
235
  - lib/tng/ui/user_stats_display.rb
232
236
  - lib/tng/utils.rb
233
237
  - lib/tng/version.rb
234
238
  - tng.gemspec
235
239
  homepage: https://tng.sh/
236
240
  licenses:
237
- - Commercial
241
+ - Nonstandard
238
242
  metadata:
239
243
  allowed_push_host: https://rubygems.org
240
244
  homepage_uri: https://tng.sh/
@@ -251,7 +255,7 @@ post_install_message: "ā”Œ TNG ────────────────
251
255
  \ │\n│ │\n│
252
256
  \ 3. Add your license key: │\n│ config.api_key
253
257
  = 'your-license-key-here' │\n│ │\n│
254
- \ \U0001F4D6 Check documentation for the correct authentication setup │\n│
258
+ \ \U0001F4CB Check documentation for the correct authentication setup │\n│
255
259
  \ │\n│ \U0001F680
256
260
  Usage: │\n│ │\n│
257
261
  \ Interactive mode: │\n│ • bundle
@@ -264,7 +268,7 @@ post_install_message: "ā”Œ TNG ────────────────
264
268
  exec tng --help - Show all options │\n│ │\n│
265
269
  \ \U0001F4A1 Use -t c for controller, -t m for model │\n│
266
270
  \ │\n└────────────────────────────────────────────────────────────
267
- v0.1.3 ā”˜\n"
271
+ v0.1.5 ā”˜\n"
268
272
  rdoc_options: []
269
273
  require_paths:
270
274
  - lib