validation_hints 0.2.2 → 6.0.0

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: 9cf32471d0a80a02b0a5db3b89ba7564d5fa92e00e2e2bcb2e28f04a4b462d04
4
- data.tar.gz: 044bd3521b06d203e01dc40084cfa1d0cf9e09c52b33be24e1067f7b692cfa77
3
+ metadata.gz: 1f43f9338ea91967565859b93f7a0f884cf4d3999d83abda9d23ac55673a77ec
4
+ data.tar.gz: 399657680fb3f0a005aea6034c41a52c1f96b21c051e811b7dbe6f2c0d24fc0c
5
5
  SHA512:
6
- metadata.gz: daa31a4cb817fe4cef08124e970d2a5a02c8f6c8350441486f817354e011b3d7bc18690f089da18d31e9443db4ebb7b278433e8280de156f5b6a895514812f1f
7
- data.tar.gz: 0b2b921d259e537178a4675d787fda8632ae87ed90a7f356e82a47768892802d3ce0f6c99993d6856468e68e986cbd49975267044706ff2c4994dc7e669e93e9
6
+ metadata.gz: 0c3e3a58ea45b2620e516216d8d5267fefe2bff0c43c2de1956ab2bb3c15174418ed68f867c9d05bb56fa280107b8095afc9520b03f7dc93e231f445edad52cb
7
+ data.tar.gz: 602bbff26e2aea34e3117f9223063a8ba461608d8f51da3b9bb357418260dc8abe9e9455772bfbfbed4404e80133cfa2714c67ed3347bb031aed6527d5efc951
data/.gitignore CHANGED
@@ -15,4 +15,6 @@ capybara-*.html
15
15
  rerun.txt
16
16
  pickle-email-*.html
17
17
  /pkg
18
+ *.gem
18
19
  .rvmrc
20
+ /stuff/
data/CHANGELOG.md ADDED
@@ -0,0 +1,39 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here.
4
+
5
+ ## 6.0.0 (unreleased)
6
+
7
+ Modernize the gem for **Ruby 3.2+** and **Rails 7.0.x**, targeting use with **inline_forms 7.x**.
8
+
9
+ ### Breaking changes
10
+
11
+ - Requires **Ruby >= 3.2** and **Active Record 7.0.x** (`>= 7.0`, `< 7.1`).
12
+ - Version jump from **0.2.x** to **6.0.0** signals a full modernization.
13
+ - Public API used by inline_forms is preserved: `hints`, `full_messages_for`, `has_validations?`, `has_validations_for?`.
14
+
15
+ ### Added
16
+
17
+ - `ValidationHints::Railtie` — registers I18n and patches `ActiveModel::Validations` via `ActiveSupport.on_load(:active_model)` (Rails apps no longer need a manual `require`).
18
+ - `ValidationHints::ValidationsPatch` — extracted module for `has_validations*` and `hints`.
19
+ - `ValidationHints.load_i18n!` — idempotent locale registration.
20
+ - Runtime dependency on `activerecord` 7.0.x.
21
+ - Minitest harness (`test/`) and `rake test` as the default Rake task.
22
+ - `CHANGELOG.md`.
23
+
24
+ ### Changed
25
+
26
+ - `ValidationHints::VERSION` set to `6.0.0`.
27
+ - Gemspec rewritten for current RubyGems / Bundler (Ruby version, dependencies, file list with non-git fallback).
28
+ - `Gemfile` source updated to `https://rubygems.org`.
29
+ - Entry point (`lib/validation_hints.rb`) refactored: Railtie in Rails, direct `active_model` load outside Rails.
30
+ - I18n locale registration moved behind `ValidationHints.load_i18n!` (was unconditional append at load time).
31
+
32
+ ### Removed
33
+
34
+ - Obsolete development dependencies: jeweler, rcov, shoulda, rspec-rails, bundler ~> 1.0 pin.
35
+ - Inline `ActiveModel::Validations` patch from main entry file (moved to `validations_patch.rb`).
36
+
37
+ ## 0.2.3
38
+
39
+ - Legacy release (Rails 3.2 era).
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
- source "http://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
2
4
 
3
5
  gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,273 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ validation_hints (6.0.0)
