thecore_generators 3.13.0 → 3.13.1

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: 146693a69bac954bb16fae029f76d60a5f92d2702f90d1cfda0b19e8a4e1a796
4
- data.tar.gz: 728d2a12604ebb33b6efa6c7e27e33f7b086e3f61f7042492e5db0d4f9772b6c
3
+ metadata.gz: 82aaaedd48f043efdbc3f73c96a2dd28a59de2dede02d9be51c457a5ac2a8728
4
+ data.tar.gz: 6a9e1221628db11797320a882387bf0843cedea3861d3c338619271aa73d8c53
5
5
  SHA512:
6
- metadata.gz: 738f18d403082dedbbfc4ce40a3376bc03c5057c6789a63436114bf135e262e6127e201c44a65c7ce76a0423eaab0cc198705d47501057d855c96b634ba1ec33
7
- data.tar.gz: 3559b1310d5d59046158ec81232bc8b86a527c05130c605b571589a65f11c23566b119029d9f36a35b985351b13d31306c66acfbb2f5ee281d6b259a95b2dcd7
6
+ metadata.gz: a4781db70ca0658359f4ba768d34a9bce1433aadd1c87565b07a360dc4b57da7c1de98f4366b0b6a0dbaa3f753407433474259d8bcf086cd56366850a813b541
7
+ data.tar.gz: 0cbc37cc33e26a67f19d1c0a5dddd87595601c964eb5f2d6468ec839075ab8639082a82eb9e40691eaf5cc6496949519d1ba4aee62222e56e7125d5a0026c3bb
data/README.md CHANGED
@@ -433,17 +433,20 @@ git-based dependencies — see the Gemfile's comment — purely so
433
433
  `test/generators/thecore/model_generator_default_concern_behavior_test.rb` can prove the
434
434
  no-concern default actually works at runtime, not just that no file was written.
435
435
 
436
+ `test/dummy` runs on PostgreSQL only (never SQLite). Create its test database once, then run
437
+ the suite:
438
+
436
439
  ```bash
437
440
  bundle install
441
+ (cd test/dummy && RAILS_ENV=test bin/rails db:create)
438
442
  bundle exec rake test
439
443
  ```
440
444
 
441
- If your shell has `DATABASE_URL` set to a PostgreSQL URL (e.g. inside the Thecore
442
- devcontainer), unset it first — it overrides `test/dummy`'s own SQLite3 test config:
443
-
444
- ```bash
445
- env -u DATABASE_URL bundle exec rake test
446
- ```
445
+ Connection settings come from `PGHOST`/`PGPORT`/`PGUSER`/`PGPASSWORD` (defaults
446
+ `db`/`5432`/`postgres`/`postgres`). If `DATABASE_URL` is set to a PostgreSQL URL (e.g. inside the
447
+ Thecore devcontainer), `test/dummy/config/boot.rb` keeps its server/credentials but always
448
+ swaps the database name to `thecore_generators_<RAILS_ENV>`, so tests never touch the host
449
+ app's database — no need to unset it.
447
450
 
448
451
  `bundle exec rake` alone runs the same suite (`test` is the default Rake task).
449
452
 
@@ -37,7 +37,7 @@ module Thecore
37
37
  atom_name = atom_name.to_s.strip
38
38
  return resolve_named_atom(app_root, atom_name) unless atom_name.empty?
39
39
 
40
- resolve_cwd_atom(cwd)
40
+ resolve_cwd_atom(cwd, app_root)
41
41
  end
42
42
 
43
43
  # Walks up from `dir` until the immediate parent directory is
@@ -137,9 +137,21 @@ module Thecore
137
137
  "(expected a #{atom_name}.gemspec or #{atom_name.tr('-', '_')}.gemspec inside it)."
138
138
  end
139
139
 
140
- def resolve_cwd_atom(cwd)
140
+ # A cwd-detected ATOM only counts when it belongs to the app being
141
+ # generated into: it must be `app_root` itself (e.g. an engine's own
142
+ # bin/rails, whose destination_root is already the ATOM) or live
143
+ # inside it. For a real `rails generate` the app root is always an
144
+ # ancestor of cwd, so this never changes the normal outcome — but
145
+ # when `app_root` itself sits *inside* some `vendor/submodules/<x>/`
146
+ # tree (an ATOM's own test/dummy app, or a gem checked out as a
147
+ # submodule of a host app and running its own generator tests with
148
+ # a tmp destination_root), walking up from cwd would otherwise find
149
+ # that enclosing <x> and redirect every file *out of* app_root into
150
+ # it. See thecore_generators' CLAUDE.md, WorkspaceContext.
151
+ def resolve_cwd_atom(cwd, app_root)
141
152
  candidate = atom_root_of(cwd)
142
153
  return nil unless candidate
154
+ return nil unless within_app_root?(candidate, app_root)
143
155
 
144
156
  unless valid_atom_dir?(candidate)
145
157
  raise Thor::Error,
@@ -149,6 +161,13 @@ module Thecore
149
161
 
150
162
  candidate
151
163
  end
164
+
165
+ def within_app_root?(candidate, app_root)
166
+ return true if app_root.to_s.empty?
167
+
168
+ root = File.expand_path(app_root.to_s)
169
+ candidate == root || candidate.start_with?("#{root}/")
170
+ end
152
171
  end
153
172
  end
154
173
  end
@@ -1,3 +1,3 @@
1
1
  module ThecoreGenerators
2
- VERSION = "3.13.0"
2
+ VERSION = "3.13.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thecore_generators
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.13.0
4
+ version: 3.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni