zod_rails 0.3.1 → 0.3.2

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: 2d23bb8daf103c59a7cb41cd7eff8a7e2346ab19171228283ab990214e7aa1a6
4
- data.tar.gz: 22b5712ffa475a57026411d6e9f2345e42a56999f3efc5f2e7ee8b63a3d39449
3
+ metadata.gz: 1163af9def212c75de8a25cc2e35fda2bbef62b372b239cd7bface8a3ae56098
4
+ data.tar.gz: 9d397ad7adcd549b35d059157b209a2214c2a558310ff9e860f663cad1849c47
5
5
  SHA512:
6
- metadata.gz: 18f8e43a66304819f9d0e14a50822c2c869a79da08c54772d2775f6393b590f55f156774f7404003ce2a169654138b83d4e136d4ce581be558100651136a03c6
7
- data.tar.gz: 9ecd30fe73d9a791e9642be2895308becd45752c9d1e84435e9a82be7a882c8a6bd80b307e0629d7d96c4c2ef873907da064478d03f908febb50aa4d32884309
6
+ metadata.gz: d1bd6a4631656247e5a0a15faf4b2928cbc1b3e9d982086b661757b3ec8eed4eecaa0fa421561165238ba997afa9fe3f8788b616d407169da281a1b6cb5821e4
7
+ data.tar.gz: 10edec80377e583661f8741bac4bff3647992fbc35d5dd16117564eb1d802e7f955b731259d861458d2a8137fb3ea60d8f2837f3fdc1faf1b4530e24fad1c92b
data/CHANGELOG.md CHANGED
@@ -4,6 +4,19 @@ All notable changes to ZodRails are documented here.
4
4
 
5
5
  ## Unreleased
6
6
 
7
+ ## 0.3.2 - 2026-08-03
8
+
9
+ ### Upgrade Notes
10
+
11
+ - Upgrade from `0.3.0` or `0.3.1` immediately. Those releases omitted the Railtie's Rake task file from the packaged
12
+ gem, causing `Rails.application.load_tasks` and unrelated Rails tasks such as `db:migrate` and `assets:precompile`
13
+ to fail with `LoadError`.
14
+
15
+ ### Fixed
16
+
17
+ - Include `lib/tasks/zod_rails.rake` in the published gem.
18
+ - Verify the runtime manifest and task loading in the test suite.
19
+
7
20
  ## 0.3.1 - 2026-08-03
8
21
 
9
22
  ### Upgrade Notes
data/README.md CHANGED
@@ -45,6 +45,9 @@ Add to your Gemfile:
45
45
  gem "zod_rails"
46
46
  ```
47
47
 
48
+ Use `0.3.2` or newer. Versions `0.3.0` and `0.3.1` omitted the Railtie's Rake task file from the published gem and can
49
+ break Rails task loading.
50
+
48
51
  Then run:
49
52
 
50
53
  ```bash
