rails_dictionary 0.3.pre.rc1 → 0.4.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 +5 -5
- data/.github/workflows/ci.yml +33 -0
- data/.gitignore +5 -3
- data/CHANGELOG +19 -3
- data/Gemfile +10 -3
- data/Gemfile.lock +350 -0
- data/{README.v2.0.rdoc → README.rdoc} +33 -15
- data/Rakefile +10 -4
- data/docs/load-order.md +118 -0
- data/lib/rails_dictionary/active_record_extension.rb +48 -0
- data/lib/rails_dictionary/acts_as_dict_slave.rb +85 -0
- data/lib/rails_dictionary/acts_as_dict_type.rb +53 -0
- data/lib/rails_dictionary/acts_as_dictionary.rb +118 -0
- data/lib/rails_dictionary/array_core_ext.rb +10 -0
- data/lib/rails_dictionary/railtie.rb +11 -0
- data/lib/rails_dictionary/version.rb +1 -1
- data/lib/rails_dictionary.rb +64 -20
- data/lib/tasks/dicts.rake +9 -11
- data/pkg/rails_dictionary-0.2.2.gem +0 -0
- data/pkg/rails_dictionary-0.2.3.gem +0 -0
- data/rails_dictionary.gemspec +4 -4
- data/spec/fake_app.rb +29 -0
- data/spec/init_models.rb +12 -0
- data/spec/load_order/empty_boot_recovers.rb +19 -0
- data/spec/load_order/lazy_slave_model_boot.rb +25 -0
- data/spec/load_order/preseeded_boot.rb +22 -0
- data/spec/load_order/support.rb +41 -0
- data/spec/rails_dictionary_spec.rb +172 -0
- data/spec/spec_helper.rb +22 -0
- data/v1.0-roadmap.md +31 -0
- metadata +37 -38
- data/Readme.md +0 -10
- data/lib/rails_dictionary/models/active_record_extension.rb +0 -38
- data/lib/rails_dictionary/models/acts_as_dict_consumer.rb +0 -77
- data/lib/rails_dictionary/models/acts_as_dictionary.rb +0 -27
- data/test/acts_as_consumer_test.rb +0 -44
- data/test/fake_app.rb +0 -40
- data/test/lookup_test.rb +0 -39
- data/test/rails_dictionary_test.rb +0 -81
- data/test/test_helper.rb +0 -36
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 61e9822e64c345d45c61804294deb6facc17e9beb611ba7ad576ed3b334e2753
|
|
4
|
+
data.tar.gz: 21aa40faca5795ec2df7e16504a323720a8733c7243a782e715215987beff495
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b8ed37944127d618e815bb59c63844c64f4e7b708db1448880f3e834341777be7c7270a577291b9cd9d6287ce5d67b31233d5072009d335d4536e0ed04ef886d
|
|
7
|
+
data.tar.gz: 4736686322270efc4357845b4f48c4c9d101da935067a5e6947e02bd46ec264124f3250482848ac838ef1a10e125d8dba22036687b133793ee845b014578ed89
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ main ]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
fail-fast: false
|
|
13
|
+
matrix:
|
|
14
|
+
ruby: [ "3.3", "3.4" ]
|
|
15
|
+
rails: [ "7.1", "7.2", "8.0" ]
|
|
16
|
+
|
|
17
|
+
name: Ruby ${{ matrix.ruby }} / Rails ${{ matrix.rails }}
|
|
18
|
+
env:
|
|
19
|
+
RAILS_VERSION: ${{ matrix.rails }}
|
|
20
|
+
|
|
21
|
+
steps:
|
|
22
|
+
- uses: actions/checkout@v4
|
|
23
|
+
|
|
24
|
+
- name: Remove lockfile so the matrix can resolve its Rails version
|
|
25
|
+
run: rm -f Gemfile.lock
|
|
26
|
+
|
|
27
|
+
- uses: ruby/setup-ruby@v1
|
|
28
|
+
with:
|
|
29
|
+
ruby-version: ${{ matrix.ruby }}
|
|
30
|
+
bundler-cache: true
|
|
31
|
+
|
|
32
|
+
- name: Run tests
|
|
33
|
+
run: bundle exec rake
|
data/.gitignore
CHANGED
data/CHANGELOG
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
|
-
0.
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
0.4.0
|
|
2
|
+
Fix load/seed-order bug introduced in 0.3.0: lookup methods (Dictionary.address_city, ...) failed with NoMethodError when the dictionary model was loaded after its DictType rows were seeded (common in test/seed files under lazy autoloading). The model now generates its own lookups in its acts_as_dictionary `included` hook, so the order of DictType, Dictionary, and seeding no longer matters.
|
|
3
|
+
Guard the new include-time generation: skipped when DictType isn't defined yet (reverse load order) and when the dict_types table can't be queried (missing/unmigrated DB).
|
|
4
|
+
Extract RailsDictionary.dict_table_ready? as the shared boot/load guard.
|
|
5
|
+
Add docs/load-order.md documenting every load/seed-order scenario, and spec/load_order/lazy_slave_model_boot.rb covering the regression.
|
|
4
6
|
|
|
7
|
+
0.3.0
|
|
8
|
+
Replace the inner Dictionary.method_missing with generated per-type methods (define_singleton_method), regenerated at boot (Railtie) and on DictType writes.
|
|
9
|
+
Fix load-order bug: DictType.all_types no longer freezes as [] when first called on an empty table (use .presence). The config/initializers DictType.table_exists? workaround is no longer needed.
|
|
10
|
+
Fix stale-id bug under forked, multi-DB parallel tests: the Dictionary lookup cache key is now scoped per database, preventing cross-DB foreign-key violations.
|
|
11
|
+
Require Rails >= 7.1 and Ruby >= 3.3.
|
|
12
|
+
Add GitHub Actions CI matrix (Ruby 3.3/3.4 x Rails 7.1/7.2/8.0).
|
|
13
|
+
Add Dictionary.categories to list all categories.
|
|
14
|
+
Add query: option (Dictionary.city(query: true)) to bypass the cache and hit the DB.
|
|
15
|
+
Add CRUD helpers Dictionary.add(category, name) and Dictionary.remove(category, name).
|
|
16
|
+
Add Dictionary.options_for(category, locale:) returning options_for_select-ready pairs.
|
|
17
|
+
Deprecate the :locale option on Dictionary.<category> and the Array#extract_to_hash monkey-patch (removed in v1.0).
|
|
18
|
+
|
|
19
|
+
0.2.4
|
|
20
|
+
Support Rails7
|
|
5
21
|
0.2
|
|
6
22
|
Add Support For Rails4
|
|
7
23
|
|
data/Gemfile
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
source "
|
|
1
|
+
source "https://rubygems.org"
|
|
2
|
+
|
|
3
|
+
ruby '> 3.3'
|
|
2
4
|
|
|
3
5
|
# Specify your gem's dependencies in rails_dictionary.gemspec
|
|
4
6
|
gemspec
|
|
5
7
|
|
|
6
8
|
group :development,:test do
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
rails_version = ENV.fetch('RAILS_VERSION', nil)
|
|
10
|
+
if rails_version
|
|
11
|
+
gem 'rails', "~> #{rails_version}.0"
|
|
12
|
+
else
|
|
13
|
+
gem 'rails', '< 9.0'
|
|
14
|
+
end
|
|
15
|
+
gem "rspec-rails", '< 9'
|
|
9
16
|
gem 'sqlite3'
|
|
10
17
|
end
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
rails_dictionary (0.4.0)
|
|
5
|
+
rails (>= 7.1, < 9)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
action_text-trix (2.1.19)
|
|
11
|
+
railties
|
|
12
|
+
actioncable (8.1.3)
|
|
13
|
+
actionpack (= 8.1.3)
|
|
14
|
+
activesupport (= 8.1.3)
|
|
15
|
+
nio4r (~> 2.0)
|
|
16
|
+
websocket-driver (>= 0.6.1)
|
|
17
|
+
zeitwerk (~> 2.6)
|
|
18
|
+
actionmailbox (8.1.3)
|
|
19
|
+
actionpack (= 8.1.3)
|
|
20
|
+
activejob (= 8.1.3)
|
|
21
|
+
activerecord (= 8.1.3)
|
|
22
|
+
activestorage (= 8.1.3)
|
|
23
|
+
activesupport (= 8.1.3)
|
|
24
|
+
mail (>= 2.8.0)
|
|
25
|
+
actionmailer (8.1.3)
|
|
26
|
+
actionpack (= 8.1.3)
|
|
27
|
+
actionview (= 8.1.3)
|
|
28
|
+
activejob (= 8.1.3)
|
|
29
|
+
activesupport (= 8.1.3)
|
|
30
|
+
mail (>= 2.8.0)
|
|
31
|
+
rails-dom-testing (~> 2.2)
|
|
32
|
+
actionpack (8.1.3)
|
|
33
|
+
actionview (= 8.1.3)
|
|
34
|
+
activesupport (= 8.1.3)
|
|
35
|
+
nokogiri (>= 1.8.5)
|
|
36
|
+
rack (>= 2.2.4)
|
|
37
|
+
rack-session (>= 1.0.1)
|
|
38
|
+
rack-test (>= 0.6.3)
|
|
39
|
+
rails-dom-testing (~> 2.2)
|
|
40
|
+
rails-html-sanitizer (~> 1.6)
|
|
41
|
+
useragent (~> 0.16)
|
|
42
|
+
actiontext (8.1.3)
|
|
43
|
+
action_text-trix (~> 2.1.15)
|
|
44
|
+
actionpack (= 8.1.3)
|
|
45
|
+
activerecord (= 8.1.3)
|
|
46
|
+
activestorage (= 8.1.3)
|
|
47
|
+
activesupport (= 8.1.3)
|
|
48
|
+
globalid (>= 0.6.0)
|
|
49
|
+
nokogiri (>= 1.8.5)
|
|
50
|
+
actionview (8.1.3)
|
|
51
|
+
activesupport (= 8.1.3)
|
|
52
|
+
builder (~> 3.1)
|
|
53
|
+
erubi (~> 1.11)
|
|
54
|
+
rails-dom-testing (~> 2.2)
|
|
55
|
+
rails-html-sanitizer (~> 1.6)
|
|
56
|
+
activejob (8.1.3)
|
|
57
|
+
activesupport (= 8.1.3)
|
|
58
|
+
globalid (>= 0.3.6)
|
|
59
|
+
activemodel (8.1.3)
|
|
60
|
+
activesupport (= 8.1.3)
|
|
61
|
+
activerecord (8.1.3)
|
|
62
|
+
activemodel (= 8.1.3)
|
|
63
|
+
activesupport (= 8.1.3)
|
|
64
|
+
timeout (>= 0.4.0)
|
|
65
|
+
activestorage (8.1.3)
|
|
66
|
+
actionpack (= 8.1.3)
|
|
67
|
+
activejob (= 8.1.3)
|
|
68
|
+
activerecord (= 8.1.3)
|
|
69
|
+
activesupport (= 8.1.3)
|
|
70
|
+
marcel (~> 1.0)
|
|
71
|
+
activesupport (8.1.3)
|
|
72
|
+
base64
|
|
73
|
+
bigdecimal
|
|
74
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
75
|
+
connection_pool (>= 2.2.5)
|
|
76
|
+
drb
|
|
77
|
+
i18n (>= 1.6, < 2)
|
|
78
|
+
json
|
|
79
|
+
logger (>= 1.4.2)
|
|
80
|
+
minitest (>= 5.1)
|
|
81
|
+
securerandom (>= 0.3)
|
|
82
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
|
83
|
+
uri (>= 0.13.1)
|
|
84
|
+
base64 (0.3.0)
|
|
85
|
+
bigdecimal (4.1.2)
|
|
86
|
+
builder (3.3.0)
|
|
87
|
+
concurrent-ruby (1.3.6)
|
|
88
|
+
connection_pool (3.0.2)
|
|
89
|
+
crass (1.0.6)
|
|
90
|
+
date (3.5.1)
|
|
91
|
+
diff-lcs (1.6.2)
|
|
92
|
+
drb (2.2.3)
|
|
93
|
+
erb (6.0.4)
|
|
94
|
+
erubi (1.13.1)
|
|
95
|
+
globalid (1.3.0)
|
|
96
|
+
activesupport (>= 6.1)
|
|
97
|
+
i18n (1.14.8)
|
|
98
|
+
concurrent-ruby (~> 1.0)
|
|
99
|
+
io-console (0.8.2)
|
|
100
|
+
irb (1.18.0)
|
|
101
|
+
pp (>= 0.6.0)
|
|
102
|
+
prism (>= 1.3.0)
|
|
103
|
+
rdoc (>= 4.0.0)
|
|
104
|
+
reline (>= 0.4.2)
|
|
105
|
+
json (2.19.9)
|
|
106
|
+
logger (1.7.0)
|
|
107
|
+
loofah (2.25.1)
|
|
108
|
+
crass (~> 1.0.2)
|
|
109
|
+
nokogiri (>= 1.12.0)
|
|
110
|
+
mail (2.9.0)
|
|
111
|
+
logger
|
|
112
|
+
mini_mime (>= 0.1.1)
|
|
113
|
+
net-imap
|
|
114
|
+
net-pop
|
|
115
|
+
net-smtp
|
|
116
|
+
marcel (1.2.1)
|
|
117
|
+
mini_mime (1.1.5)
|
|
118
|
+
minitest (6.0.6)
|
|
119
|
+
drb (~> 2.0)
|
|
120
|
+
prism (~> 1.5)
|
|
121
|
+
net-imap (0.6.4.1)
|
|
122
|
+
date
|
|
123
|
+
net-protocol
|
|
124
|
+
net-pop (0.1.2)
|
|
125
|
+
net-protocol
|
|
126
|
+
net-protocol (0.2.2)
|
|
127
|
+
timeout
|
|
128
|
+
net-smtp (0.5.1)
|
|
129
|
+
net-protocol
|
|
130
|
+
nio4r (2.7.5)
|
|
131
|
+
nokogiri (1.19.3-aarch64-linux-gnu)
|
|
132
|
+
racc (~> 1.4)
|
|
133
|
+
nokogiri (1.19.3-aarch64-linux-musl)
|
|
134
|
+
racc (~> 1.4)
|
|
135
|
+
nokogiri (1.19.3-arm-linux-gnu)
|
|
136
|
+
racc (~> 1.4)
|
|
137
|
+
nokogiri (1.19.3-arm-linux-musl)
|
|
138
|
+
racc (~> 1.4)
|
|
139
|
+
nokogiri (1.19.3-arm64-darwin)
|
|
140
|
+
racc (~> 1.4)
|
|
141
|
+
nokogiri (1.19.3-x86_64-darwin)
|
|
142
|
+
racc (~> 1.4)
|
|
143
|
+
nokogiri (1.19.3-x86_64-linux-gnu)
|
|
144
|
+
racc (~> 1.4)
|
|
145
|
+
nokogiri (1.19.3-x86_64-linux-musl)
|
|
146
|
+
racc (~> 1.4)
|
|
147
|
+
pp (0.6.3)
|
|
148
|
+
prettyprint
|
|
149
|
+
prettyprint (0.2.0)
|
|
150
|
+
prism (1.9.0)
|
|
151
|
+
psych (5.4.0)
|
|
152
|
+
date
|
|
153
|
+
stringio
|
|
154
|
+
racc (1.8.1)
|
|
155
|
+
rack (3.2.6)
|
|
156
|
+
rack-session (2.1.2)
|
|
157
|
+
base64 (>= 0.1.0)
|
|
158
|
+
rack (>= 3.0.0)
|
|
159
|
+
rack-test (2.2.0)
|
|
160
|
+
rack (>= 1.3)
|
|
161
|
+
rackup (2.3.1)
|
|
162
|
+
rack (>= 3)
|
|
163
|
+
rails (8.1.3)
|
|
164
|
+
actioncable (= 8.1.3)
|
|
165
|
+
actionmailbox (= 8.1.3)
|
|
166
|
+
actionmailer (= 8.1.3)
|
|
167
|
+
actionpack (= 8.1.3)
|
|
168
|
+
actiontext (= 8.1.3)
|
|
169
|
+
actionview (= 8.1.3)
|
|
170
|
+
activejob (= 8.1.3)
|
|
171
|
+
activemodel (= 8.1.3)
|
|
172
|
+
activerecord (= 8.1.3)
|
|
173
|
+
activestorage (= 8.1.3)
|
|
174
|
+
activesupport (= 8.1.3)
|
|
175
|
+
bundler (>= 1.15.0)
|
|
176
|
+
railties (= 8.1.3)
|
|
177
|
+
rails-dom-testing (2.3.0)
|
|
178
|
+
activesupport (>= 5.0.0)
|
|
179
|
+
minitest
|
|
180
|
+
nokogiri (>= 1.6)
|
|
181
|
+
rails-html-sanitizer (1.7.0)
|
|
182
|
+
loofah (~> 2.25)
|
|
183
|
+
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)
|
|
184
|
+
railties (8.1.3)
|
|
185
|
+
actionpack (= 8.1.3)
|
|
186
|
+
activesupport (= 8.1.3)
|
|
187
|
+
irb (~> 1.13)
|
|
188
|
+
rackup (>= 1.0.0)
|
|
189
|
+
rake (>= 12.2)
|
|
190
|
+
thor (~> 1.0, >= 1.2.2)
|
|
191
|
+
tsort (>= 0.2)
|
|
192
|
+
zeitwerk (~> 2.6)
|
|
193
|
+
rake (13.4.2)
|
|
194
|
+
rdoc (7.2.0)
|
|
195
|
+
erb
|
|
196
|
+
psych (>= 4.0.0)
|
|
197
|
+
tsort
|
|
198
|
+
reline (0.6.3)
|
|
199
|
+
io-console (~> 0.5)
|
|
200
|
+
rspec-core (3.13.6)
|
|
201
|
+
rspec-support (~> 3.13.0)
|
|
202
|
+
rspec-expectations (3.13.5)
|
|
203
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
204
|
+
rspec-support (~> 3.13.0)
|
|
205
|
+
rspec-mocks (3.13.8)
|
|
206
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
207
|
+
rspec-support (~> 3.13.0)
|
|
208
|
+
rspec-rails (8.0.4)
|
|
209
|
+
actionpack (>= 7.2)
|
|
210
|
+
activesupport (>= 7.2)
|
|
211
|
+
railties (>= 7.2)
|
|
212
|
+
rspec-core (>= 3.13.0, < 5.0.0)
|
|
213
|
+
rspec-expectations (>= 3.13.0, < 5.0.0)
|
|
214
|
+
rspec-mocks (>= 3.13.0, < 5.0.0)
|
|
215
|
+
rspec-support (>= 3.13.0, < 5.0.0)
|
|
216
|
+
rspec-support (3.13.7)
|
|
217
|
+
securerandom (0.4.1)
|
|
218
|
+
sqlite3 (2.9.5-aarch64-linux-gnu)
|
|
219
|
+
sqlite3 (2.9.5-aarch64-linux-musl)
|
|
220
|
+
sqlite3 (2.9.5-arm-linux-gnu)
|
|
221
|
+
sqlite3 (2.9.5-arm-linux-musl)
|
|
222
|
+
sqlite3 (2.9.5-arm64-darwin)
|
|
223
|
+
sqlite3 (2.9.5-x86_64-darwin)
|
|
224
|
+
sqlite3 (2.9.5-x86_64-linux-gnu)
|
|
225
|
+
sqlite3 (2.9.5-x86_64-linux-musl)
|
|
226
|
+
stringio (3.2.0)
|
|
227
|
+
thor (1.5.0)
|
|
228
|
+
timeout (0.6.1)
|
|
229
|
+
tsort (0.2.0)
|
|
230
|
+
tzinfo (2.0.6)
|
|
231
|
+
concurrent-ruby (~> 1.0)
|
|
232
|
+
uri (1.1.1)
|
|
233
|
+
useragent (0.16.11)
|
|
234
|
+
websocket-driver (0.8.1)
|
|
235
|
+
base64
|
|
236
|
+
websocket-extensions (>= 0.1.0)
|
|
237
|
+
websocket-extensions (0.1.5)
|
|
238
|
+
zeitwerk (2.8.2)
|
|
239
|
+
|
|
240
|
+
PLATFORMS
|
|
241
|
+
aarch64-linux-gnu
|
|
242
|
+
aarch64-linux-musl
|
|
243
|
+
arm-linux-gnu
|
|
244
|
+
arm-linux-musl
|
|
245
|
+
arm64-darwin
|
|
246
|
+
x86_64-darwin
|
|
247
|
+
x86_64-linux-gnu
|
|
248
|
+
x86_64-linux-musl
|
|
249
|
+
|
|
250
|
+
DEPENDENCIES
|
|
251
|
+
rails (< 9.0)
|
|
252
|
+
rails_dictionary!
|
|
253
|
+
rspec-rails (< 9)
|
|
254
|
+
sqlite3
|
|
255
|
+
|
|
256
|
+
CHECKSUMS
|
|
257
|
+
action_text-trix (2.1.19) sha256=7012f59421009cf284aa651294896414d653a61a2417c9b8714c8476d2f74009
|
|
258
|
+
actioncable (8.1.3) sha256=e5bc7f75e44e6a22de29c4f43176927c3a9ce4824464b74ed18d8226e75a80f0
|
|
259
|
+
actionmailbox (8.1.3) sha256=df7da474eaa0e70df4ed5a6fef66eb3b3b0f2dbf7f14518deee8d77f1b4aae59
|
|
260
|
+
actionmailer (8.1.3) sha256=831f724891bb70d0aaa4d76581a6321124b6a752cb655c9346aae5479318448d
|
|
261
|
+
actionpack (8.1.3) sha256=af998cae4d47c5d581a2cc363b5c77eb718b7c4b45748d81b1887b25621c29a3
|
|
262
|
+
actiontext (8.1.3) sha256=d291019c00e1ea9e6463011fa214f6081a56d7b9a1d224e7d3f6384c1dafc7d2
|
|
263
|
+
actionview (8.1.3) sha256=1347c88c7f3edb38100c5ce0e9fb5e62d7755f3edc1b61cce2eb0b2c6ea2fd5d
|
|
264
|
+
activejob (8.1.3) sha256=a149b1766aa8204c3c3da7309e4becd40fcd5529c348cffbf6c9b16b565fe8d3
|
|
265
|
+
activemodel (8.1.3) sha256=90c05cbe4cef3649b8f79f13016191ea94c4525ce4a5c0fb7ef909c4b91c8219
|
|
266
|
+
activerecord (8.1.3) sha256=8003be7b2466ba0a2a670e603eeb0a61dd66058fccecfc49901e775260ac70ab
|
|
267
|
+
activestorage (8.1.3) sha256=0564ce9309143951a67615e1bb4e090ee54b8befed417133cae614479b46384d
|
|
268
|
+
activesupport (8.1.3) sha256=21a5e0dfbd4c3ddd9e1317ec6a4d782fa226e7867dc70b0743acda81a1dca20e
|
|
269
|
+
base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
|
|
270
|
+
bigdecimal (4.1.2) sha256=53d217666027eab4280346fba98e7d5b66baaae1b9c3c1c0ffe89d48188a3fbd
|
|
271
|
+
builder (3.3.0) sha256=497918d2f9dca528fdca4b88d84e4ef4387256d984b8154e9d5d3fe5a9c8835f
|
|
272
|
+
concurrent-ruby (1.3.6) sha256=6b56837e1e7e5292f9864f34b69c5a2cbc75c0cf5338f1ce9903d10fa762d5ab
|
|
273
|
+
connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a
|
|
274
|
+
crass (1.0.6) sha256=dc516022a56e7b3b156099abc81b6d2b08ea1ed12676ac7a5657617f012bd45d
|
|
275
|
+
date (3.5.1) sha256=750d06384d7b9c15d562c76291407d89e368dda4d4fff957eb94962d325a0dc0
|
|
276
|
+
diff-lcs (1.6.2) sha256=9ae0d2cba7d4df3075fe8cd8602a8604993efc0dfa934cff568969efb1909962
|
|
277
|
+
drb (2.2.3) sha256=0b00d6fdb50995fe4a45dea13663493c841112e4068656854646f418fda13373
|
|
278
|
+
erb (6.0.4) sha256=38e3803694be357fe2bfe312487c74beaf9fb4e5beb3e22498952fe1645b95d9
|
|
279
|
+
erubi (1.13.1) sha256=a082103b0885dbc5ecf1172fede897f9ebdb745a4b97a5e8dc63953db1ee4ad9
|
|
280
|
+
globalid (1.3.0) sha256=05c639ad6eb4594522a0b07983022f04aa7254626ab69445a0e493aa3786ff11
|
|
281
|
+
i18n (1.14.8) sha256=285778639134865c5e0f6269e0b818256017e8cde89993fdfcbfb64d088824a5
|
|
282
|
+
io-console (0.8.2) sha256=d6e3ae7a7cc7574f4b8893b4fca2162e57a825b223a177b7afa236c5ef9814cc
|
|
283
|
+
irb (1.18.0) sha256=de9454a0703a54704b9811a5ef31a60c86949fbf4013fcf244fabc7c775248e3
|
|
284
|
+
json (2.19.9) sha256=9b9025b7cdddafa38d316eca0b2358488e42d417045c1b90d216a9fefe46b79a
|
|
285
|
+
logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
|
|
286
|
+
loofah (2.25.1) sha256=d436c73dbd0c1147b16c4a41db097942d217303e1f7728704b37e4df9f6d2e04
|
|
287
|
+
mail (2.9.0) sha256=6fa6673ecd71c60c2d996260f9ee3dd387d4673b8169b502134659ece6d34941
|
|
288
|
+
marcel (1.2.1) sha256=1678e9360e32f9eafa917c80029e2f6d10b2715c66a4b87b6d0da9b9cd1f859f
|
|
289
|
+
mini_mime (1.1.5) sha256=8681b7e2e4215f2a159f9400b5816d85e9d8c6c6b491e96a12797e798f8bccef
|
|
290
|
+
minitest (6.0.6) sha256=153ea36d1d987a62942382b61075745042a2b3123b1cd48f4c3675af9cc7d6f1
|
|
291
|
+
net-imap (0.6.4.1) sha256=29f0360d75a7efd3539f16ac1957dea5c0a51ddeceb348db4553c3120914ea0d
|
|
292
|
+
net-pop (0.1.2) sha256=848b4e982013c15b2f0382792268763b748cce91c9e91e36b0f27ed26420dff3
|
|
293
|
+
net-protocol (0.2.2) sha256=aa73e0cba6a125369de9837b8d8ef82a61849360eba0521900e2c3713aa162a8
|
|
294
|
+
net-smtp (0.5.1) sha256=ed96a0af63c524fceb4b29b0d352195c30d82dd916a42f03c62a3a70e5b70736
|
|
295
|
+
nio4r (2.7.5) sha256=6c90168e48fb5f8e768419c93abb94ba2b892a1d0602cb06eef16d8b7df1dca1
|
|
296
|
+
nokogiri (1.19.3-aarch64-linux-gnu) sha256=46b89e5d7b9e844c2ee360794240c6ea2a4e6fa0c5892a4ed487db621224b639
|
|
297
|
+
nokogiri (1.19.3-aarch64-linux-musl) sha256=8392dfdcd21be7a94dbbe9ccc138dea01b97b24cb2dc02a114ca98bfb1d9a0b7
|
|
298
|
+
nokogiri (1.19.3-arm-linux-gnu) sha256=3919d5ffc334ad778a4a9eb88fda7dcb8b1fb58c8a52ac640c6dcd2f038e774f
|
|
299
|
+
nokogiri (1.19.3-arm-linux-musl) sha256=9ce1cb6346bb9c67b1550eb537aa183ead91e4b6eadb2f36ade02d8dd2a79fb6
|
|
300
|
+
nokogiri (1.19.3-arm64-darwin) sha256=71b9bd424b1b7abc18b05052a1a3cfd3627abdca62be280854cc411791357e42
|
|
301
|
+
nokogiri (1.19.3-x86_64-darwin) sha256=77f3fba57d46c53ab31e62fc6c28f705109d1bf6264356c76f132b2be5728d4d
|
|
302
|
+
nokogiri (1.19.3-x86_64-linux-gnu) sha256=2f5078620fe12e83669b5b17311b32532a8153d02eee7ad06948b926d6080976
|
|
303
|
+
nokogiri (1.19.3-x86_64-linux-musl) sha256=248c906d2166eca5efb56d52fdee5f9a1f51d69a72e2b64fdac647b4ce39ea3f
|
|
304
|
+
pp (0.6.3) sha256=2951d514450b93ccfeb1df7d021cae0da16e0a7f95ee1e2273719669d0ab9df6
|
|
305
|
+
prettyprint (0.2.0) sha256=2bc9e15581a94742064a3cc8b0fb9d45aae3d03a1baa6ef80922627a0766f193
|
|
306
|
+
prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85
|
|
307
|
+
psych (5.4.0) sha256=14f72d69a611af663d7d70e4a7b67d9eb1f3ae9f8d916b478961d5a0075ba5b7
|
|
308
|
+
racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
|
|
309
|
+
rack (3.2.6) sha256=5ed78e1f73b2e25679bec7d45ee2d4483cc4146eb1be0264fc4d94cb5ef212c2
|
|
310
|
+
rack-session (2.1.2) sha256=595434f8c0c3473ae7d7ac56ecda6cc6dfd9d37c0b2b5255330aa1576967ffe8
|
|
311
|
+
rack-test (2.2.0) sha256=005a36692c306ac0b4a9350355ee080fd09ddef1148a5f8b2ac636c720f5c463
|
|
312
|
+
rackup (2.3.1) sha256=6c79c26753778e90983761d677a48937ee3192b3ffef6bc963c0950f94688868
|
|
313
|
+
rails (8.1.3) sha256=6d017ba5348c98fc909753a8169b21d44de14d2a0b92d140d1a966834c3c9cd3
|
|
314
|
+
rails-dom-testing (2.3.0) sha256=8acc7953a7b911ca44588bf08737bc16719f431a1cc3091a292bca7317925c1d
|
|
315
|
+
rails-html-sanitizer (1.7.0) sha256=28b145cceaf9cc214a9874feaa183c3acba036c9592b19886e0e45efc62b1e89
|
|
316
|
+
rails_dictionary (0.4.0)
|
|
317
|
+
railties (8.1.3) sha256=913eb0e0cb520aac687ffd74916bd726d48fa21f47833c6292576ef6a286de22
|
|
318
|
+
rake (13.4.2) sha256=cb825b2bd5f1f8e91ca37bddb4b9aaf345551b4731da62949be002fa89283701
|
|
319
|
+
rdoc (7.2.0) sha256=8650f76cd4009c3b54955eb5d7e3a075c60a57276766ebf36f9085e8c9f23192
|
|
320
|
+
reline (0.6.3) sha256=1198b04973565b36ec0f11542ab3f5cfeeec34823f4e54cebde90968092b1835
|
|
321
|
+
rspec-core (3.13.6) sha256=a8823c6411667b60a8bca135364351dda34cd55e44ff94c4be4633b37d828b2d
|
|
322
|
+
rspec-expectations (3.13.5) sha256=33a4d3a1d95060aea4c94e9f237030a8f9eae5615e9bd85718fe3a09e4b58836
|
|
323
|
+
rspec-mocks (3.13.8) sha256=086ad3d3d17533f4237643de0b5c42f04b66348c28bf6b9c2d3f4a3b01af1d47
|
|
324
|
+
rspec-rails (8.0.4) sha256=06235692fc0892683d3d34977e081db867434b3a24ae0dd0c6f3516bad4e22df
|
|
325
|
+
rspec-support (3.13.7) sha256=0640e5570872aafefd79867901deeeeb40b0c9875a36b983d85f54fb7381c47c
|
|
326
|
+
securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1
|
|
327
|
+
sqlite3 (2.9.5-aarch64-linux-gnu) sha256=78075b6337d3d182c6d2b4691049ed45cd220826160c9ea18946bf6a1de200dc
|
|
328
|
+
sqlite3 (2.9.5-aarch64-linux-musl) sha256=18c801185deb4adc01ddb281e8f672a39e3d1729979ca91e39439cd3eac0402d
|
|
329
|
+
sqlite3 (2.9.5-arm-linux-gnu) sha256=1bdfca0c7d63998c60b0f4a8e3c8df2d33800ccc4abd2d612eddbbbc92a4c48b
|
|
330
|
+
sqlite3 (2.9.5-arm-linux-musl) sha256=bae1109d12b2e9f588455967729b008e1ff4feb7761749df695019c9079913c6
|
|
331
|
+
sqlite3 (2.9.5-arm64-darwin) sha256=d0cf444a70fc9395d513cfbcc1e6719e224aa645314e3824cb0474c721425aa2
|
|
332
|
+
sqlite3 (2.9.5-x86_64-darwin) sha256=8e9caae38bd7ebb29cbeee3e7ab1d12dc2327d9a1b92c7fcf0dda05589627a81
|
|
333
|
+
sqlite3 (2.9.5-x86_64-linux-gnu) sha256=233dbcb6714148dd23bc5aeb33e8efd6eac974969564ddd5794c23d5f52b231e
|
|
334
|
+
sqlite3 (2.9.5-x86_64-linux-musl) sha256=e7d3a7474e8af0f96150c21abc203fbab5437206bfcdf11deab7741c0ca516f2
|
|
335
|
+
stringio (3.2.0) sha256=c37cb2e58b4ffbd33fe5cd948c05934af997b36e0b6ca6fdf43afa234cf222e1
|
|
336
|
+
thor (1.5.0) sha256=e3a9e55fe857e44859ce104a84675ab6e8cd59c650a49106a05f55f136425e73
|
|
337
|
+
timeout (0.6.1) sha256=78f57368a7e7bbadec56971f78a3f5ecbcfb59b7fcbb0a3ed6ddc08a5094accb
|
|
338
|
+
tsort (0.2.0) sha256=9650a793f6859a43b6641671278f79cfead60ac714148aabe4e3f0060480089f
|
|
339
|
+
tzinfo (2.0.6) sha256=8daf828cc77bcf7d63b0e3bdb6caa47e2272dcfaf4fbfe46f8c3a9df087a829b
|
|
340
|
+
uri (1.1.1) sha256=379fa58d27ffb1387eaada68c749d1426738bd0f654d812fcc07e7568f5c57c6
|
|
341
|
+
useragent (0.16.11) sha256=700e6413ad4bb954bb63547fa098dddf7b0ebe75b40cc6f93b8d54255b173844
|
|
342
|
+
websocket-driver (0.8.1) sha256=5ab238238ce230e5d4b262d2be39624c867914eab99171dc4952b58b577c2d96
|
|
343
|
+
websocket-extensions (0.1.5) sha256=1c6ba63092cda343eb53fc657110c71c754c56484aad42578495227d717a8241
|
|
344
|
+
zeitwerk (2.8.2) sha256=7212a61311083c604184b1ea2574b9aa05cd14f855a0841c06985cabe9181d12
|
|
345
|
+
|
|
346
|
+
RUBY VERSION
|
|
347
|
+
ruby 4.0.1
|
|
348
|
+
|
|
349
|
+
BUNDLED WITH
|
|
350
|
+
4.0.10
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
= Plan
|
|
2
|
+
0.3 (on the main branch) is a non-breaking release on the 0.2 API: it replaces the
|
|
3
|
+
internal method_missing with generated methods, fixes the load-order and cross-DB
|
|
4
|
+
cache bugs, and adds a few convenience methods (see Features). The abandoned STI
|
|
5
|
+
experiment lives on the +sti+ branch. The next breaking rewrite is tracked in
|
|
6
|
+
v1.0-roadmap.md.
|
|
7
|
+
|
|
1
8
|
= Intro
|
|
2
9
|
There are always some static data(not static page) in application.For example product type or student diploma type.
|
|
3
10
|
|
|
@@ -5,11 +12,9 @@ This gem can map these static data to a Dictionary#method like Dictionary#studen
|
|
|
5
12
|
|
|
6
13
|
= Usage
|
|
7
14
|
== Installation
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Version 0.2 support Rails4
|
|
15
|
+
Version 0.3 supports Rails 7.1–8 and Ruby >= 3.3.
|
|
11
16
|
|
|
12
|
-
Version 0.1
|
|
17
|
+
Version 0.2 supports Rails 4–7. Version 0.1 supports Rails 3.1.
|
|
13
18
|
|
|
14
19
|
gem 'rails_dictionary'
|
|
15
20
|
or
|
|
@@ -26,7 +31,7 @@ See change log for brief info.
|
|
|
26
31
|
== Sample
|
|
27
32
|
Run following task will give you a simple start.Maybe you should try it in a new application first.
|
|
28
33
|
rake dicts:generate
|
|
29
|
-
rake dicts:
|
|
34
|
+
rake dicts:sample_slave
|
|
30
35
|
rake db:migrate
|
|
31
36
|
rake dicts:sample_data
|
|
32
37
|
These task are just generate table dictionaries,dict_types,students and some sample data.The data should be
|
|
@@ -77,7 +82,7 @@ Here is what should be like.Student model can be other models.
|
|
|
77
82
|
end
|
|
78
83
|
|
|
79
84
|
class Student < ActiveRecord::Base
|
|
80
|
-
# use
|
|
85
|
+
# use acts_as_dict_slave when your rails_dictionary version < 0.2
|
|
81
86
|
acts_as_dict_consumer
|
|
82
87
|
end
|
|
83
88
|
|
|
@@ -85,17 +90,27 @@ Here is what should be like.Student model can be other models.
|
|
|
85
90
|
DictType.all_cached #=> return cache of DictType.all
|
|
86
91
|
DictType.all_types = [:student_city,:student_school] # also cached
|
|
87
92
|
Dictionary.student_city #=> [Dictionary.find(5),Dictionary.find(6)]
|
|
88
|
-
student_city is a
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
Dictionary.
|
|
93
|
+
student_city is a method generated for each DictType (one per DictType.name); it
|
|
94
|
+
returns a list of dictionary objects whose dict_type is "student_city". The methods
|
|
95
|
+
are (re)generated at boot and whenever a DictType is created/destroyed.
|
|
96
|
+
And student_city returns an array,not ActiveRelation.So
|
|
97
|
+
Dictionary.student_school #=> []
|
|
98
|
+
Dictionary.student_city(query: true) #=> bypass the cache and hit the DB
|
|
93
99
|
If you need a ActiveRelation, try scoped_student_city like
|
|
94
100
|
Dictionary.scoped_student_city.where(...)
|
|
95
|
-
|
|
101
|
+
|
|
102
|
+
== 0.3 convenience methods
|
|
103
|
+
Dictionary.categories #=> [:student_city, :student_school]
|
|
104
|
+
Dictionary.add(:student_city, "wuhan") #=> create entry, returns the record
|
|
105
|
+
Dictionary.remove(:student_city, "wuhan") #=> destroy matching entries
|
|
106
|
+
Dictionary.options_for(:student_city, locale: :en) #=> [["beijing", 2],["shanghai",1]]
|
|
107
|
+
options_for returns options_for_select-ready pairs and is the replacement for the
|
|
108
|
+
deprecated +Dictionary.student_city(locale: ...)+ form below.
|
|
109
|
+
|
|
110
|
+
You can use it in a form select like
|
|
96
111
|
collection_select :student,:city,Dictionary.student_city,:id,:name_en
|
|
97
|
-
select :student
|
|
98
|
-
|
|
112
|
+
select :student, :city, Dictionary.options_for(:student_city, locale: :fr)
|
|
113
|
+
options_for(:student_city, locale: :fr) returns the french names (from name_fr in Dictionary)
|
|
99
114
|
Student.find(1).named_city = "beijing" # when default locale is :en
|
|
100
115
|
Here is an other solution for international translation.
|
|
101
116
|
Student.find(1).named_city(:zh) = "北京"
|
|
@@ -107,7 +122,10 @@ Student has two belongs_to assocition which named as city_dict and school_dict,t
|
|
|
107
122
|
Student.find(1).city_dict #=> Dictionary.find(6)
|
|
108
123
|
|
|
109
124
|
=== Sort Feature
|
|
110
|
-
|
|
125
|
+
Note: passing +:locale+ to the generated lookup (e.g. Dictionary.student_city(locale: :en))
|
|
126
|
+
is deprecated; use Dictionary.options_for(:student_city, locale: :en) instead. The sort
|
|
127
|
+
behavior described here applies to that form.
|
|
128
|
+
|
|
111
129
|
By default,if the options contains locale,the results are sorted by the name value.
|
|
112
130
|
If locale is :zh,sort rule is order by GBK encoding.
|
|
113
131
|
Other locales are just order by alphabetical without case sensitive.
|
data/Rakefile
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
require 'bundler'
|
|
2
2
|
Bundler::GemHelper.install_tasks
|
|
3
3
|
|
|
4
|
-
task :default => [:test]
|
|
4
|
+
task :default => [:test, :load_order]
|
|
5
5
|
|
|
6
6
|
desc "Running Test"
|
|
7
7
|
task :test do
|
|
8
|
-
system
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
# system "ruby -I . test/rails_dictionary_test.rb " # used with version 0.0.8 or before it
|
|
9
|
+
sh "bundle exec rspec spec/rails_dictionary_spec.rb"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
desc "Run isolated load-order scenarios (each in its own process)"
|
|
13
|
+
task :load_order do
|
|
14
|
+
Dir[File.expand_path("spec/load_order/*_boot*.rb", __dir__)].sort.each do |script|
|
|
15
|
+
sh "bundle exec ruby #{script}"
|
|
16
|
+
end
|
|
11
17
|
end
|