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.
- checksums.yaml +4 -4
- data/README.md +0 -79
- data/bin/tng +26 -0
- data/lib/generators/tng/install_generator.rb +21 -13
- data/lib/tng/services/testng.rb +1 -1
- data/lib/tng/ui/about_display.rb +33 -40
- data/lib/tng/ui/authentication_warning_display.rb +172 -0
- data/lib/tng/ui/configuration_display.rb +32 -26
- data/lib/tng/ui/controller_test_flow_display.rb +35 -28
- data/lib/tng/ui/display_banner.rb +13 -23
- data/lib/tng/ui/goodbye_display.rb +14 -23
- data/lib/tng/ui/model_test_flow_display.rb +34 -32
- data/lib/tng/ui/post_install_box.rb +35 -26
- data/lib/tng/ui/service_test_flow_display.rb +34 -28
- data/lib/tng/ui/show_help.rb +82 -47
- data/lib/tng/ui/system_status_display.rb +101 -30
- data/lib/tng/ui/theme.rb +266 -0
- data/lib/tng/ui/user_stats_display.rb +50 -43
- data/lib/tng/version.rb +1 -1
- data/lib/tng.rb +14 -0
- data/tng.gemspec +3 -3
- metadata +10 -6
@@ -4,6 +4,7 @@ require "tty-prompt"
|
|
4
4
|
require "tty-spinner"
|
5
5
|
require "pastel"
|
6
6
|
require "tty-screen"
|
7
|
+
require_relative "theme"
|
7
8
|
|
8
9
|
class ControllerTestFlowDisplay
|
9
10
|
def initialize(prompt, pastel)
|
@@ -17,73 +18,79 @@ class ControllerTestFlowDisplay
|
|
17
18
|
end
|
18
19
|
|
19
20
|
def select_controller(controllers)
|
20
|
-
header = @pastel.
|
21
|
-
puts center_text(header)
|
21
|
+
header = @pastel.public_send(Tng::UI::Theme.color(:primary)).bold("#{Tng::UI::Theme.icon(:config)} Select controller to test:")
|
22
|
+
puts Tng::UI::Theme.center_text(header, @terminal_width)
|
22
23
|
|
23
24
|
@prompt.select(
|
24
25
|
"",
|
25
26
|
cycle: true,
|
26
27
|
per_page: 12,
|
27
28
|
filter: true,
|
28
|
-
symbols: { marker:
|
29
|
+
symbols: { marker: Tng::UI::Theme.icon(:marker) }
|
29
30
|
) do |menu|
|
30
31
|
controllers.each do |controller|
|
31
|
-
display_name = "#{controller[:name]} #{@pastel.
|
32
|
+
display_name = "#{controller[:name]} #{@pastel.public_send(Tng::UI::Theme.color(:muted),
|
33
|
+
"(#{controller[:path]})")}"
|
32
34
|
menu.choice display_name, controller
|
33
35
|
end
|
34
|
-
menu.choice @pastel.
|
36
|
+
menu.choice @pastel.public_send(Tng::UI::Theme.color(:secondary), "#{Tng::UI::Theme.icon(:back)} Back"), :back
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
38
40
|
def select_test_option(controller_choice)
|
39
|
-
header = @pastel.
|
40
|
-
puts center_text(header)
|
41
|
+
header = @pastel.public_send(Tng::UI::Theme.color(:primary)).bold("#{Tng::UI::Theme.icon(:rocket)} Test Generation Options for #{controller_choice[:name]}")
|
42
|
+
puts Tng::UI::Theme.center_text(header, @terminal_width)
|
41
43
|
puts
|
42
44
|
|
43
45
|
@prompt.select(
|
44
|
-
@pastel.
|
46
|
+
@pastel.public_send(Tng::UI::Theme.color(:primary), "Choose test generation type:"),
|
45
47
|
cycle: true,
|
46
|
-
symbols: { marker:
|
48
|
+
symbols: { marker: Tng::UI::Theme.icon(:marker) }
|
47
49
|
) do |menu|
|
48
|
-
menu.choice @pastel.
|
49
|
-
|
50
|
-
menu.choice @pastel.
|
50
|
+
menu.choice @pastel.public_send(Tng::UI::Theme.color(:success), "Generate all possible tests"),
|
51
|
+
:all_possible_tests
|
52
|
+
menu.choice @pastel.public_send(Tng::UI::Theme.color(:info), "Generate per method"), :per_method
|
53
|
+
menu.choice @pastel.public_send(Tng::UI::Theme.color(:secondary), "#{Tng::UI::Theme.icon(:back)} Back"), :back
|
51
54
|
end
|
52
55
|
end
|
53
56
|
|
54
57
|
def show_no_controllers_message
|
55
|
-
error_msg = "#{@pastel.
|
56
|
-
|
57
|
-
|
58
|
+
error_msg = "#{@pastel.public_send(Tng::UI::Theme.color(:error)).bold("#{Tng::UI::Theme.icon(:error)} No controllers found in your application")}\n#{@pastel.public_send(
|
59
|
+
Tng::UI::Theme.color(:muted), "Make sure you have controllers in app/controllers/"
|
60
|
+
)}"
|
61
|
+
puts Tng::UI::Theme.center_text(error_msg, @terminal_width)
|
62
|
+
@prompt.keypress(Tng::UI::Theme.center_text(
|
63
|
+
@pastel.public_send(Tng::UI::Theme.color(:muted),
|
64
|
+
"Press any key to continue..."), @terminal_width
|
65
|
+
))
|
58
66
|
end
|
59
67
|
|
60
68
|
def select_controller_method(controller, methods)
|
61
|
-
header = @pastel.
|
62
|
-
puts center_text(header)
|
69
|
+
header = @pastel.public_send(Tng::UI::Theme.color(:primary)).bold("#{Tng::UI::Theme.icon(:rocket)} Select method to test in #{controller[:name]}")
|
70
|
+
puts Tng::UI::Theme.center_text(header, @terminal_width)
|
63
71
|
|
64
72
|
@prompt.select(
|
65
73
|
"",
|
66
74
|
cycle: true,
|
67
75
|
per_page: 10,
|
68
76
|
filter: true,
|
69
|
-
symbols: { marker:
|
77
|
+
symbols: { marker: Tng::UI::Theme.icon(:marker) }
|
70
78
|
) do |menu|
|
71
79
|
methods.each do |method|
|
72
80
|
menu.choice method[:name], method
|
73
81
|
end
|
74
|
-
menu.choice @pastel.
|
82
|
+
menu.choice @pastel.public_send(Tng::UI::Theme.color(:secondary), "#{Tng::UI::Theme.icon(:back)} Back"), :back
|
75
83
|
end
|
76
84
|
end
|
77
85
|
|
78
86
|
def show_no_methods_message(controller)
|
79
|
-
error_msg = "#{@pastel.
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
(" " * padding) + text
|
87
|
+
error_msg = "#{@pastel.public_send(Tng::UI::Theme.color(:error)).bold("#{Tng::UI::Theme.icon(:error)} No methods found in #{controller[:name]}")}\n#{@pastel.public_send(
|
88
|
+
Tng::UI::Theme.color(:muted), "Controller may be empty or have syntax errors"
|
89
|
+
)}"
|
90
|
+
puts Tng::UI::Theme.center_text(error_msg, @terminal_width)
|
91
|
+
@prompt.keypress(Tng::UI::Theme.center_text(
|
92
|
+
@pastel.public_send(Tng::UI::Theme.color(:muted),
|
93
|
+
"Press any key to continue..."), @terminal_width
|
94
|
+
))
|
88
95
|
end
|
89
96
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require "tty-box"
|
2
2
|
require "pastel"
|
3
3
|
require "tty-screen"
|
4
|
+
require_relative "theme"
|
4
5
|
|
5
6
|
class DisplayBanner
|
6
7
|
attr_reader :pastel, :version, :terminal_width
|
@@ -9,46 +10,35 @@ class DisplayBanner
|
|
9
10
|
@pastel = pastel
|
10
11
|
@version = version
|
11
12
|
@terminal_width = begin
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
TTY::Screen.width
|
14
|
+
rescue StandardError
|
15
|
+
80
|
16
|
+
end
|
16
17
|
end
|
17
18
|
|
18
19
|
def render
|
19
20
|
banner_content = [
|
20
|
-
pastel.
|
21
|
-
pastel.
|
21
|
+
pastel.public_send(Tng::UI::Theme.color(:secondary)).bold("Tng - LLM-Powered Rails Test Generator"),
|
22
|
+
pastel.public_send(Tng::UI::Theme.color(:muted), "Version: #{version}"),
|
22
23
|
"",
|
23
|
-
pastel.
|
24
|
-
pastel.
|
24
|
+
pastel.public_send(Tng::UI::Theme.color(:accent), "Generate comprehensive tests for your Rails application"),
|
25
|
+
pastel.public_send(Tng::UI::Theme.color(:muted), "Powered by LLM and static analysis")
|
25
26
|
].join("\n")
|
26
27
|
|
27
28
|
box_width = 64
|
28
29
|
box_width = terminal_width if box_width > terminal_width
|
30
|
+
style = Tng::UI::Theme.box_style(:default)
|
29
31
|
|
30
32
|
box = TTY::Box.frame(
|
31
33
|
title: { top_left: " Tng ", bottom_right: " Ready " },
|
32
|
-
style:
|
33
|
-
|
34
|
-
border: { fg: :cyan },
|
35
|
-
title: { fg: :bright_cyan }
|
36
|
-
},
|
37
|
-
padding: [1, 2],
|
34
|
+
style: style[:style],
|
35
|
+
padding: style[:padding],
|
38
36
|
align: :center,
|
39
37
|
width: box_width
|
40
38
|
) do
|
41
39
|
banner_content
|
42
40
|
end
|
43
41
|
|
44
|
-
"#{center_box(box, box_width)}\n"
|
45
|
-
end
|
46
|
-
|
47
|
-
private
|
48
|
-
|
49
|
-
def center_box(box_string, box_width)
|
50
|
-
padding = (terminal_width - box_width) / 2
|
51
|
-
padding = 0 if padding.negative?
|
52
|
-
box_string.lines.map { |line| (" " * padding) + line.chomp }.join("\n")
|
42
|
+
"#{Tng::UI::Theme.center_box(box, box_width, terminal_width)}\n"
|
53
43
|
end
|
54
44
|
end
|
@@ -3,48 +3,39 @@
|
|
3
3
|
require "tty-box"
|
4
4
|
require "pastel"
|
5
5
|
require "tty-screen"
|
6
|
+
require_relative "theme"
|
6
7
|
|
7
8
|
class GoodbyeDisplay
|
8
9
|
def initialize(pastel)
|
9
10
|
@pastel = pastel
|
10
11
|
@terminal_width = begin
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
TTY::Screen.width
|
13
|
+
rescue StandardError
|
14
|
+
80
|
15
|
+
end
|
15
16
|
end
|
16
17
|
|
17
18
|
def display
|
18
|
-
box_width =
|
19
|
+
box_width = Tng::UI::Theme.calculate_box_width(@terminal_width)
|
20
|
+
style = Tng::UI::Theme.box_style(:success)
|
21
|
+
|
19
22
|
goodbye_box = TTY::Box.frame(
|
20
23
|
title: { top_left: " Thank You " },
|
21
|
-
style:
|
22
|
-
|
23
|
-
border: { fg: :green },
|
24
|
-
title: { fg: :bright_green }
|
25
|
-
},
|
26
|
-
padding: [1, 2],
|
24
|
+
style: style[:style],
|
25
|
+
padding: style[:padding],
|
27
26
|
align: :center,
|
28
27
|
width: box_width
|
29
28
|
) do
|
30
29
|
[
|
31
|
-
@pastel.
|
30
|
+
@pastel.public_send(Tng::UI::Theme.color(:success)).bold("Thanks for using Tng!"),
|
32
31
|
"",
|
33
|
-
@pastel.
|
32
|
+
@pastel.public_send(Tng::UI::Theme.color(:secondary), "Happy testing!"),
|
34
33
|
"",
|
35
|
-
@pastel.
|
34
|
+
@pastel.public_send(Tng::UI::Theme.color(:muted), "Your Rails tests are now supercharged with LLM")
|
36
35
|
].join("\n")
|
37
36
|
end
|
38
37
|
|
39
|
-
puts center_box(goodbye_box, box_width)
|
38
|
+
puts Tng::UI::Theme.center_box(goodbye_box, box_width, @terminal_width)
|
40
39
|
puts
|
41
40
|
end
|
42
|
-
|
43
|
-
private
|
44
|
-
|
45
|
-
def center_box(box_string, box_width)
|
46
|
-
padding = (@terminal_width - box_width) / 2
|
47
|
-
padding = 0 if padding.negative?
|
48
|
-
box_string.lines.map { |line| (" " * padding) + line.chomp }.join("\n")
|
49
|
-
end
|
50
41
|
end
|
@@ -4,6 +4,7 @@ require "tty-prompt"
|
|
4
4
|
require "tty-spinner"
|
5
5
|
require "pastel"
|
6
6
|
require "tty-screen"
|
7
|
+
require_relative "theme"
|
7
8
|
|
8
9
|
class ModelTestFlowDisplay
|
9
10
|
def initialize(prompt, pastel)
|
@@ -17,79 +18,80 @@ class ModelTestFlowDisplay
|
|
17
18
|
end
|
18
19
|
|
19
20
|
def select_model(models)
|
20
|
-
header = @pastel.
|
21
|
-
puts center_text(header)
|
21
|
+
header = @pastel.public_send(Tng::UI::Theme.color(:primary)).bold("#{Tng::UI::Theme.icon(:config)} Select model to test:")
|
22
|
+
puts Tng::UI::Theme.center_text(header, @terminal_width)
|
22
23
|
|
23
24
|
@prompt.select(
|
24
25
|
"",
|
25
26
|
cycle: true,
|
26
27
|
per_page: 12,
|
27
28
|
filter: true,
|
28
|
-
symbols: { marker:
|
29
|
+
symbols: { marker: Tng::UI::Theme.icon(:marker) }
|
29
30
|
) do |menu|
|
30
31
|
models.each do |model|
|
31
|
-
display_name = "#{model[:name]} #{@pastel.
|
32
|
+
display_name = "#{model[:name]} #{@pastel.public_send(Tng::UI::Theme.color(:muted), "(#{model[:path]})")}"
|
32
33
|
menu.choice display_name, model
|
33
34
|
end
|
34
|
-
menu.choice @pastel.
|
35
|
+
menu.choice @pastel.public_send(Tng::UI::Theme.color(:secondary), "#{Tng::UI::Theme.icon(:back)} Back"), :back
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
38
39
|
def select_test_option(model_choice)
|
39
|
-
header = @pastel.
|
40
|
-
puts center_text(header)
|
40
|
+
header = @pastel.public_send(Tng::UI::Theme.color(:primary)).bold("#{Tng::UI::Theme.icon(:rocket)} Test Generation Options for #{model_choice[:name]}")
|
41
|
+
puts Tng::UI::Theme.center_text(header, @terminal_width)
|
41
42
|
puts
|
42
43
|
|
43
44
|
@prompt.select(
|
44
|
-
@pastel.
|
45
|
+
@pastel.public_send(Tng::UI::Theme.color(:primary), "Choose test generation type:"),
|
45
46
|
cycle: true,
|
46
|
-
symbols: { marker:
|
47
|
+
symbols: { marker: Tng::UI::Theme.icon(:marker) }
|
47
48
|
) do |menu|
|
48
|
-
menu.choice @pastel.
|
49
|
-
|
50
|
-
menu.choice @pastel.
|
49
|
+
menu.choice @pastel.public_send(Tng::UI::Theme.color(:success), "Generate all possible tests"),
|
50
|
+
:all_possible_tests
|
51
|
+
menu.choice @pastel.public_send(Tng::UI::Theme.color(:info), "Generate per method"), :per_method
|
52
|
+
menu.choice @pastel.public_send(Tng::UI::Theme.color(:secondary), "#{Tng::UI::Theme.icon(:back)} Back"), :back
|
51
53
|
end
|
52
54
|
end
|
53
55
|
|
54
56
|
def show_no_models_message
|
55
57
|
puts
|
56
|
-
puts center_text(
|
57
|
-
|
58
|
+
puts Tng::UI::Theme.center_text(
|
59
|
+
@pastel.public_send(Tng::UI::Theme.color(:warning),
|
60
|
+
"#{Tng::UI::Theme.icon(:warning)} No models found in app/models"), @terminal_width
|
61
|
+
)
|
62
|
+
puts Tng::UI::Theme.center_text(
|
63
|
+
@pastel.public_send(Tng::UI::Theme.color(:muted),
|
64
|
+
"Make sure you're in a Rails project with models"), @terminal_width
|
65
|
+
)
|
58
66
|
puts
|
59
67
|
end
|
60
68
|
|
61
69
|
def select_model_method(model, methods)
|
62
|
-
header = @pastel.
|
63
|
-
puts center_text(header)
|
70
|
+
header = @pastel.public_send(Tng::UI::Theme.color(:primary)).bold("#{Tng::UI::Theme.icon(:rocket)} Select method to test in #{model[:name]}")
|
71
|
+
puts Tng::UI::Theme.center_text(header, @terminal_width)
|
64
72
|
|
65
73
|
@prompt.select(
|
66
74
|
"",
|
67
75
|
cycle: true,
|
68
76
|
per_page: 10,
|
69
77
|
filter: true,
|
70
|
-
symbols: { marker:
|
78
|
+
symbols: { marker: Tng::UI::Theme.icon(:marker) }
|
71
79
|
) do |menu|
|
72
80
|
methods.each do |method|
|
73
81
|
menu.choice method[:name], method
|
74
82
|
end
|
75
|
-
menu.choice @pastel.
|
83
|
+
menu.choice @pastel.public_send(Tng::UI::Theme.color(:secondary), "#{Tng::UI::Theme.icon(:back)} Back"), :back
|
76
84
|
end
|
77
85
|
end
|
78
86
|
|
79
87
|
def show_no_methods_message(model)
|
80
|
-
error_msg = "#{@pastel.
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
padding = [(@terminal_width - strip_ansi(text).length) / 2, 0].max
|
89
|
-
"#{" " * padding}#{text}"
|
90
|
-
end
|
91
|
-
|
92
|
-
def strip_ansi(text)
|
93
|
-
text.gsub(/\e\[([;\d]+)?m/, "")
|
88
|
+
error_msg = "#{@pastel.public_send(Tng::UI::Theme.color(:error)).bold("#{Tng::UI::Theme.icon(:error)} No methods found in #{model[:name]}")}\n#{@pastel.public_send(
|
89
|
+
Tng::UI::Theme.color(:muted), "Model may be empty or have syntax errors"
|
90
|
+
)}"
|
91
|
+
puts Tng::UI::Theme.center_text(error_msg, @terminal_width)
|
92
|
+
@prompt.keypress(Tng::UI::Theme.center_text(
|
93
|
+
@pastel.public_send(Tng::UI::Theme.color(:muted),
|
94
|
+
"Press any key to continue..."), @terminal_width
|
95
|
+
))
|
94
96
|
end
|
95
97
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require "tty-box"
|
2
2
|
require "pastel"
|
3
|
+
require_relative "theme"
|
3
4
|
|
4
5
|
class PostInstallBox
|
5
6
|
attr_reader :version, :pastel
|
@@ -16,35 +17,46 @@ class PostInstallBox
|
|
16
17
|
|
17
18
|
def content
|
18
19
|
[
|
19
|
-
pastel.
|
20
|
+
pastel.public_send(Tng::UI::Theme.color(:success)).bold("#{Tng::UI::Theme.icon(:success)} Tng installed successfully!"),
|
20
21
|
"",
|
21
|
-
pastel.
|
22
|
+
pastel.public_send(Tng::UI::Theme.color(:warning)).bold("#{Tng::UI::Theme.icon(:config)} SETUP REQUIRED"),
|
22
23
|
"",
|
23
|
-
pastel.
|
24
|
-
pastel.
|
24
|
+
pastel.public_send(Tng::UI::Theme.color(:primary), "1. Generate configuration:"),
|
25
|
+
pastel.public_send(Tng::UI::Theme.color(:secondary), " rails g tng:install"),
|
25
26
|
"",
|
26
|
-
pastel.
|
27
|
-
pastel.
|
27
|
+
pastel.public_send(Tng::UI::Theme.color(:primary), "2. Edit configuration file:"),
|
28
|
+
pastel.public_send(Tng::UI::Theme.color(:secondary), " config/initializers/tng.rb"),
|
28
29
|
"",
|
29
|
-
pastel.
|
30
|
-
pastel.
|
30
|
+
pastel.public_send(Tng::UI::Theme.color(:primary), "3. Add your license key:"),
|
31
|
+
pastel.public_send(Tng::UI::Theme.color(:secondary), " config.api_key = 'your-license-key-here'"),
|
31
32
|
"",
|
32
|
-
pastel.
|
33
|
+
pastel.public_send(Tng::UI::Theme.color(:primary),
|
34
|
+
"#{Tng::UI::Theme.icon(:config)} Check documentation for the correct authentication setup"),
|
33
35
|
"",
|
34
|
-
pastel.
|
36
|
+
pastel.public_send(Tng::UI::Theme.color(:accent)).bold("#{Tng::UI::Theme.icon(:rocket)} Usage:"),
|
35
37
|
"",
|
36
|
-
pastel.
|
37
|
-
pastel.
|
38
|
+
pastel.public_send(Tng::UI::Theme.color(:primary), "Interactive mode:"),
|
39
|
+
pastel.public_send(Tng::UI::Theme.color(:success),
|
40
|
+
"#{Tng::UI::Theme.icon(:bullet)} bundle exec tng") + pastel.public_send(Tng::UI::Theme.color(:muted),
|
41
|
+
" - Full interactive CLI"),
|
38
42
|
"",
|
39
|
-
pastel.
|
40
|
-
pastel.
|
41
|
-
|
42
|
-
|
43
|
+
pastel.public_send(Tng::UI::Theme.color(:primary), "Direct generation:"),
|
44
|
+
pastel.public_send(Tng::UI::Theme.color(:success),
|
45
|
+
"#{Tng::UI::Theme.icon(:bullet)} bundle exec tng -t c -f ping") + pastel.public_send(Tng::UI::Theme.color(:muted),
|
46
|
+
" - Short"),
|
47
|
+
pastel.public_send(Tng::UI::Theme.color(:success),
|
48
|
+
"#{Tng::UI::Theme.icon(:bullet)} bundle exec tng -t=c f=ping") + pastel.public_send(Tng::UI::Theme.color(:muted),
|
49
|
+
" - Mixed"),
|
50
|
+
pastel.public_send(Tng::UI::Theme.color(:success),
|
51
|
+
"#{Tng::UI::Theme.icon(:bullet)} bundle exec tng --type=controller --file=ping"),
|
43
52
|
"",
|
44
|
-
pastel.
|
45
|
-
pastel.
|
53
|
+
pastel.public_send(Tng::UI::Theme.color(:primary), "Help:"),
|
54
|
+
pastel.public_send(Tng::UI::Theme.color(:success),
|
55
|
+
"#{Tng::UI::Theme.icon(:bullet)} bundle exec tng --help") + pastel.public_send(Tng::UI::Theme.color(:muted),
|
56
|
+
" - Show all options"),
|
46
57
|
"",
|
47
|
-
pastel.
|
58
|
+
pastel.public_send(Tng::UI::Theme.color(:muted),
|
59
|
+
"#{Tng::UI::Theme.icon(:lightbulb)} Use -t c for controller, -t m for model")
|
48
60
|
].join("\n")
|
49
61
|
end
|
50
62
|
|
@@ -52,20 +64,17 @@ class PostInstallBox
|
|
52
64
|
# Use a reasonable width that won't cause issues
|
53
65
|
box_width = [@terminal_width, 70].min
|
54
66
|
|
67
|
+
style = Tng::UI::Theme.box_style(:default)
|
55
68
|
TTY::Box.frame(
|
56
69
|
title: { top_left: " TNG ", bottom_right: " v#{@version} " },
|
57
|
-
style:
|
58
|
-
|
59
|
-
border: { fg: :cyan },
|
60
|
-
title: { fg: :bright_cyan }
|
61
|
-
},
|
62
|
-
padding: [1, 2],
|
70
|
+
style: style[:style],
|
71
|
+
padding: style[:padding],
|
63
72
|
align: :left,
|
64
73
|
width: box_width
|
65
74
|
) do
|
66
75
|
content
|
67
76
|
end
|
68
|
-
rescue StandardError
|
77
|
+
rescue StandardError
|
69
78
|
"TNG v#{@version} installed successfully!\n" +
|
70
79
|
"Run 'rails g tng:install' to get started.\n" +
|
71
80
|
"Use 'bundle exec tng --help' for usage information."
|
@@ -4,6 +4,7 @@ require "tty-prompt"
|
|
4
4
|
require "tty-spinner"
|
5
5
|
require "pastel"
|
6
6
|
require "tty-screen"
|
7
|
+
require_relative "theme"
|
7
8
|
|
8
9
|
class ServiceTestFlowDisplay
|
9
10
|
def initialize(prompt, pastel)
|
@@ -17,73 +18,78 @@ class ServiceTestFlowDisplay
|
|
17
18
|
end
|
18
19
|
|
19
20
|
def select_service(services)
|
20
|
-
header = @pastel.
|
21
|
-
puts center_text(header)
|
21
|
+
header = @pastel.public_send(Tng::UI::Theme.color(:primary)).bold("#{Tng::UI::Theme.icon(:config)} Select service to test:")
|
22
|
+
puts Tng::UI::Theme.center_text(header, @terminal_width)
|
22
23
|
|
23
24
|
@prompt.select(
|
24
25
|
"",
|
25
26
|
cycle: true,
|
26
27
|
per_page: 12,
|
27
28
|
filter: true,
|
28
|
-
symbols: { marker:
|
29
|
+
symbols: { marker: Tng::UI::Theme.icon(:marker) }
|
29
30
|
) do |menu|
|
30
31
|
services.each do |service|
|
31
|
-
display_name = "#{service[:name]} #{@pastel.
|
32
|
+
display_name = "#{service[:name]} #{@pastel.public_send(Tng::UI::Theme.color(:muted), "(#{service[:path]})")}"
|
32
33
|
menu.choice display_name, service
|
33
34
|
end
|
34
|
-
menu.choice @pastel.
|
35
|
+
menu.choice @pastel.public_send(Tng::UI::Theme.color(:secondary), "#{Tng::UI::Theme.icon(:back)} Back"), :back
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
38
39
|
def select_test_option(service_choice)
|
39
|
-
header = @pastel.
|
40
|
-
puts center_text(header)
|
40
|
+
header = @pastel.public_send(Tng::UI::Theme.color(:primary)).bold("#{Tng::UI::Theme.icon(:rocket)} Test Generation Options for #{service_choice[:name]}")
|
41
|
+
puts Tng::UI::Theme.center_text(header, @terminal_width)
|
41
42
|
puts
|
42
43
|
|
43
44
|
@prompt.select(
|
44
|
-
@pastel.
|
45
|
+
@pastel.public_send(Tng::UI::Theme.color(:primary), "Choose test generation type:"),
|
45
46
|
cycle: true,
|
46
|
-
symbols: { marker:
|
47
|
+
symbols: { marker: Tng::UI::Theme.icon(:marker) }
|
47
48
|
) do |menu|
|
48
|
-
menu.choice @pastel.
|
49
|
-
|
50
|
-
menu.choice @pastel.
|
49
|
+
menu.choice @pastel.public_send(Tng::UI::Theme.color(:success), "Generate all possible tests"),
|
50
|
+
:all_possible_tests
|
51
|
+
menu.choice @pastel.public_send(Tng::UI::Theme.color(:info), "Generate per method"), :per_method
|
52
|
+
menu.choice @pastel.public_send(Tng::UI::Theme.color(:secondary), "#{Tng::UI::Theme.icon(:back)} Back"), :back
|
51
53
|
end
|
52
54
|
end
|
53
55
|
|
54
56
|
def show_no_services_message
|
55
|
-
error_msg = "#{@pastel.
|
56
|
-
|
57
|
-
|
57
|
+
error_msg = "#{@pastel.public_send(Tng::UI::Theme.color(:error)).bold("#{Tng::UI::Theme.icon(:error)} No services found in your application")}\n#{@pastel.public_send(
|
58
|
+
Tng::UI::Theme.color(:muted), "Make sure you have services in app/services/ or app/service/"
|
59
|
+
)}"
|
60
|
+
puts Tng::UI::Theme.center_text(error_msg, @terminal_width)
|
61
|
+
@prompt.keypress(Tng::UI::Theme.center_text(
|
62
|
+
@pastel.public_send(Tng::UI::Theme.color(:muted),
|
63
|
+
"Press any key to continue..."), @terminal_width
|
64
|
+
))
|
58
65
|
end
|
59
66
|
|
60
67
|
def select_service_method(service, methods)
|
61
|
-
header = @pastel.
|
62
|
-
puts center_text(header)
|
68
|
+
header = @pastel.public_send(Tng::UI::Theme.color(:primary)).bold("#{Tng::UI::Theme.icon(:rocket)} Select method to test for #{service[:name]}")
|
69
|
+
puts Tng::UI::Theme.center_text(header, @terminal_width)
|
63
70
|
|
64
71
|
@prompt.select(
|
65
72
|
"",
|
66
73
|
cycle: true,
|
67
74
|
per_page: 12,
|
68
75
|
filter: true,
|
69
|
-
symbols: { marker:
|
76
|
+
symbols: { marker: Tng::UI::Theme.icon(:marker) }
|
70
77
|
) do |menu|
|
71
78
|
methods.each do |method|
|
72
79
|
menu.choice "#{method[:name]}", method
|
73
80
|
end
|
74
|
-
menu.choice @pastel.
|
81
|
+
menu.choice @pastel.public_send(Tng::UI::Theme.color(:secondary), "#{Tng::UI::Theme.icon(:back)} Back"), :back
|
75
82
|
end
|
76
83
|
end
|
77
84
|
|
78
85
|
def show_no_methods_message(service)
|
79
|
-
error_msg = "#{@pastel.
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
(" " * padding) + text
|
86
|
+
error_msg = "#{@pastel.public_send(Tng::UI::Theme.color(:error)).bold("#{Tng::UI::Theme.icon(:error)} No methods found in #{service[:name]}")}\n#{@pastel.public_send(
|
87
|
+
Tng::UI::Theme.color(:muted), "The service might not have any public methods or could not be analyzed."
|
88
|
+
)}"
|
89
|
+
puts Tng::UI::Theme.center_text(error_msg, @terminal_width)
|
90
|
+
@prompt.keypress(Tng::UI::Theme.center_text(
|
91
|
+
@pastel.public_send(Tng::UI::Theme.color(:muted),
|
92
|
+
"Press any key to continue..."), @terminal_width
|
93
|
+
))
|
88
94
|
end
|
89
95
|
end
|