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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2e326b668a9c84c05be3a8b67b079fe62477131ea5d6bf7f641cc791c9ecf484
4
- data.tar.gz: 1d7d72326e7941a6fccb5474a9e659f72f62120e5b3212d0331c7d2229e99ab9
3
+ metadata.gz: '0308512f255c22a7fbc31ff42a20947ee8c155c4c9ceaea3a4824a1e5a50c618'
4
+ data.tar.gz: e071128ae46f66256e4f52c5a0b3eb096e49faf2a0cde9e6c3d962c6ed54af93
5
5
  SHA512:
6
- metadata.gz: 2a5f09abb9d336b745fb4387b980c099436cf7b5a170b7ac48b0bce1e8104c964cb565213b1cd959edc498c8d1fbba491bd0066cf0d6dae45ef2ff89eaa9c31a
7
- data.tar.gz: 4ae1253f78503c66853b54de458f577e25c13a95e3616021264c25cbc7090ec389ec6aef7b2fc5bd6bbb28256509bda6a4e2b1a008b936969807efc35c7da9dd
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
- @name = name&.downcase&.gsub(/[^a-z0-9_]/, '_')
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
@@ -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
- full_path = options[:on] == :collection ? "#{@collection_prefix}#{path}" : "#{@prefix}#{path}"
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 = "#{@prefix}#{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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Belt
4
- VERSION = '0.3.36'
4
+ VERSION = '0.3.37'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: belt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.36
4
+ version: 0.3.37
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stowzilla