@@ -0,0 +1,110 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :zod_rails do
4
+ desc "Generate Zod schemas for configured models (DRY_RUN=1 to preview only)"
5
+ task generate: :environment do
6
+ config = ZodRails.configuration
7
+ generator = ZodRails::Generator.new(output_dir: config.output_dir)
8
+
9
+ if config.models.empty?
10
+ puts "No models configured. Add models to ZodRails.configure { |c| c.models = ['User', 'Article'] }"
11
+ exit 1
12
+ end
13
+
14
+ resolution = ZodRails::ModelResolver.resolve(config.models)
15
+
16
+ unless resolution[:missing].empty?
17
+ puts "ZodRails: #{resolution[:missing].size} model(s) in config.models could not be loaded:"
18
+ resolution[:missing].each { |m| puts " - #{m}" }
19
+ puts ""
20
+ puts "Check the model names in config/initializers/zod_rails.rb."
21
+ exit 1
22
+ end
23
+
24
+ unless resolution[:invalid].empty?
25
+ puts "ZodRails: configured constants must be concrete ActiveRecord models:"
26
+ resolution[:invalid].each { |model| puts " - #{model}" }
27
+ exit 1
28
+ end
29
+
30
+ models = resolution[:resolved]
31
+
32
+ if ENV["DRY_RUN"] == "1"
33
+ drift = generator.check(models)
34
+ if drift.empty?
35
+ puts "ZodRails (dry run): no changes."
36
+ else
37
+ puts "ZodRails (dry run): would update #{drift.size} file(s):"
38
+ drift.each { |d| puts " - #{d[:filename]} (#{d[:status]})" }
39
+ end
40
+ else
41
+ generated = generator.generate_all(models)
42
+ puts "Generated #{generated.size} schema file(s):"
43
+ generated.each { |f| puts " - #{f}" }
44
+ end
45
+ end
46
+
47
+ desc "Check whether generated schemas match the current models (exits nonzero on drift)"
48
+ task check: :environment do
49
+ config = ZodRails.configuration
50
+ generator = ZodRails::Generator.new(output_dir: config.output_dir)
51
+
52
+ if config.models.empty?
53
+ puts "No models configured. Nothing to check."
54
+ exit 0
55
+ end
56
+
57
+ resolution = ZodRails::ModelResolver.resolve(config.models)
58
+
59
+ unless resolution[:missing].empty?
60
+ puts "ZodRails: #{resolution[:missing].size} model(s) in config.models could not be loaded:"
61
+ resolution[:missing].each { |m| puts " - #{m}" }
62
+ exit 1
63
+ end
64
+
65
+ unless resolution[:invalid].empty?
66
+ puts "ZodRails: configured constants must be concrete ActiveRecord models:"
67
+ resolution[:invalid].each { |model| puts " - #{model}" }
68
+ exit 1
69
+ end
70
+
71
+ drift = generator.check(resolution[:resolved])
72
+
73
+ if drift.empty?
74
+ puts "ZodRails: generated schemas are up to date."
75
+ exit 0
76
+ end
77
+
78
+ puts "ZodRails: #{drift.size} file(s) out of date:"
79
+ drift.each { |d| puts " - #{d[:filename]} (#{d[:status]})" }
80
+ puts ""
81
+ puts "Run `bin/rails zod_rails:generate` to update."
82
+ exit 1
83
+ end
84
+
85
+ desc "Generate Zod schema for a specific model"
86
+ task :generate_model, [:model_name] => :environment do |_t, args|
87
+ model_name = args[:model_name]
88
+ unless model_name
89
+ puts "Usage: rails zod_rails:generate_model[ModelName]"
90
+ exit 1
91
+ end
92
+
93
+ config = ZodRails.configuration
94
+ generator = ZodRails::Generator.new(output_dir: config.output_dir)
95
+
96
+ resolution = ZodRails::ModelResolver.resolve([model_name])
97
+ if resolution[:missing].any?
98
+ puts "ZodRails: model '#{model_name}' could not be loaded. Check the spelling."
99
+ exit 1
100
+ end
101
+
102
+ if resolution[:invalid].any?
103
+ puts "ZodRails: '#{model_name}' is not a concrete ActiveRecord model."
104
+ exit 1
105
+ end
106
+
107
+ filename = generator.generate_all(resolution[:resolved]).first
108
+ puts "Generated: #{filename}"
109
+ end
110
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ZodRails
4
- VERSION = "0.3.1"
4
+ VERSION = "0.3.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zod_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Kelly
@@ -75,6 +75,7 @@ files:
75
75
  - CHANGELOG.md
76
76
  - LICENSE
77
77
  - README.md
78
+ - lib/tasks/zod_rails.rake
78
79
  - lib/zod_rails.rb
79
80
  - lib/zod_rails/configuration.rb
80
81
  - lib/zod_rails/generation/file_writer.rb