5
+ activerecord (>= 7.0, < 7.1)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (7.0.10)
11
+ actionpack (= 7.0.10)
12
+ activesupport (= 7.0.10)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ actionmailbox (7.0.10)
16
+ actionpack (= 7.0.10)
17
+ activejob (= 7.0.10)
18
+ activerecord (= 7.0.10)
19
+ activestorage (= 7.0.10)
20
+ activesupport (= 7.0.10)
21
+ mail (>= 2.7.1)
22
+ net-imap
23
+ net-pop
24
+ net-smtp
25
+ actionmailer (7.0.10)
26
+ actionpack (= 7.0.10)
27
+ actionview (= 7.0.10)
28
+ activejob (= 7.0.10)
29
+ activesupport (= 7.0.10)
30
+ mail (~> 2.5, >= 2.5.4)
31
+ net-imap
32
+ net-pop
33
+ net-smtp
34
+ rails-dom-testing (~> 2.0)
35
+ actionpack (7.0.10)
36
+ actionview (= 7.0.10)
37
+ activesupport (= 7.0.10)
38
+ racc
39
+ rack (~> 2.0, >= 2.2.4)
40
+ rack-test (>= 0.6.3)
41
+ rails-dom-testing (~> 2.0)
42
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
43
+ actiontext (7.0.10)
44
+ actionpack (= 7.0.10)
45
+ activerecord (= 7.0.10)
46
+ activestorage (= 7.0.10)
47
+ activesupport (= 7.0.10)
48
+ globalid (>= 0.6.0)
49
+ nokogiri (>= 1.8.5)
50
+ actionview (7.0.10)
51
+ activesupport (= 7.0.10)
52
+ builder (~> 3.1)
53
+ erubi (~> 1.4)
54
+ rails-dom-testing (~> 2.0)
55
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
56
+ activejob (7.0.10)
57
+ activesupport (= 7.0.10)
58
+ globalid (>= 0.3.6)
59
+ activemodel (7.0.10)
60
+ activesupport (= 7.0.10)
61
+ activerecord (7.0.10)
62
+ activemodel (= 7.0.10)
63
+ activesupport (= 7.0.10)
64
+ activestorage (7.0.10)
65
+ actionpack (= 7.0.10)
66
+ activejob (= 7.0.10)
67
+ activerecord (= 7.0.10)
68
+ activesupport (= 7.0.10)
69
+ marcel (~> 1.0)
70
+ mini_mime (>= 1.1.0)
71
+ activesupport (7.0.10)
72
+ base64
73
+ benchmark (>= 0.3)
74
+ bigdecimal
75
+ concurrent-ruby (~> 1.0, >= 1.0.2)
76
+ drb
77
+ i18n (>= 1.6, < 2)
78
+ logger (>= 1.4.2)
79
+ minitest (>= 5.1)
80
+ mutex_m
81
+ securerandom (>= 0.3)
82
+ tzinfo (~> 2.0)
83
+ base64 (0.3.0)
84
+ benchmark (0.5.0)
85
+ bigdecimal (4.1.2)
86
+ builder (3.3.0)
87
+ concurrent-ruby (1.3.6)
88
+ crass (1.0.6)
89
+ date (3.5.1)
90
+ drb (2.2.3)
91
+ erubi (1.13.1)
92
+ globalid (1.3.0)
93
+ activesupport (>= 6.1)
94
+ i18n (1.14.8)
95
+ concurrent-ruby (~> 1.0)
96
+ logger (1.7.0)
97
+ loofah (2.25.1)
98
+ crass (~> 1.0.2)
99
+ nokogiri (>= 1.12.0)
100
+ mail (2.9.0)
101
+ logger
102
+ mini_mime (>= 0.1.1)
103
+ net-imap
104
+ net-pop
105
+ net-smtp
106
+ marcel (1.1.0)
107
+ method_source (1.1.0)
108
+ mini_mime (1.1.5)
109
+ minitest (5.27.0)
110
+ mutex_m (0.3.0)
111
+ net-imap (0.6.4)
112
+ date
113
+ net-protocol
114
+ net-pop (0.1.2)
115
+ net-protocol
116
+ net-protocol (0.2.2)
117
+ timeout
118
+ net-smtp (0.5.1)
119
+ net-protocol
120
+ nio4r (2.7.5)
121
+ nokogiri (1.19.3-aarch64-linux-gnu)
122
+ racc (~> 1.4)
123
+ nokogiri (1.19.3-aarch64-linux-musl)
124
+ racc (~> 1.4)
125
+ nokogiri (1.19.3-arm-linux-gnu)
126
+ racc (~> 1.4)
127
+ nokogiri (1.19.3-arm-linux-musl)
128
+ racc (~> 1.4)
129
+ nokogiri (1.19.3-arm64-darwin)
130
+ racc (~> 1.4)
131
+ nokogiri (1.19.3-x86_64-darwin)
132
+ racc (~> 1.4)
133
+ nokogiri (1.19.3-x86_64-linux-gnu)
134
+ racc (~> 1.4)
135
+ nokogiri (1.19.3-x86_64-linux-musl)
136
+ racc (~> 1.4)
137
+ racc (1.8.1)
138
+ rack (2.2.23)
139
+ rack-test (2.2.0)
140
+ rack (>= 1.3)
141
+ rails (7.0.10)
142
+ actioncable (= 7.0.10)
143
+ actionmailbox (= 7.0.10)
144
+ actionmailer (= 7.0.10)
145
+ actionpack (= 7.0.10)
146
+ actiontext (= 7.0.10)
147
+ actionview (= 7.0.10)
148
+ activejob (= 7.0.10)
149
+ activemodel (= 7.0.10)
150
+ activerecord (= 7.0.10)
151
+ activestorage (= 7.0.10)
152
+ activesupport (= 7.0.10)
153
+ bundler (>= 1.15.0)
154
+ railties (= 7.0.10)
155
+ rails-dom-testing (2.3.0)
156
+ activesupport (>= 5.0.0)
157
+ minitest
158
+ nokogiri (>= 1.6)
159
+ rails-html-sanitizer (1.7.0)
160
+ loofah (~> 2.25)
161
+ nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
162
+ railties (7.0.10)
163
+ actionpack (= 7.0.10)
164
+ activesupport (= 7.0.10)
165
+ method_source
166
+ rake (>= 12.2)
167
+ thor (~> 1.0)
168
+ zeitwerk (~> 2.5)
169
+ rake (13.4.2)
170
+ securerandom (0.4.1)
171
+ sqlite3 (1.7.3-aarch64-linux)
172
+ sqlite3 (1.7.3-arm-linux)
173
+ sqlite3 (1.7.3-arm64-darwin)
174
+ sqlite3 (1.7.3-x86_64-darwin)
175
+ sqlite3 (1.7.3-x86_64-linux)
176
+ thor (1.5.0)
177
+ timeout (0.6.1)
178
+ tzinfo (2.0.6)
179
+ concurrent-ruby (~> 1.0)
180
+ websocket-driver (0.8.0)
181
+ base64
182
+ websocket-extensions (>= 0.1.0)
183
+ websocket-extensions (0.1.5)
184
+ zeitwerk (2.7.5)
185
+
186
+ PLATFORMS
187
+ aarch64-linux
188
+ aarch64-linux-gnu
189
+ aarch64-linux-musl
190
+ arm-linux
191
+ arm-linux-gnu
192
+ arm-linux-musl
193
+ arm64-darwin
194
+ x86_64-darwin
195
+ x86_64-linux-gnu
196
+ x86_64-linux-musl
197
+
198
+ DEPENDENCIES
199
+ bundler (>= 2.0)
200
+ minitest (~> 5.0)
201
+ rails (>= 7.0, < 7.1)
202
+ sqlite3 (~> 1.4)
203
+ validation_hints!
204
+
205
+ CHECKSUMS
206
+ actioncable (7.0.10) sha256=7aa02ea26d6cc21c33e604bb28a0759c5212653311bc42105f96f709e507afab
207
+ actionmailbox (7.0.10) sha256=1236f472d86db056f97b3602391becab69c84d9f79d963b9c9b50056e213c1e6
208
+ actionmailer (7.0.10) sha256=53bc7aac1659ef97a216c43002ea8286931d7b97f252b27152ac15de1b2585ef
209
+ actionpack (7.0.10) sha256=4c524b3b401cc828efb3fcd6f3de56ac1ec0180843b74f54357f58b0256f9509
210
+ actiontext (7.0.10) sha256=ffadcbb9b21c09e9bfe946a79739d92abc92a9097eb1db7675e52484804c1c8c
211
+ actionview (7.0.10) sha256=e5a9475ccfcde80dddf7ced701f44aedc4f8262286051db84ae2c48322ec000e
212
+ activejob (7.0.10) sha256=f31b974206569a362e8c6c07aa00f3099fcc0f365880929c23e79c739d90fceb
213
+ activemodel (7.0.10) sha256=e2e1e0a4664b69606363e9f6f59afadeab6fa8843c5fb73cd037bb72a40fa498
214
+ activerecord (7.0.10) sha256=63bc193d4c6944d85f53255362b67269d246a51bd664e09b1aa2cecfe5288c9a
215
+ activestorage (7.0.10) sha256=41906d59536170abcb480d05b2368ee06305307edcafc5e4891ffb7b0970eaa2
216
+ activesupport (7.0.10) sha256=01487b0774045918b36893af4f012986db8375f6c5850c0ffc75b940ede72305
217
+ base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
218
+ benchmark (0.5.0) sha256=465df122341aedcb81a2a24b4d3bd19b6c67c1530713fd533f3ff034e419236c
219
+ bigdecimal (4.1.2) sha256=53d217666027eab4280346fba98e7d5b66baaae1b9c3c1c0ffe89d48188a3fbd
220
+ builder (3.3.0) sha256=497918d2f9dca528fdca4b88d84e4ef4387256d984b8154e9d5d3fe5a9c8835f
221
+ bundler (4.0.11) sha256=5bcec0fb78302e48d02ee46f10ee6e6942be647ba5b44a6d1ddfda9a240ce785
222
+ concurrent-ruby (1.3.6) sha256=6b56837e1e7e5292f9864f34b69c5a2cbc75c0cf5338f1ce9903d10fa762d5ab
223
+ crass (1.0.6) sha256=dc516022a56e7b3b156099abc81b6d2b08ea1ed12676ac7a5657617f012bd45d
224
+ date (3.5.1) sha256=750d06384d7b9c15d562c76291407d89e368dda4d4fff957eb94962d325a0dc0
225
+ drb (2.2.3) sha256=0b00d6fdb50995fe4a45dea13663493c841112e4068656854646f418fda13373
226
+ erubi (1.13.1) sha256=a082103b0885dbc5ecf1172fede897f9ebdb745a4b97a5e8dc63953db1ee4ad9
227
+ globalid (1.3.0) sha256=05c639ad6eb4594522a0b07983022f04aa7254626ab69445a0e493aa3786ff11
228
+ i18n (1.14.8) sha256=285778639134865c5e0f6269e0b818256017e8cde89993fdfcbfb64d088824a5
229
+ logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
230
+ loofah (2.25.1) sha256=d436c73dbd0c1147b16c4a41db097942d217303e1f7728704b37e4df9f6d2e04
231
+ mail (2.9.0) sha256=6fa6673ecd71c60c2d996260f9ee3dd387d4673b8169b502134659ece6d34941
232
+ marcel (1.1.0) sha256=fdcfcfa33cc52e93c4308d40e4090a5d4ea279e160a7f6af988260fa970e0bee
233
+ method_source (1.1.0) sha256=181301c9c45b731b4769bc81e8860e72f9161ad7d66dd99103c9ab84f560f5c5
234
+ mini_mime (1.1.5) sha256=8681b7e2e4215f2a159f9400b5816d85e9d8c6c6b491e96a12797e798f8bccef
235
+ minitest (5.27.0) sha256=2d3b17f8a36fe7801c1adcffdbc38233b938eb0b4966e97a6739055a45fa77d5
236
+ mutex_m (0.3.0) sha256=cfcb04ac16b69c4813777022fdceda24e9f798e48092a2b817eb4c0a782b0751
237
+ net-imap (0.6.4) sha256=9a5598c67a3022c284d98430ef1d4948e7dbdb62596f61081ea8ca933270a02b
238
+ net-pop (0.1.2) sha256=848b4e982013c15b2f0382792268763b748cce91c9e91e36b0f27ed26420dff3
239
+ net-protocol (0.2.2) sha256=aa73e0cba6a125369de9837b8d8ef82a61849360eba0521900e2c3713aa162a8
240
+ net-smtp (0.5.1) sha256=ed96a0af63c524fceb4b29b0d352195c30d82dd916a42f03c62a3a70e5b70736
241
+ nio4r (2.7.5) sha256=6c90168e48fb5f8e768419c93abb94ba2b892a1d0602cb06eef16d8b7df1dca1
242
+ nokogiri (1.19.3-aarch64-linux-gnu) sha256=46b89e5d7b9e844c2ee360794240c6ea2a4e6fa0c5892a4ed487db621224b639
243
+ nokogiri (1.19.3-aarch64-linux-musl) sha256=8392dfdcd21be7a94dbbe9ccc138dea01b97b24cb2dc02a114ca98bfb1d9a0b7
244
+ nokogiri (1.19.3-arm-linux-gnu) sha256=3919d5ffc334ad778a4a9eb88fda7dcb8b1fb58c8a52ac640c6dcd2f038e774f
245
+ nokogiri (1.19.3-arm-linux-musl) sha256=9ce1cb6346bb9c67b1550eb537aa183ead91e4b6eadb2f36ade02d8dd2a79fb6
246
+ nokogiri (1.19.3-arm64-darwin) sha256=71b9bd424b1b7abc18b05052a1a3cfd3627abdca62be280854cc411791357e42
247
+ nokogiri (1.19.3-x86_64-darwin) sha256=77f3fba57d46c53ab31e62fc6c28f705109d1bf6264356c76f132b2be5728d4d
248
+ nokogiri (1.19.3-x86_64-linux-gnu) sha256=2f5078620fe12e83669b5b17311b32532a8153d02eee7ad06948b926d6080976
249
+ nokogiri (1.19.3-x86_64-linux-musl) sha256=248c906d2166eca5efb56d52fdee5f9a1f51d69a72e2b64fdac647b4ce39ea3f
250
+ racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
251
+ rack (2.2.23) sha256=a8fe9d7e07064770b8ec123663fded8a59ef7e2b6db5cda7173d45a5718ab69c
252
+ rack-test (2.2.0) sha256=005a36692c306ac0b4a9350355ee080fd09ddef1148a5f8b2ac636c720f5c463
253
+ rails (7.0.10) sha256=866eb2c53d3184543fdb770d7ea308e4ee518063226a9e176229f3c7a9537c25
254
+ rails-dom-testing (2.3.0) sha256=8acc7953a7b911ca44588bf08737bc16719f431a1cc3091a292bca7317925c1d
255
+ rails-html-sanitizer (1.7.0) sha256=28b145cceaf9cc214a9874feaa183c3acba036c9592b19886e0e45efc62b1e89
256
+ railties (7.0.10) sha256=d52a8b7a61ad941121a15a6596b2150e05c70b199c3afc9e9b73e63b3b1a57a7
257
+ rake (13.4.2) sha256=cb825b2bd5f1f8e91ca37bddb4b9aaf345551b4731da62949be002fa89283701
258
+ securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1
259
+ sqlite3 (1.7.3-aarch64-linux) sha256=0ccb8c001cd2617f4801a2c816142d3c9bc299e3f3e0f49e03812f3610b0891c
260
+ sqlite3 (1.7.3-arm-linux) sha256=eb653026d44f8502b74564e585245485a5667d72f8888854e53c561f816541b0
261
+ sqlite3 (1.7.3-arm64-darwin) sha256=b956160cc882d2568f332f915c9fe27cae9a4521b202d6e7ea540171c88e4600
262
+ sqlite3 (1.7.3-x86_64-darwin) sha256=b88e117ae14b2c5b61a7eb14da24b3b0e93cd3e1c17774ff3b6e5a03ffe4e5b7
263
+ sqlite3 (1.7.3-x86_64-linux) sha256=522a3285660dec8253465880c97980e873db0d79060900be8d14194217a3ee73
264
+ thor (1.5.0) sha256=e3a9e55fe857e44859ce104a84675ab6e8cd59c650a49106a05f55f136425e73
265
+ timeout (0.6.1) sha256=78f57368a7e7bbadec56971f78a3f5ecbcfb59b7fcbb0a3ed6ddc08a5094accb
266
+ tzinfo (2.0.6) sha256=8daf828cc77bcf7d63b0e3bdb6caa47e2272dcfaf4fbfe46f8c3a9df087a829b
267
+ validation_hints (6.0.0)
268
+ websocket-driver (0.8.0) sha256=ed0dba4b943c22f17f9a734817e808bc84cdce6a7e22045f5315aa57676d4962
269
+ websocket-extensions (0.1.5) sha256=1c6ba63092cda343eb53fc657110c71c754c56484aad42578495227d717a8241
270
+ zeitwerk (2.7.5) sha256=d8da92128c09ea6ec62c949011b00ed4a20242b255293dd66bf41545398f73dd
271
+
272
+ BUNDLED WITH
273
+ 4.0.11
data/Rakefile CHANGED
@@ -1,2 +1,15 @@
1
- require 'bundler'
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/setup"
4
+ require "bundler/gem_helper"
5
+ require "rake/testtask"
6
+
2
7
  Bundler::GemHelper.install_tasks
8
+
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.libs << "test"
11
+ t.libs << "lib"
12
+ t.pattern = "test/**/*_test.rb"
13
+ end
14
+
15
+ task default: :test
@@ -306,16 +306,17 @@ module ActiveModel
306
306
 
307
307
  key = defaults.shift
308
308
 
309
- options = {
310
- :default => defaults,
311
- :model => @base.class.model_name.human,
312
- :attribute => @base.class.human_attribute_name(attribute),
313
- }.merge(options)
314
- I18n.translate(key,
315
- :default => defaults,
316
- :model => @base.class.model_name.human,
317
- :attribute => @base.class.human_attribute_name(attribute),
318
- )
309
+ # options = {
310
+ # :default => defaults,
311
+ # :model => @base.class.model_name.human,
312
+ # :attribute => @base.class.human_attribute_name(attribute),
313
+ # }.merge(options)
314
+ I18n.translate( key,
315
+ default: defaults,
316
+ model: @base.class.model_name.human,
317
+ attribute: @base.class.human_attribute_name(attribute),
318
+ count: options[:count],
319
+ )
319
320
  end
320
321
 
321
322
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ValidationHints
4
+ class Railtie < Rails::Railtie
5
+ initializer "validation_hints.i18n" do
6
+ ValidationHints.load_i18n!
7
+ end
8
+
9
+ ActiveSupport.on_load(:active_model) do
10
+ ValidationHints::ValidationsPatch.apply!
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ValidationHints
4
+ module ValidationsPatch
5
+ def self.apply!
6
+ return if applied?
7
+
8
+ ActiveModel::Validations::ClassMethods.module_eval do
9
+ def has_validations?
10
+ !validators.empty?
11
+ end
12
+
13
+ def has_validations_for?(attribute)
14
+ !validators_on(attribute).empty?
15
+ end
16
+ end
17
+
18
+ ActiveModel::Validations.module_eval do
19
+ def has_validations?
20
+ self.class.has_validations?
21
+ end
22
+
23
+ def has_validations_for?(attribute)
24
+ self.class.has_validations_for?(attribute)
25
+ end
26
+
27
+ def hints
28
+ @hints ||= ActiveModel::Hints.new(self)
29
+ end
30
+ end
31
+
32
+ @applied = true
33
+ end
34
+
35
+ def self.applied?
36
+ @applied
37
+ end
38
+ end
39
+ end
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module ValidationHints
3
- VERSION = "0.2.2"
3
+ VERSION = "6.0.0"
4
4
  end
