belt 0.4.2 → 0.4.3

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: e17e0755e497e26d8bd10604e6f050b0c6e0b69e3627276f8d83be984862d5da
4
- data.tar.gz: b4249c4ac11715ae45a091c3eced0d0bad8ecd5d89a750edfaa8586ab6449758
3
+ metadata.gz: f2a6059e3ba3ce67327476626815d9a1b61b441836877277c44d04978dfa2727
4
+ data.tar.gz: d714bba5f18070ed1504e33f473a9fd2497019da7fe7c5609b9d97e4676d70ee
5
5
  SHA512:
6
- metadata.gz: abe5b18f7eeeb92bba2863746e7cc71d854078462274993403c4d7b93af81ff2c82a3b5c1db2fbdf537f8a139ec15964d76aad042505ade12ad64e6069f40a5a
7
- data.tar.gz: dba1d0cca64620fc48b495ee844600e7a8e38c577ad3f27ada191263038f38a081a3d640f9a66e00fd97c138e1686ae91654d6995225d357bec8a5016e903f5e
6
+ metadata.gz: d6feaddb7cb071ee7cb75427544d2d32b65ddf9354c3fa08461a67247485fdd6adddf986d93d0ee3fa778ab491136ca14395e5b6dc67fc918eb19b748b8a4214
7
+ data.tar.gz: 56b99bafbc94e4abcb7fa64cb3ca7b1744591c17c84afea3fe1cab07bb1cbeffe6c76f7af5b6c6f19a51bebffecba10091a70125de012f885709e417cf817bd2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.3
4
+
5
+ ### Bug Fix
6
+
7
+ - **`belt deploy` preflight no longer false-fails on `belongs_to ..., index: false`.**
8
+ The deploy preflight added in 0.4.2 demanded a `{Assoc}Index` GSI for *every*
9
+ `belongs_to`, ignoring `index: false` and `index: 'CustomName'` — the exact
10
+ opt-outs the table generator honours. The two halves of the gem disagreed: a
11
+ model that opts out (its reverse lookup is covered by another GSI, or it doesn't
12
+ need one) got a passing `belt setup tables` and a failing `belt deploy`, with no
13
+ way out but `--force`-ing the generator or pinning back to 0.4.1. The preflight's
14
+ index extraction now mirrors the generator exactly: it skips `index: false` and
15
+ honours an explicit `index: 'Name'`. `foreign_key:`-remapped associations
16
+ (`belongs_to :user, foreign_key: 'cognito_sub', index: false`) no longer demand a
17
+ phantom `UserIndex` either.
18
+
3
19
  ## Unreleased
4
20
 
5
21
  ### Bug Fix
@@ -262,19 +262,33 @@ module Belt
262
262
  end
263
263
  end
264
264
 
265
+ # Which GSIs a model's belongs_to declarations require. This MUST agree with the
266
+ # generator (TablesCommand#extract_belongs_to_indexes) or the two halves of the gem
267
+ # disagree: the generator refuses to create an index the preflight then demands,
268
+ # and `belt setup tables` → `belt deploy` loops forever.
269
+ #
270
+ # `index: false` opts out — the reverse lookup is covered some other way (the
271
+ # model's own indexes() entry under a different key, or no reverse lookup at all).
272
+ # The generator skips those, so the preflight must too.
273
+ #
274
+ # An explicit `index: 'Name'` overrides the convention name; we honour it so the
275
+ # check matches the GSI the model actually declared.
265
276
  def extract_expected_indexes(content)
266
277
  indexes = []
267
- content.lines.reject { |line| line.strip.start_with?('#') }.join
268
- .scan(/belongs_to\s+:(\w+)/) do |match|
269
- association_name = match[0]
270
- indexes << {
271
- name: "#{Belt::Inflector.classify(association_name)}Index",
272
- association: association_name
273
- }
278
+ uncommented(content).scan(/belongs_to\s+:(\w+)([^\n]*)/) do |association_name, options|
279
+ next if options.match?(/index:\s*false/)
280
+
281
+ explicit = options.match(/index:\s*['"]([^'"]+)['"]/)
282
+ name = explicit ? explicit[1] : "#{Belt::Inflector.classify(association_name)}Index"
283
+ indexes << { name: name, association: association_name }
274
284
  end
275
285
  indexes
276
286
  end
277
287
 
288
+ def uncommented(content)
289
+ content.lines.reject { |line| line.strip.start_with?('#') }.join
290
+ end
291
+
278
292
  def check_cognito_auth
279
293
  return unless Belt.root?
280
294
 
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.4.2'
4
+ VERSION = '0.4.3'
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.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stowzilla