belt 0.4.3 → 0.4.4
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/CHANGELOG.md +15 -0
- data/lib/belt/route_dsl.rb +14 -3
- 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: 8a4efb62a37845ad3c311558cebdd71fcf74ba7ae31870f3c2728e286dc33a72
|
|
4
|
+
data.tar.gz: 8278be1ba1c44b6d355d00963ca1d33c401749b0af584a4cb5c07f6ae25bca54
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b3d9d4782cd23143c6674b674780072784077105eeef396ec04d55b194ef102c643c5cd646311cdf024983c1e1a7f70407bea5bb2e0cb5261938e58d0dcceb87
|
|
7
|
+
data.tar.gz: a7e6cc11a4e2625b135cf967af4f614dcaa21fd7ee7b8cfcbea42bd68eea8976368a6392e257f2f229f8a6e9673414546044628cefa1f4fe0d6a2d9042b0b90f
|
data/CHANGELOG.md
CHANGED
|
@@ -18,8 +18,23 @@
|
|
|
18
18
|
|
|
19
19
|
## Unreleased
|
|
20
20
|
|
|
21
|
+
## 0.4.4
|
|
22
|
+
|
|
21
23
|
### Bug Fix
|
|
22
24
|
|
|
25
|
+
- **Gateway-level `scope path:` with a param segment no longer emits malformed paths.**
|
|
26
|
+
A gateway-level `scope path: 'accounts/:account_id'` used to leak the raw Rails-style
|
|
27
|
+
`:account_id` segment straight into route paths (`/accounts/:account_id/changes`)
|
|
28
|
+
instead of the API Gateway `{account_id}` form, and — worse — a bare-param scope with a
|
|
29
|
+
path that didn't start with `/` (e.g. `get 'summary'`) produced fused garbage like
|
|
30
|
+
`/accounts/{account_idsummary}`. It also folded the param segment into the derived
|
|
31
|
+
controller module (`accounts/:account_id/changes`). Now `build_path` joins the scope
|
|
32
|
+
prefix and route path with exactly one `/` and normalizes `:param` → `{param}`, and
|
|
33
|
+
the controller module is derived only from the scope's *static* segments (matching
|
|
34
|
+
Rails, where `scope path:` shapes the URL, not the module). Static-only scopes
|
|
35
|
+
(`scope path: 'admin'` → `admin/users`) are unchanged. A scope nested inside a
|
|
36
|
+
`resources` block was already fine; only the gateway-level case was broken.
|
|
37
|
+
|
|
23
38
|
- **`belt setup tables` no longer silently clobbers hand-added tables/GSIs.**
|
|
24
39
|
Regenerating `dynamodb.tf` is a full overwrite from `lambda/models/*.rb`, so a
|
|
25
40
|
table or `global_secondary_index` added straight into the `.tf` file — one the
|
data/lib/belt/route_dsl.rb
CHANGED
|
@@ -788,14 +788,25 @@ module Belt
|
|
|
788
788
|
private
|
|
789
789
|
|
|
790
790
|
def build_path(path)
|
|
791
|
-
|
|
791
|
+
path = path.to_s
|
|
792
|
+
sep = @scope_prefix.empty? || path.empty? || path.start_with?('/') ? '' : '/'
|
|
793
|
+
prefix = @scope_prefix.empty? ? '' : "/#{@scope_prefix}"
|
|
794
|
+
# Normalize Rails-style `:param` → API Gateway `{param}` so a gateway-level
|
|
795
|
+
# `scope path:` with a param (e.g. "accounts/:account_id") emits valid paths.
|
|
796
|
+
"#{prefix}#{sep}#{path}".gsub(/:([a-zA-Z_]\w*)/) { "{#{::Regexp.last_match(1)}}" }
|
|
797
|
+
end
|
|
798
|
+
|
|
799
|
+
# Strip param segments (`:param` / `{param}`) from a scope prefix before using it
|
|
800
|
+
# as a controller module: `scope path:` affects the URL, not the module.
|
|
801
|
+
def controller_module_from_prefix(prefix)
|
|
802
|
+
prefix.to_s.split('/').reject { |s| s.empty? || s.start_with?(':', '{') }.join('/')
|
|
792
803
|
end
|
|
793
804
|
|
|
794
805
|
def determine_scoped_controller(resource_name)
|
|
795
806
|
if @scope_module && !@scope_module.empty?
|
|
796
807
|
"#{@scope_module}/#{resource_name}"
|
|
797
|
-
elsif !@scope_prefix.empty?
|
|
798
|
-
"#{
|
|
808
|
+
elsif !@scope_prefix.empty? && !(mod = controller_module_from_prefix(@scope_prefix)).empty?
|
|
809
|
+
"#{mod}/#{resource_name}"
|
|
799
810
|
else
|
|
800
811
|
resource_name
|
|
801
812
|
end
|
data/lib/belt/version.rb
CHANGED