@@ -1,39 +1,26 @@
1
- # -*- encoding : utf-8 -*-
1
+ # frozen_string_literal: true
2
2
 
3
- require 'validation_hints/version'
4
- require 'active_model/hints'
3
+ require "validation_hints/version"
4
+ require "active_model/hints"
5
5
 
6
- module ActiveModel
6
+ module ValidationHints
7
+ LOCALE_PATH = File.expand_path("validation_hints/locale/en.yml", __dir__)
7
8
 
8
- module Validations
9
-
10
- module ClassMethods
11
-
12
- def has_validations?
13
- ! self.validators.empty?
14
- end
15
-
16
- def has_validations_for?(attribute)
17
- ! self.validators_on(attribute).empty?
18
- end
19
-
20
- end
21
-
22
- def has_validations?
23
- self.class.has_validations?
24
- end
25
-
26
- def has_validations_for?(attribute)
27
- self.class.has_validations_for?(attribute)
28
- end
29
-
30
- def hints
31
- @hints ||= Hints.new(self)
32
- end
9
+ def self.load_i18n!
10
+ return if @i18n_loaded
33
11
 
12
+ require "i18n"
13
+ I18n.load_path << LOCALE_PATH unless I18n.load_path.include?(LOCALE_PATH)
14
+ @i18n_loaded = true
34
15
  end
