tng 0.1.5 → 0.1.6
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/lib/tng/ui/show_help.rb +12 -1
- data/lib/tng/ui/theme.rb +11 -19
- 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: d9a79e45532cb4a0a79648c689dc0b74de6b9ce630f9bcf133441ff5bb927e6c
|
4
|
+
data.tar.gz: 91841602114d06c26e04983a5db2912b21efb0f9e0f810a31f2de1c4d25ea7e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ea19d449f5996ced3d0b0a654ae0549c78cb8c82632d328ee3754c76ed0941e5ba0eff184e362643307d555b93802ef324d42ef19dcf285c0680ed18886d065
|
7
|
+
data.tar.gz: 126e393b129b43bf94fd9421b08212cbcb42c54c133b2c3fd0643f01ba8f93613b048f64aa47e285501785e68e984597ea30c13bb56b3f40653a381aebbd9e65
|
data/lib/tng/ui/show_help.rb
CHANGED
@@ -46,6 +46,9 @@ class ShowHelp
|
|
46
46
|
@pastel.public_send(Tng::UI::Theme.color(:success),
|
47
47
|
" bundle exec tng -t m -f user") + @pastel.public_send(Tng::UI::Theme.color(:muted),
|
48
48
|
" # Model test"),
|
49
|
+
@pastel.public_send(Tng::UI::Theme.color(:success),
|
50
|
+
" bundle exec tng -t s -f user_service") + @pastel.public_send(Tng::UI::Theme.color(:muted),
|
51
|
+
" # Service test"),
|
49
52
|
@pastel.public_send(Tng::UI::Theme.color(:success),
|
50
53
|
" bundle exec tng --type=controller --file=users_controller"),
|
51
54
|
@pastel.public_send(Tng::UI::Theme.color(:success),
|
@@ -55,7 +58,7 @@ class ShowHelp
|
|
55
58
|
@pastel.public_send(Tng::UI::Theme.color(:accent)).bold("Options:"),
|
56
59
|
@pastel.public_send(Tng::UI::Theme.color(:primary),
|
57
60
|
" -t, --type=TYPE") + @pastel.public_send(Tng::UI::Theme.color(:muted),
|
58
|
-
" Test type (controller, model)"),
|
61
|
+
" Test type (controller, model, service)"),
|
59
62
|
@pastel.public_send(Tng::UI::Theme.color(:primary),
|
60
63
|
" -f, --file=FILE") + @pastel.public_send(Tng::UI::Theme.color(:muted),
|
61
64
|
" File name (without .rb extension)"),
|
@@ -74,6 +77,10 @@ class ShowHelp
|
|
74
77
|
" #{Tng::UI::Theme.icon(:bullet)} Models: ") + @pastel.public_send(
|
75
78
|
Tng::UI::Theme.color(:secondary), "m, mo, model"
|
76
79
|
),
|
80
|
+
@pastel.public_send(Tng::UI::Theme.color(:muted),
|
81
|
+
" #{Tng::UI::Theme.icon(:bullet)} Services: ") + @pastel.public_send(
|
82
|
+
Tng::UI::Theme.color(:secondary), "s, se, service"
|
83
|
+
),
|
77
84
|
"",
|
78
85
|
@pastel.public_send(Tng::UI::Theme.color(:accent)).bold("File Format:"),
|
79
86
|
@pastel.public_send(Tng::UI::Theme.color(:muted),
|
@@ -83,6 +90,10 @@ class ShowHelp
|
|
83
90
|
" #{Tng::UI::Theme.icon(:bullet)} Models: ") + @pastel.public_send(
|
84
91
|
Tng::UI::Theme.color(:success), "user, blog/post"
|
85
92
|
),
|
93
|
+
@pastel.public_send(Tng::UI::Theme.color(:muted),
|
94
|
+
" #{Tng::UI::Theme.icon(:bullet)} Services: ") + @pastel.public_send(
|
95
|
+
Tng::UI::Theme.color(:success), "user_service, payment/stripe_service"
|
96
|
+
),
|
86
97
|
@pastel.public_send(Tng::UI::Theme.color(:muted),
|
87
98
|
" #{Tng::UI::Theme.icon(:bullet)} Don't include .rb extension"),
|
88
99
|
"",
|
data/lib/tng/ui/theme.rb
CHANGED
@@ -104,27 +104,21 @@ module Tng
|
|
104
104
|
}
|
105
105
|
}.freeze
|
106
106
|
|
107
|
-
# Helper methods for consistent styling
|
108
107
|
module_function
|
109
108
|
|
109
|
+
# Cache for background detection to avoid multiple escape sequences
|
110
|
+
@background_cache = nil
|
111
|
+
|
110
112
|
def detect_terminal_background
|
111
|
-
#
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
else
|
118
|
-
# Skip background detection if explicitly disabled
|
119
|
-
return :dark if ENV["TNG_DISABLE_BACKGROUND_DETECTION"] == "true"
|
120
|
-
|
121
|
-
get_background_color
|
122
|
-
end
|
113
|
+
# Return cached result if available
|
114
|
+
return @background_cache if @background_cache
|
115
|
+
|
116
|
+
# Get background color and cache the result
|
117
|
+
@background_cache = get_background_color
|
118
|
+
@background_cache
|
123
119
|
end
|
124
120
|
|
125
121
|
def get_background_color
|
126
|
-
# Don't attempt background detection if not in an interactive terminal
|
127
|
-
# or during Rails startup/loading
|
128
122
|
return :dark unless $stdout.tty? && $stdin.tty? && interactive_session?
|
129
123
|
|
130
124
|
print "\e]11;?\e\\"
|
@@ -176,13 +170,11 @@ module Tng
|
|
176
170
|
end
|
177
171
|
|
178
172
|
def interactive_session?
|
179
|
-
|
180
|
-
return false if
|
181
|
-
return false if ENV["BUNDLE_GEMFILE"] && !ENV["TNG_FORCE_BACKGROUND_DETECTION"]
|
173
|
+
return false if defined?(Rails) && Rails.respond_to?(:application) && Rails.application&.initialized?
|
174
|
+
return false if ENV["BUNDLE_GEMFILE"]
|
182
175
|
return false if $PROGRAM_NAME&.include?("bundle")
|
183
176
|
return false if $PROGRAM_NAME&.include?("rails") && ARGV.any? { |arg| %w[server console runner].include?(arg) }
|
184
177
|
|
185
|
-
# Only allow in truly interactive contexts
|
186
178
|
ENV["TNG_CLI"] == "true" || $PROGRAM_NAME&.include?("tng")
|
187
179
|
end
|
188
180
|
|
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.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ralucab
|
@@ -268,7 +268,7 @@ post_install_message: "┌ TNG ────────────────
|
|
268
268
|
exec tng --help - Show all options │\n│ │\n│
|
269
269
|
\ \U0001F4A1 Use -t c for controller, -t m for model │\n│
|
270
270
|
\ │\n└────────────────────────────────────────────────────────────
|
271
|
-
v0.1.
|
271
|
+
v0.1.6 ┘\n"
|
272
272
|
rdoc_options: []
|
273
273
|
require_paths:
|
274
274
|
- lib
|