belt 0.3.36 → 0.3.37
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/belt/cli/destroy_command.rb +7 -1
- data/lib/belt/route_dsl.rb +21 -2
- data/lib/belt/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '0308512f255c22a7fbc31ff42a20947ee8c155c4c9ceaea3a4824a1e5a50c618'
|
|
4
|
+
data.tar.gz: e071128ae46f66256e4f52c5a0b3eb096e49faf2a0cde9e6c3d962c6ed54af93
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ec4a7be24ec7cb6961ed6c06cbc7690eb05a92406cf10cedf8760ef5cde8d464bd062652524ca74e41fdd6045f495b77e1c252823d1d18e14090ed986073f1ac
|
|
7
|
+
data.tar.gz: '08f0980d98b9c868c7e53c23236acc3c72be619f3b361dea0a1520a3d5e71549ad95758d7cc8cdbdd21186dfcbd7f6e7d7acff822b1b12d00225d2c35711f6e3'
|
|
@@ -148,7 +148,13 @@ module Belt
|
|
|
148
148
|
# -- keyword options for destroy flags
|
|
149
149
|
def initialize(generator, name, fields, force: false, skip_terraform: false, full: false, frontend_name: nil)
|
|
150
150
|
@generator = generator
|
|
151
|
-
|
|
151
|
+
# Environment names preserve hyphens (matching `belt g environment`);
|
|
152
|
+
# other generators normalize to underscores for valid Ruby identifiers.
|
|
153
|
+
@name = if generator == 'environment'
|
|
154
|
+
name&.downcase&.gsub(/[^a-z0-9_-]/, '')
|
|
155
|
+
else
|
|
156
|
+
name&.downcase&.gsub(/[^a-z0-9_]/, '_')
|
|
157
|
+
end
|
|
152
158
|
@fields = fields
|
|
153
159
|
@force = force
|
|
154
160
|
@skip_terraform = skip_terraform
|
data/lib/belt/route_dsl.rb
CHANGED
|
@@ -96,7 +96,8 @@ module Belt
|
|
|
96
96
|
|
|
97
97
|
%i[get post put delete patch].each do |method|
|
|
98
98
|
define_method(method) do |path, options = {}|
|
|
99
|
-
|
|
99
|
+
base = options[:on] == :collection ? @collection_prefix : @prefix
|
|
100
|
+
full_path = join_path(base, path)
|
|
100
101
|
options = merge_inherited_options(options)
|
|
101
102
|
route_options = options.except(:on)
|
|
102
103
|
@gateway.send(:add_route, method, full_path, route_options)
|
|
@@ -105,6 +106,15 @@ module Belt
|
|
|
105
106
|
|
|
106
107
|
private
|
|
107
108
|
|
|
109
|
+
# Join a base path with a relative path, ensuring exactly one `/` separator.
|
|
110
|
+
def join_path(base, path)
|
|
111
|
+
path = path.to_s
|
|
112
|
+
return base if path.empty?
|
|
113
|
+
return "#{base}#{path}" if path.start_with?('/')
|
|
114
|
+
|
|
115
|
+
"#{base}/#{path}"
|
|
116
|
+
end
|
|
117
|
+
|
|
108
118
|
def add_nested_resource_routes(resource_name, param_name, resource_options, actions)
|
|
109
119
|
if actions.include?(:index)
|
|
110
120
|
@gateway.send(:add_route, :get, "#{@prefix}/#{resource_name}",
|
|
@@ -165,7 +175,7 @@ module Belt
|
|
|
165
175
|
|
|
166
176
|
%i[get post put delete patch].each do |method|
|
|
167
177
|
define_method(method) do |path, options = {}|
|
|
168
|
-
full_path =
|
|
178
|
+
full_path = join_path(@prefix, path)
|
|
169
179
|
options = merge_inherited_options(options)
|
|
170
180
|
@gateway.send(:add_route, method, full_path, options)
|
|
171
181
|
end
|
|
@@ -173,6 +183,15 @@ module Belt
|
|
|
173
183
|
|
|
174
184
|
private
|
|
175
185
|
|
|
186
|
+
# Join a base path with a relative path, ensuring exactly one `/` separator.
|
|
187
|
+
def join_path(base, path)
|
|
188
|
+
path = path.to_s
|
|
189
|
+
return base if path.empty?
|
|
190
|
+
return "#{base}#{path}" if path.start_with?('/')
|
|
191
|
+
|
|
192
|
+
"#{base}/#{path}"
|
|
193
|
+
end
|
|
194
|
+
|
|
176
195
|
def merge_inherited_options(options)
|
|
177
196
|
result = options.dup
|
|
178
197
|
if @inherited_tables.any?
|
data/lib/belt/version.rb
CHANGED