35
-
36
16
  end
37
17
 
38
- require 'active_support/i18n'
39
- I18n.load_path << File.dirname(__FILE__) + '/validation_hints/locale/en.yml'
18
+ require "validation_hints/validations_patch"
19
+
20
+ if defined?(Rails::Railtie)
21
+ require "validation_hints/railtie"
22
+ else
23
+ require "active_model"
24
+ ValidationHints::ValidationsPatch.apply!
25
+ ValidationHints.load_i18n!
26
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/setup"
4
+ require "minitest/autorun"
5
+
6
+ require "validation_hints"
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class ValidationHintsTest < Minitest::Test
6
+ def test_version
7
+ assert_equal "6.0.0", ValidationHints::VERSION
8
+ end
9
+
10
+ def test_locale_path_exists
11
+ assert File.file?(ValidationHints::LOCALE_PATH),
12
+ "expected locale at #{ValidationHints::LOCALE_PATH}"
13
+ end
14
+ end
@@ -1,6 +1,6 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "validation_hints/version"
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/validation_hints/version"
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "validation_hints"
@@ -8,22 +8,30 @@ Gem::Specification.new do |s|
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Ace Suares"]
10
10
  s.email = ["ace@suares.com"]
11
- s.homepage = %q{http://github.com/acesuares/validation_hints}
12
- s.summary = %q{Validation Hints.}
13
- s.description = %q{Hints for validation.}
14
- s.licenses = ["MIT"]
11
+ s.homepage = "https://github.com/acesuares/validation_hints"
12
+ s.summary = "Proactive validation hints derived from model validators"
13
+ s.description = "Shows what a field expects before validation fails — complementary to ActiveModel errors."
14
+ s.license = "MIT"
15
+ s.required_ruby_version = ">= 3.2.0"
15
16
 
16
- s.rubyforge_project = "validation_hints"
17
+ if File.directory?(File.join(__dir__, ".git"))
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ else
21
+ s.files = Dir.chdir(__dir__) do
22
+ Dir.glob("{lib,test}/**/*", File::FNM_DOTMATCH).reject do |f|
23
+ f.end_with?(".gem") || f.start_with?("stuff/")
24
+ end + %w[README.md LICENSE.txt CHANGELOG.md Gemfile Rakefile validation_hints.gemspec]
25
+ end
26
+ s.test_files = Dir.glob("{test,spec}/**/*", base: __dir__)
27
+ end
17
28
 
18
- s.files = `git ls-files`.split("\n")
19
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
29
  s.require_paths = ["lib"]
22
30
 
23
- s.add_development_dependency(%q<rspec-rails>, [">= 0"])
24
- s.add_development_dependency(%q<shoulda>, [">= 0"])
25
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
26
- s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
27
- s.add_development_dependency(%q<rcov>, [">= 0"])
31
+ s.add_dependency "activerecord", ">= 7.0", "< 7.1"
28
32
 
33
+ s.add_development_dependency "rails", ">= 7.0", "< 7.1"
34
+ s.add_development_dependency "sqlite3", "~> 1.4"
35
+ s.add_development_dependency "minitest", "~> 5.0"
36
+ s.add_development_dependency "bundler", ">= 2.0"
29
37
  end
metadata CHANGED
@@ -1,86 +1,98 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validation_hints
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ace Suares
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-03-28 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
- name: rspec-rails
13
+ name: activerecord
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
16
  - - ">="
18
17
  - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
18
+ version: '7.0'
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: '7.1'
22
+ type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
23
25
  requirements:
24
26
  - - ">="
25
27
  - !ruby/object:Gem::Version
26
- version: '0'
28
+ version: '7.0'
29
+ - - "<"
30
+ - !ruby/object:Gem::Version
31
+ version: '7.1'
27
32
  - !ruby/object:Gem::Dependency
28
- name: shoulda
33
+ name: rails
29
34
  requirement: !ruby/object:Gem::Requirement
30
35
  requirements:
31
36
  - - ">="
32
37
  - !ruby/object:Gem::Version
33
- version: '0'
38
+ version: '7.0'
39
+ - - "<"
40
+ - !ruby/object:Gem::Version
41
+ version: '7.1'
34
42
  type: :development
35
43
  prerelease: false
36
44
  version_requirements: !ruby/object:Gem::Requirement
37
45
  requirements:
38
46
  - - ">="
39
47
  - !ruby/object:Gem::Version
40
- version: '0'
48
+ version: '7.0'
49
+ - - "<"
50
+ - !ruby/object:Gem::Version
51
+ version: '7.1'
41
52
  - !ruby/object:Gem::Dependency
42
- name: bundler
53
+ name: sqlite3
43
54
  requirement: !ruby/object:Gem::Requirement
44
55
  requirements:
45
56
  - - "~>"
46
57
  - !ruby/object:Gem::Version
47
- version: 1.0.0
58
+ version: '1.4'
48
59
  type: :development
49
60
  prerelease: false
50
61
  version_requirements: !ruby/object:Gem::Requirement
51
62
  requirements:
52
63
  - - "~>"
53
64
  - !ruby/object:Gem::Version
54
- version: 1.0.0
65
+ version: '1.4'
55
66
  - !ruby/object:Gem::Dependency
56
- name: jeweler
67
+ name: minitest
57
68
  requirement: !ruby/object:Gem::Requirement
58
69
  requirements:
59
70
  - - "~>"
60
71
  - !ruby/object:Gem::Version
61
- version: 1.5.2
72
+ version: '5.0'
62
73
  type: :development
63
74
  prerelease: false
64
75
  version_requirements: !ruby/object:Gem::Requirement
65
76
  requirements:
66
77
  - - "~>"
67
78
  - !ruby/object:Gem::Version
68
- version: 1.5.2
79
+ version: '5.0'
69
80
  - !ruby/object:Gem::Dependency
70
- name: rcov
81
+ name: bundler
71
82
  requirement: !ruby/object:Gem::Requirement
72
83
  requirements:
73
84
  - - ">="
74
85
  - !ruby/object:Gem::Version
75
- version: '0'
86
+ version: '2.0'
76
87
  type: :development
77
88
  prerelease: false
78
89
  version_requirements: !ruby/object:Gem::Requirement
79
90
  requirements:
80
91
  - - ">="
81
92
  - !ruby/object:Gem::Version
82
- version: '0'
83
- description: Hints for validation.
93
+ version: '2.0'
94
+ description: Shows what a field expects before validation fails — complementary to
95
+ ActiveModel errors.
84
96
  email:
85
97
  - ace@suares.com
86
98
  executables: []
@@ -89,20 +101,25 @@ extra_rdoc_files: []
89
101
  files:
90
102
  - ".document"
91
103
  - ".gitignore"
104
+ - CHANGELOG.md
92
105
  - Gemfile
106
+ - Gemfile.lock
93
107
  - LICENSE.txt
94
108
  - README.md
95
109
  - Rakefile
96
110
  - lib/active_model/hints.rb
97
111
  - lib/validation_hints.rb
98
112
  - lib/validation_hints/locale/en.yml
113
+ - lib/validation_hints/railtie.rb
114
+ - lib/validation_hints/validations_patch.rb
99
115
  - lib/validation_hints/version.rb
116
+ - test/test_helper.rb
117
+ - test/validation_hints_test.rb
100
118
  - validation_hints.gemspec
101
- homepage: http://github.com/acesuares/validation_hints
119
+ homepage: https://github.com/acesuares/validation_hints
102
120
  licenses:
103
121
  - MIT
104
122
  metadata: {}
105
- post_install_message:
106
123
  rdoc_options: []
107
124
  require_paths:
108
125
  - lib
@@ -110,15 +127,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
127
  requirements:
111
128
  - - ">="
112
129
  - !ruby/object:Gem::Version
113
- version: '0'
130
+ version: 3.2.0
114
131
  required_rubygems_version: !ruby/object:Gem::Requirement
115
132
  requirements:
116
133
  - - ">="
117
134
  - !ruby/object:Gem::Version
118
135
  version: '0'
119
136
  requirements: []
120
- rubygems_version: 3.2.3
121
- signing_key:
137
+ rubygems_version: 3.7.2
122
138
  specification_version: 4
123
- summary: Validation Hints.
139
+ summary: Proactive validation hints derived from model validators
124
140
  test_files: []