rails_vault 0.1.0 → 1.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 +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +166 -122
- data/README.md +24 -6
- data/bin/console +0 -0
- data/bin/release +19 -4
- data/bin/setup +0 -0
- data/lib/generators/templates/vault.rb.tt +6 -0
- data/lib/generators/vault_generator.rb +53 -0
- data/lib/generators/vault_templates.rb +39 -0
- data/lib/rails_vault/base.rb +18 -11
- data/lib/rails_vault/vaults.rb +19 -2
- data/lib/rails_vault/version.rb +1 -1
- data/lib/rails_vault.rb +2 -1
- data/rails_vault.gemspec +5 -4
- metadata +11 -12
- data/lib/generators/rails_vault/add_generator.rb +0 -25
- data/lib/generators/rails_vault/templates/vault.rb.tt +0 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1d5f2dd2b22135ce8c89442188262351da076d968625c6b5b03926b8ba1ceacb
|
|
4
|
+
data.tar.gz: d8bbe5b52d455a941464ccc1179dd507bfb12784dd072cd4f68bcc395d62e728
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 40c43040dbac22aed22104cd8a8a72e26995a0620b144c44d575ea954d533f23ec3e2740aff8a8d3e546f0f2ed957711ab00517608bc97a3d5f703702de432d4
|
|
7
|
+
data.tar.gz: c2d0a890eaeb8daf2fcb131fa56ee0348b757019463ee5f29f04e958dce94da5f073d59cf235636aa87c15a9b69918081eca23812ef79c2e284c43837e640714
|
data/Gemfile
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
source "https://rubygems.org"
|
|
4
4
|
|
|
5
|
-
# Specify your gem's dependencies in rails_vault.gemspec
|
|
6
5
|
gemspec
|
|
7
6
|
|
|
8
7
|
group :development do
|
|
@@ -12,4 +11,5 @@ end
|
|
|
12
11
|
group :development, :test do
|
|
13
12
|
gem "minitest"
|
|
14
13
|
gem "debug", "~> 1.9", ">= 1.9.2"
|
|
14
|
+
gem "sqlite3", "~> 2.0"
|
|
15
15
|
end
|
data/Gemfile.lock
CHANGED
|
@@ -1,124 +1,130 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
rails_vault (
|
|
4
|
+
rails_vault (1.0.0)
|
|
5
5
|
rails (>= 7.2.2)
|
|
6
6
|
store_attribute (>= 1.3)
|
|
7
7
|
|
|
8
8
|
GEM
|
|
9
9
|
remote: https://rubygems.org/
|
|
10
10
|
specs:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
action_text-trix (2.1.19)
|
|
12
|
+
railties
|
|
13
|
+
actioncable (8.1.3)
|
|
14
|
+
actionpack (= 8.1.3)
|
|
15
|
+
activesupport (= 8.1.3)
|
|
14
16
|
nio4r (~> 2.0)
|
|
15
17
|
websocket-driver (>= 0.6.1)
|
|
16
18
|
zeitwerk (~> 2.6)
|
|
17
|
-
actionmailbox (
|
|
18
|
-
actionpack (=
|
|
19
|
-
activejob (=
|
|
20
|
-
activerecord (=
|
|
21
|
-
activestorage (=
|
|
22
|
-
activesupport (=
|
|
19
|
+
actionmailbox (8.1.3)
|
|
20
|
+
actionpack (= 8.1.3)
|
|
21
|
+
activejob (= 8.1.3)
|
|
22
|
+
activerecord (= 8.1.3)
|
|
23
|
+
activestorage (= 8.1.3)
|
|
24
|
+
activesupport (= 8.1.3)
|
|
23
25
|
mail (>= 2.8.0)
|
|
24
|
-
actionmailer (
|
|
25
|
-
actionpack (=
|
|
26
|
-
actionview (=
|
|
27
|
-
activejob (=
|
|
28
|
-
activesupport (=
|
|
26
|
+
actionmailer (8.1.3)
|
|
27
|
+
actionpack (= 8.1.3)
|
|
28
|
+
actionview (= 8.1.3)
|
|
29
|
+
activejob (= 8.1.3)
|
|
30
|
+
activesupport (= 8.1.3)
|
|
29
31
|
mail (>= 2.8.0)
|
|
30
32
|
rails-dom-testing (~> 2.2)
|
|
31
|
-
actionpack (
|
|
32
|
-
actionview (=
|
|
33
|
-
activesupport (=
|
|
33
|
+
actionpack (8.1.3)
|
|
34
|
+
actionview (= 8.1.3)
|
|
35
|
+
activesupport (= 8.1.3)
|
|
34
36
|
nokogiri (>= 1.8.5)
|
|
35
|
-
|
|
36
|
-
rack (>= 2.2.4, < 3.2)
|
|
37
|
+
rack (>= 2.2.4)
|
|
37
38
|
rack-session (>= 1.0.1)
|
|
38
39
|
rack-test (>= 0.6.3)
|
|
39
40
|
rails-dom-testing (~> 2.2)
|
|
40
41
|
rails-html-sanitizer (~> 1.6)
|
|
41
42
|
useragent (~> 0.16)
|
|
42
|
-
actiontext (
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
actiontext (8.1.3)
|
|
44
|
+
action_text-trix (~> 2.1.15)
|
|
45
|
+
actionpack (= 8.1.3)
|
|
46
|
+
activerecord (= 8.1.3)
|
|
47
|
+
activestorage (= 8.1.3)
|
|
48
|
+
activesupport (= 8.1.3)
|
|
47
49
|
globalid (>= 0.6.0)
|
|
48
50
|
nokogiri (>= 1.8.5)
|
|
49
|
-
actionview (
|
|
50
|
-
activesupport (=
|
|
51
|
+
actionview (8.1.3)
|
|
52
|
+
activesupport (= 8.1.3)
|
|
51
53
|
builder (~> 3.1)
|
|
52
54
|
erubi (~> 1.11)
|
|
53
55
|
rails-dom-testing (~> 2.2)
|
|
54
56
|
rails-html-sanitizer (~> 1.6)
|
|
55
|
-
activejob (
|
|
56
|
-
activesupport (=
|
|
57
|
+
activejob (8.1.3)
|
|
58
|
+
activesupport (= 8.1.3)
|
|
57
59
|
globalid (>= 0.3.6)
|
|
58
|
-
activemodel (
|
|
59
|
-
activesupport (=
|
|
60
|
-
activerecord (
|
|
61
|
-
activemodel (=
|
|
62
|
-
activesupport (=
|
|
60
|
+
activemodel (8.1.3)
|
|
61
|
+
activesupport (= 8.1.3)
|
|
62
|
+
activerecord (8.1.3)
|
|
63
|
+
activemodel (= 8.1.3)
|
|
64
|
+
activesupport (= 8.1.3)
|
|
63
65
|
timeout (>= 0.4.0)
|
|
64
|
-
activestorage (
|
|
65
|
-
actionpack (=
|
|
66
|
-
activejob (=
|
|
67
|
-
activerecord (=
|
|
68
|
-
activesupport (=
|
|
66
|
+
activestorage (8.1.3)
|
|
67
|
+
actionpack (= 8.1.3)
|
|
68
|
+
activejob (= 8.1.3)
|
|
69
|
+
activerecord (= 8.1.3)
|
|
70
|
+
activesupport (= 8.1.3)
|
|
69
71
|
marcel (~> 1.0)
|
|
70
|
-
activesupport (
|
|
72
|
+
activesupport (8.1.3)
|
|
71
73
|
base64
|
|
72
|
-
benchmark (>= 0.3)
|
|
73
74
|
bigdecimal
|
|
74
75
|
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
75
76
|
connection_pool (>= 2.2.5)
|
|
76
77
|
drb
|
|
77
78
|
i18n (>= 1.6, < 2)
|
|
79
|
+
json
|
|
78
80
|
logger (>= 1.4.2)
|
|
79
81
|
minitest (>= 5.1)
|
|
80
82
|
securerandom (>= 0.3)
|
|
81
83
|
tzinfo (~> 2.0, >= 2.0.5)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
bigdecimal (
|
|
84
|
+
uri (>= 0.13.1)
|
|
85
|
+
ast (2.4.3)
|
|
86
|
+
base64 (0.3.0)
|
|
87
|
+
bigdecimal (4.1.2)
|
|
86
88
|
builder (3.3.0)
|
|
87
|
-
concurrent-ruby (1.3.
|
|
88
|
-
connection_pool (
|
|
89
|
+
concurrent-ruby (1.3.6)
|
|
90
|
+
connection_pool (3.0.2)
|
|
89
91
|
crass (1.0.6)
|
|
90
|
-
date (3.
|
|
91
|
-
debug (1.
|
|
92
|
+
date (3.5.1)
|
|
93
|
+
debug (1.11.1)
|
|
92
94
|
irb (~> 1.10)
|
|
93
95
|
reline (>= 0.3.8)
|
|
94
|
-
drb (2.2.
|
|
96
|
+
drb (2.2.3)
|
|
97
|
+
erb (6.0.4)
|
|
95
98
|
erubi (1.13.1)
|
|
96
|
-
globalid (1.
|
|
99
|
+
globalid (1.3.0)
|
|
97
100
|
activesupport (>= 6.1)
|
|
98
|
-
i18n (1.14.
|
|
101
|
+
i18n (1.14.8)
|
|
99
102
|
concurrent-ruby (~> 1.0)
|
|
100
|
-
io-console (0.8.
|
|
101
|
-
irb (1.
|
|
103
|
+
io-console (0.8.2)
|
|
104
|
+
irb (1.18.0)
|
|
102
105
|
pp (>= 0.6.0)
|
|
106
|
+
prism (>= 1.3.0)
|
|
103
107
|
rdoc (>= 4.0.0)
|
|
104
108
|
reline (>= 0.4.2)
|
|
105
|
-
json (2.
|
|
106
|
-
language_server-protocol (3.17.0.
|
|
109
|
+
json (2.19.9)
|
|
110
|
+
language_server-protocol (3.17.0.5)
|
|
107
111
|
lint_roller (1.1.0)
|
|
108
|
-
logger (1.
|
|
109
|
-
loofah (2.
|
|
112
|
+
logger (1.7.0)
|
|
113
|
+
loofah (2.25.1)
|
|
110
114
|
crass (~> 1.0.2)
|
|
111
115
|
nokogiri (>= 1.12.0)
|
|
112
|
-
mail (2.
|
|
116
|
+
mail (2.9.0)
|
|
117
|
+
logger
|
|
113
118
|
mini_mime (>= 0.1.1)
|
|
114
119
|
net-imap
|
|
115
120
|
net-pop
|
|
116
121
|
net-smtp
|
|
117
|
-
marcel (1.
|
|
122
|
+
marcel (1.2.1)
|
|
118
123
|
mini_mime (1.1.5)
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
124
|
+
minitest (6.0.6)
|
|
125
|
+
drb (~> 2.0)
|
|
126
|
+
prism (~> 1.5)
|
|
127
|
+
net-imap (0.6.4.1)
|
|
122
128
|
date
|
|
123
129
|
net-protocol
|
|
124
130
|
net-pop (0.1.2)
|
|
@@ -127,120 +133,158 @@ GEM
|
|
|
127
133
|
timeout
|
|
128
134
|
net-smtp (0.5.1)
|
|
129
135
|
net-protocol
|
|
130
|
-
nio4r (2.7.
|
|
131
|
-
nokogiri (1.
|
|
132
|
-
|
|
136
|
+
nio4r (2.7.5)
|
|
137
|
+
nokogiri (1.19.3-aarch64-linux-gnu)
|
|
138
|
+
racc (~> 1.4)
|
|
139
|
+
nokogiri (1.19.3-aarch64-linux-musl)
|
|
140
|
+
racc (~> 1.4)
|
|
141
|
+
nokogiri (1.19.3-arm-linux-gnu)
|
|
142
|
+
racc (~> 1.4)
|
|
143
|
+
nokogiri (1.19.3-arm-linux-musl)
|
|
144
|
+
racc (~> 1.4)
|
|
145
|
+
nokogiri (1.19.3-arm64-darwin)
|
|
133
146
|
racc (~> 1.4)
|
|
134
|
-
|
|
135
|
-
|
|
147
|
+
nokogiri (1.19.3-x86_64-darwin)
|
|
148
|
+
racc (~> 1.4)
|
|
149
|
+
nokogiri (1.19.3-x86_64-linux-gnu)
|
|
150
|
+
racc (~> 1.4)
|
|
151
|
+
nokogiri (1.19.3-x86_64-linux-musl)
|
|
152
|
+
racc (~> 1.4)
|
|
153
|
+
parallel (2.1.0)
|
|
154
|
+
parser (3.3.11.1)
|
|
136
155
|
ast (~> 2.4.1)
|
|
137
156
|
racc
|
|
138
|
-
pp (0.6.
|
|
157
|
+
pp (0.6.3)
|
|
139
158
|
prettyprint
|
|
140
159
|
prettyprint (0.2.0)
|
|
141
|
-
|
|
160
|
+
prism (1.9.0)
|
|
161
|
+
psych (5.4.0)
|
|
142
162
|
date
|
|
143
163
|
stringio
|
|
144
164
|
racc (1.8.1)
|
|
145
|
-
rack (3.
|
|
146
|
-
rack-session (2.1.
|
|
165
|
+
rack (3.2.6)
|
|
166
|
+
rack-session (2.1.2)
|
|
147
167
|
base64 (>= 0.1.0)
|
|
148
168
|
rack (>= 3.0.0)
|
|
149
169
|
rack-test (2.2.0)
|
|
150
170
|
rack (>= 1.3)
|
|
151
|
-
rackup (2.
|
|
171
|
+
rackup (2.3.1)
|
|
152
172
|
rack (>= 3)
|
|
153
|
-
rails (
|
|
154
|
-
actioncable (=
|
|
155
|
-
actionmailbox (=
|
|
156
|
-
actionmailer (=
|
|
157
|
-
actionpack (=
|
|
158
|
-
actiontext (=
|
|
159
|
-
actionview (=
|
|
160
|
-
activejob (=
|
|
161
|
-
activemodel (=
|
|
162
|
-
activerecord (=
|
|
163
|
-
activestorage (=
|
|
164
|
-
activesupport (=
|
|
173
|
+
rails (8.1.3)
|
|
174
|
+
actioncable (= 8.1.3)
|
|
175
|
+
actionmailbox (= 8.1.3)
|
|
176
|
+
actionmailer (= 8.1.3)
|
|
177
|
+
actionpack (= 8.1.3)
|
|
178
|
+
actiontext (= 8.1.3)
|
|
179
|
+
actionview (= 8.1.3)
|
|
180
|
+
activejob (= 8.1.3)
|
|
181
|
+
activemodel (= 8.1.3)
|
|
182
|
+
activerecord (= 8.1.3)
|
|
183
|
+
activestorage (= 8.1.3)
|
|
184
|
+
activesupport (= 8.1.3)
|
|
165
185
|
bundler (>= 1.15.0)
|
|
166
|
-
railties (=
|
|
167
|
-
rails-dom-testing (2.
|
|
186
|
+
railties (= 8.1.3)
|
|
187
|
+
rails-dom-testing (2.3.0)
|
|
168
188
|
activesupport (>= 5.0.0)
|
|
169
189
|
minitest
|
|
170
190
|
nokogiri (>= 1.6)
|
|
171
|
-
rails-html-sanitizer (1.
|
|
172
|
-
loofah (~> 2.
|
|
191
|
+
rails-html-sanitizer (1.7.0)
|
|
192
|
+
loofah (~> 2.25)
|
|
173
193
|
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)
|
|
174
|
-
railties (
|
|
175
|
-
actionpack (=
|
|
176
|
-
activesupport (=
|
|
194
|
+
railties (8.1.3)
|
|
195
|
+
actionpack (= 8.1.3)
|
|
196
|
+
activesupport (= 8.1.3)
|
|
177
197
|
irb (~> 1.13)
|
|
178
198
|
rackup (>= 1.0.0)
|
|
179
199
|
rake (>= 12.2)
|
|
180
200
|
thor (~> 1.0, >= 1.2.2)
|
|
201
|
+
tsort (>= 0.2)
|
|
181
202
|
zeitwerk (~> 2.6)
|
|
182
203
|
rainbow (3.1.1)
|
|
183
|
-
rake (13.2
|
|
184
|
-
rdoc (
|
|
204
|
+
rake (13.4.2)
|
|
205
|
+
rdoc (7.2.0)
|
|
206
|
+
erb
|
|
185
207
|
psych (>= 4.0.0)
|
|
186
|
-
|
|
187
|
-
|
|
208
|
+
tsort
|
|
209
|
+
regexp_parser (2.12.0)
|
|
210
|
+
reline (0.6.3)
|
|
188
211
|
io-console (~> 0.5)
|
|
189
|
-
rubocop (1.
|
|
212
|
+
rubocop (1.87.0)
|
|
190
213
|
json (~> 2.3)
|
|
191
|
-
language_server-protocol (
|
|
192
|
-
|
|
214
|
+
language_server-protocol (~> 3.17.0.2)
|
|
215
|
+
lint_roller (~> 1.1.0)
|
|
216
|
+
parallel (>= 1.10)
|
|
193
217
|
parser (>= 3.3.0.2)
|
|
194
218
|
rainbow (>= 2.2.2, < 4.0)
|
|
195
219
|
regexp_parser (>= 2.9.3, < 3.0)
|
|
196
|
-
rubocop-ast (>= 1.
|
|
220
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
197
221
|
ruby-progressbar (~> 1.7)
|
|
198
222
|
unicode-display_width (>= 2.4.0, < 4.0)
|
|
199
|
-
rubocop-ast (1.
|
|
200
|
-
parser (>= 3.3.
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
223
|
+
rubocop-ast (1.49.1)
|
|
224
|
+
parser (>= 3.3.7.2)
|
|
225
|
+
prism (~> 1.7)
|
|
226
|
+
rubocop-performance (1.26.1)
|
|
227
|
+
lint_roller (~> 1.1)
|
|
228
|
+
rubocop (>= 1.75.0, < 2.0)
|
|
229
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
|
204
230
|
ruby-progressbar (1.13.0)
|
|
205
231
|
securerandom (0.4.1)
|
|
206
|
-
|
|
232
|
+
sqlite3 (2.9.5-aarch64-linux-gnu)
|
|
233
|
+
sqlite3 (2.9.5-aarch64-linux-musl)
|
|
234
|
+
sqlite3 (2.9.5-arm-linux-gnu)
|
|
235
|
+
sqlite3 (2.9.5-arm-linux-musl)
|
|
236
|
+
sqlite3 (2.9.5-arm64-darwin)
|
|
237
|
+
sqlite3 (2.9.5-x86_64-darwin)
|
|
238
|
+
sqlite3 (2.9.5-x86_64-linux-gnu)
|
|
239
|
+
sqlite3 (2.9.5-x86_64-linux-musl)
|
|
240
|
+
standard (1.55.0)
|
|
207
241
|
language_server-protocol (~> 3.17.0.2)
|
|
208
242
|
lint_roller (~> 1.0)
|
|
209
|
-
rubocop (~> 1.
|
|
243
|
+
rubocop (~> 1.87.0)
|
|
210
244
|
standard-custom (~> 1.0.0)
|
|
211
|
-
standard-performance (~> 1.
|
|
245
|
+
standard-performance (~> 1.8)
|
|
212
246
|
standard-custom (1.0.2)
|
|
213
247
|
lint_roller (~> 1.0)
|
|
214
248
|
rubocop (~> 1.50)
|
|
215
|
-
standard-performance (1.
|
|
249
|
+
standard-performance (1.9.0)
|
|
216
250
|
lint_roller (~> 1.1)
|
|
217
|
-
rubocop-performance (~> 1.
|
|
218
|
-
store_attribute (2.
|
|
219
|
-
activerecord (>=
|
|
220
|
-
stringio (3.
|
|
221
|
-
thor (1.
|
|
222
|
-
timeout (0.
|
|
251
|
+
rubocop-performance (~> 1.26.0)
|
|
252
|
+
store_attribute (2.1.1)
|
|
253
|
+
activerecord (>= 7.2)
|
|
254
|
+
stringio (3.2.0)
|
|
255
|
+
thor (1.5.0)
|
|
256
|
+
timeout (0.6.1)
|
|
257
|
+
tsort (0.2.0)
|
|
223
258
|
tzinfo (2.0.6)
|
|
224
259
|
concurrent-ruby (~> 1.0)
|
|
225
|
-
unicode-display_width (3.
|
|
226
|
-
unicode-emoji (~> 4.
|
|
227
|
-
unicode-emoji (4.0
|
|
260
|
+
unicode-display_width (3.2.0)
|
|
261
|
+
unicode-emoji (~> 4.1)
|
|
262
|
+
unicode-emoji (4.2.0)
|
|
263
|
+
uri (1.1.1)
|
|
228
264
|
useragent (0.16.11)
|
|
229
|
-
websocket-driver (0.
|
|
265
|
+
websocket-driver (0.8.1)
|
|
230
266
|
base64
|
|
231
267
|
websocket-extensions (>= 0.1.0)
|
|
232
268
|
websocket-extensions (0.1.5)
|
|
233
|
-
zeitwerk (2.
|
|
269
|
+
zeitwerk (2.8.2)
|
|
234
270
|
|
|
235
271
|
PLATFORMS
|
|
236
|
-
|
|
272
|
+
aarch64-linux-gnu
|
|
273
|
+
aarch64-linux-musl
|
|
274
|
+
arm-linux-gnu
|
|
275
|
+
arm-linux-musl
|
|
276
|
+
arm64-darwin
|
|
277
|
+
x86_64-darwin
|
|
237
278
|
x86_64-linux
|
|
279
|
+
x86_64-linux-gnu
|
|
280
|
+
x86_64-linux-musl
|
|
238
281
|
|
|
239
282
|
DEPENDENCIES
|
|
240
283
|
debug (~> 1.9, >= 1.9.2)
|
|
241
284
|
minitest
|
|
242
285
|
rails_vault!
|
|
286
|
+
sqlite3 (~> 2.0)
|
|
243
287
|
standard
|
|
244
288
|
|
|
245
289
|
BUNDLED WITH
|
|
246
|
-
2.
|
|
290
|
+
2.7.0
|
data/README.md
CHANGED
|
@@ -13,6 +13,8 @@ Simple and easy to add settings, preferences and so on to any model. See [an exa
|
|
|
13
13
|
</picture>
|
|
14
14
|
</a>
|
|
15
15
|
|
|
16
|
+
Want to make JavaScript your second-favorite language? 👉 [JavaScript for Rails Developers](https://javascriptforrails.com/)
|
|
17
|
+
|
|
16
18
|
|
|
17
19
|
## Installation
|
|
18
20
|
|
|
@@ -27,13 +29,27 @@ rails db:migrate
|
|
|
27
29
|
|
|
28
30
|
Generate a vault:
|
|
29
31
|
```bash
|
|
30
|
-
rails generate
|
|
32
|
+
rails generate vault MODEL::VAULT_NAME [field:type field:type]
|
|
31
33
|
```
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
Use a built-in template:
|
|
36
|
+
```bash
|
|
37
|
+
rails generate vault User::Preferences --template=preferences
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Available templates:
|
|
41
|
+
|
|
42
|
+
| Template | Description |
|
|
43
|
+
|----------|-------------|
|
|
44
|
+
| `preferences` | Timezone, locale, date/time format, UI density, hotkeys |
|
|
45
|
+
| `notification_settings` | Email/push/SMS toggles, frequency, quiet hours |
|
|
46
|
+
| `feature_flags` | Boolean flags for A/B testing and beta features |
|
|
47
|
+
| `email_sequence` | State tracking for drip/welcome email sequences |
|
|
34
48
|
|
|
49
|
+
|
|
50
|
+
Example (manual fields):
|
|
35
51
|
```bash
|
|
36
|
-
rails generate
|
|
52
|
+
rails generate vault User::Preferences \
|
|
37
53
|
time_zone:string \
|
|
38
54
|
datetime_format:string \
|
|
39
55
|
hotkeys_disabled:boolean
|
|
@@ -43,16 +59,18 @@ This will:
|
|
|
43
59
|
1. Create a vault class at **app/models/users/preferences.rb**
|
|
44
60
|
2. Add `vault :preferences` to your User model
|
|
45
61
|
|
|
62
|
+
|
|
46
63
|
### Define vault attributes
|
|
47
64
|
|
|
48
65
|
```ruby
|
|
49
|
-
class User::Preferences <
|
|
66
|
+
class User::Preferences < Vault
|
|
50
67
|
vault_attribute :time_zone, :string, default: "UTC"
|
|
51
68
|
vault_attribute :datetime_format, :string, default: "dd-mm-yyyy"
|
|
52
69
|
vault_attribute :hotkeys_disabled, :boolean, default: false
|
|
53
70
|
end
|
|
54
71
|
```
|
|
55
72
|
|
|
73
|
+
|
|
56
74
|
### Read and write values
|
|
57
75
|
|
|
58
76
|
```ruby
|
|
@@ -65,9 +83,9 @@ user.preferences.update time_zone: "Amsterdam", hotkeys_disabled: true
|
|
|
65
83
|
|
|
66
84
|
user.preferences.time_zone # => "Amsterdam"
|
|
67
85
|
user.preferences.hotkeys_disabled? # => true
|
|
68
|
-
```
|
|
69
86
|
|
|
70
|
-
|
|
87
|
+
user.preferences.vault_attributes # => ["time_zone", "datetime_format", "hotkeys_disabled"]
|
|
88
|
+
```
|
|
71
89
|
|
|
72
90
|
|
|
73
91
|
## Contributing
|
data/bin/console
CHANGED
|
File without changes
|
data/bin/release
CHANGED
|
@@ -3,17 +3,32 @@
|
|
|
3
3
|
VERSION=$1
|
|
4
4
|
|
|
5
5
|
if [ -z "$VERSION" ]; then
|
|
6
|
-
echo "Error:
|
|
7
|
-
echo "Usage: $0 <version-number>"
|
|
6
|
+
echo "Error: Version number or bump type is required"
|
|
7
|
+
echo " Usage: $0 <major|minor|patch|version-number>"
|
|
8
|
+
|
|
8
9
|
exit 1
|
|
9
10
|
fi
|
|
10
11
|
|
|
12
|
+
if [[ "$VERSION" =~ ^(major|minor|patch)$ ]]; then
|
|
13
|
+
CURRENT=$(grep -o '"[^"]*"' ./lib/rails_vault/version.rb | tr -d '"')
|
|
14
|
+
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT"
|
|
15
|
+
|
|
16
|
+
case $VERSION in
|
|
17
|
+
major) VERSION="$((MAJOR + 1)).0.0" ;;
|
|
18
|
+
minor) VERSION="$MAJOR.$((MINOR + 1)).0" ;;
|
|
19
|
+
patch) VERSION="$MAJOR.$MINOR.$((PATCH + 1))" ;;
|
|
20
|
+
esac
|
|
21
|
+
fi
|
|
22
|
+
|
|
11
23
|
printf "module RailsVault\n VERSION = \"$VERSION\"\nend\n" > ./lib/rails_vault/version.rb
|
|
24
|
+
|
|
12
25
|
bundle
|
|
26
|
+
|
|
13
27
|
git add Gemfile.lock lib/rails_vault/version.rb
|
|
14
28
|
git commit -m "Bump version for $VERSION"
|
|
15
29
|
git push
|
|
16
30
|
git tag v$VERSION
|
|
17
31
|
git push --tags
|
|
18
|
-
|
|
19
|
-
|
|
32
|
+
|
|
33
|
+
bundle exec rake build
|
|
34
|
+
gem push "pkg/rails_vault-$VERSION.gem"
|
data/bin/setup
CHANGED
|
File without changes
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rails/generators"
|
|
4
|
+
require "rails/generators/named_base"
|
|
5
|
+
require_relative "vault_templates"
|
|
6
|
+
|
|
7
|
+
class VaultGenerator < Rails::Generators::NamedBase
|
|
8
|
+
source_root File.expand_path("../templates", __FILE__)
|
|
9
|
+
|
|
10
|
+
argument :attributes, type: :array, default: [], banner: "field:type field:type"
|
|
11
|
+
class_option :template, type: :string, default: nil, desc: "Use a built-in template (preferences, notification_settings, feature_flags, email_sequence)"
|
|
12
|
+
|
|
13
|
+
def create_vault_file
|
|
14
|
+
template "vault.rb.tt", File.join("app/models", class_path, "#{file_name}.rb")
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def inject_vault_into_model
|
|
18
|
+
has_existing_vault? ?
|
|
19
|
+
gsub_file(model_path, /^\s*vaults?\s+.+$/, vault_line) :
|
|
20
|
+
inject_into_class(model_path, class_name.deconstantize) { "#{vault_line}\n" }
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def vault_attributes
|
|
26
|
+
if options[:template]
|
|
27
|
+
VaultTemplates::TEMPLATES.fetch(options[:template]) do |key|
|
|
28
|
+
raise ArgumentError, "Unknown template '#{key}'. Available: #{VaultTemplates::TEMPLATES.keys.join(", ")}"
|
|
29
|
+
end
|
|
30
|
+
else
|
|
31
|
+
attributes.map { |attribute| {name: attribute.name.to_sym, type: attribute.type} }
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def has_existing_vault?
|
|
36
|
+
model_content =~ /vaults?\s+/
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def vault_line
|
|
40
|
+
vaults = Set.new(model_content[/vaults?\s+(.+)$/, 1]&.scan(/:(\w+)/)&.flatten || []) << plural_name
|
|
41
|
+
method_name = vaults.many? ? "vaults" : "vault"
|
|
42
|
+
|
|
43
|
+
" #{method_name} #{vaults.map { ":#{_1}" }.join(", ")}"
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def model_content
|
|
47
|
+
@model_content ||= File.binread(model_path)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def model_path
|
|
51
|
+
"app/models/#{class_path.join("/")}.rb"
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module VaultTemplates
|
|
4
|
+
TEMPLATES = {
|
|
5
|
+
"preferences" => [
|
|
6
|
+
{name: :time_zone, type: :string, default: '"UTC"'},
|
|
7
|
+
{name: :locale, type: :string, default: '"en"'},
|
|
8
|
+
{name: :date_format, type: :string, default: '"dd-mm-yyyy"'},
|
|
9
|
+
{name: :time_format, type: :string, default: '"24h"'},
|
|
10
|
+
{name: :density, type: :string, default: '"default"'},
|
|
11
|
+
{name: :hotkeys_disabled, type: :boolean, default: "false"}
|
|
12
|
+
],
|
|
13
|
+
|
|
14
|
+
"notification_settings" => [
|
|
15
|
+
{name: :email_enabled, type: :boolean, default: "true"},
|
|
16
|
+
{name: :push_enabled, type: :boolean, default: "true"},
|
|
17
|
+
{name: :sms_enabled, type: :boolean, default: "false"},
|
|
18
|
+
{name: :email_frequency, type: :string, default: '"daily"'},
|
|
19
|
+
{name: :quiet_hours_start, type: :string, default: '"22:00"'},
|
|
20
|
+
{name: :quiet_hours_end, type: :string, default: '"08:00"'}
|
|
21
|
+
],
|
|
22
|
+
|
|
23
|
+
"feature_flags" => [
|
|
24
|
+
{name: :new_dashboard_enabled, type: :boolean, default: "false"},
|
|
25
|
+
{name: :beta_features_enabled, type: :boolean, default: "false"},
|
|
26
|
+
{name: :experimental_ai_assistant, type: :boolean, default: "false"},
|
|
27
|
+
{name: :dark_mode_beta, type: :boolean, default: "false"}
|
|
28
|
+
],
|
|
29
|
+
|
|
30
|
+
"email_sequence" => [
|
|
31
|
+
{name: :sequence_name, type: :string, default: '"welcome"'},
|
|
32
|
+
{name: :current_step, type: :integer, default: "0"},
|
|
33
|
+
{name: :total_steps, type: :integer, default: "5"},
|
|
34
|
+
{name: :started_at, type: :datetime},
|
|
35
|
+
{name: :completed_at, type: :datetime},
|
|
36
|
+
{name: :skipped, type: :boolean, default: "false"}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
end
|
data/lib/rails_vault/base.rb
CHANGED
|
@@ -4,21 +4,28 @@ module RailsVault
|
|
|
4
4
|
|
|
5
5
|
belongs_to :resource, polymorphic: true
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
class << self
|
|
8
|
+
def inherited(subclass)
|
|
9
|
+
super
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
end
|
|
11
|
+
scope_name = subclass.name.demodulize.underscore
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
subclass.vault_scope(scope_name)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def vault_scope(scope_name)
|
|
17
|
+
default_scope { where(scope: scope_name) }
|
|
18
|
+
end
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
def vault_attribute(key, *attributes)
|
|
21
|
+
options = attributes.extract_options!
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
store_attribute :payload, key, *attributes, **options
|
|
24
|
+
end
|
|
22
25
|
end
|
|
26
|
+
|
|
27
|
+
def vault_attributes = payload.keys
|
|
23
28
|
end
|
|
24
29
|
end
|
|
30
|
+
|
|
31
|
+
Vault = RailsVault::Base
|
data/lib/rails_vault/vaults.rb
CHANGED
|
@@ -4,14 +4,31 @@ module RailsVault
|
|
|
4
4
|
|
|
5
5
|
class_methods do
|
|
6
6
|
def vault(association_name, class_name: nil)
|
|
7
|
-
|
|
7
|
+
vault_class = class_name || "#{self}::#{association_name.to_s.camelize}"
|
|
8
|
+
|
|
9
|
+
has_one(
|
|
10
|
+
association_name,
|
|
11
|
+
as: :resource,
|
|
12
|
+
class_name: vault_class,
|
|
13
|
+
dependent: :destroy
|
|
14
|
+
)
|
|
8
15
|
end
|
|
9
16
|
|
|
10
17
|
def vaults(*association_names)
|
|
11
18
|
association_names.each do |association_name|
|
|
12
|
-
|
|
19
|
+
vault(association_name)
|
|
13
20
|
end
|
|
14
21
|
end
|
|
15
22
|
end
|
|
23
|
+
|
|
24
|
+
included do
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def create_vault(association_name, vault_class)
|
|
28
|
+
return if public_send(association_name).present?
|
|
29
|
+
|
|
30
|
+
vault_class.constantize.create!(resource: self)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
16
33
|
end
|
|
17
34
|
end
|
data/lib/rails_vault/version.rb
CHANGED
data/lib/rails_vault.rb
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "store_attribute"
|
|
4
|
+
|
|
4
5
|
require "rails_vault/version"
|
|
6
|
+
require "generators/vault_generator"
|
|
5
7
|
require "rails_vault/engine"
|
|
6
8
|
require "rails_vault/base"
|
|
7
9
|
require "rails_vault/vaults"
|
|
8
10
|
|
|
9
11
|
module RailsVault
|
|
10
|
-
class Error < StandardError; end
|
|
11
12
|
end
|
data/rails_vault.gemspec
CHANGED
|
@@ -5,19 +5,20 @@ require_relative "lib/rails_vault/version"
|
|
|
5
5
|
Gem::Specification.new do |spec|
|
|
6
6
|
spec.name = "rails_vault"
|
|
7
7
|
spec.version = RailsVault::VERSION
|
|
8
|
-
spec.authors = ["Rails Designer
|
|
8
|
+
spec.authors = ["Rails Designer"]
|
|
9
9
|
spec.email = ["devs@railsdesigner.com"]
|
|
10
|
-
spec.summary = "Simple and easy to add settings, preferences and so on to any model."
|
|
11
|
-
spec.description = "Rails Vault
|
|
10
|
+
spec.summary = "Simple and easy to add settings, preferences and so on to any ActiveRecord model."
|
|
11
|
+
spec.description = "Rails Vault adds settings and preferences to ActiveRecord models. The settings are stored as JSON in a separate table."
|
|
12
12
|
spec.homepage = "https://railsdesigner.com/rails-vault/"
|
|
13
13
|
spec.license = "MIT"
|
|
14
14
|
|
|
15
15
|
spec.metadata["homepage_uri"] = spec.homepage
|
|
16
16
|
spec.metadata["source_code_uri"] = "https://github.com/Rails-Designer/rails_vault/"
|
|
17
17
|
|
|
18
|
-
spec.files = Dir["{bin,
|
|
18
|
+
spec.files = Dir["{bin,db,lib}/**/*", "Rakefile", "README.md", "rails_vault.gemspec", "Gemfile", "Gemfile.lock"]
|
|
19
19
|
|
|
20
20
|
spec.required_ruby_version = ">= 3.1.0"
|
|
21
|
+
|
|
21
22
|
spec.add_dependency "rails", ">= 7.2.2"
|
|
22
23
|
spec.add_dependency "store_attribute", ">= 1.3"
|
|
23
24
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rails_vault
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
- Rails Designer
|
|
8
|
-
autorequire:
|
|
7
|
+
- Rails Designer
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: rails
|
|
@@ -38,8 +37,8 @@ dependencies:
|
|
|
38
37
|
- - ">="
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
39
|
version: '1.3'
|
|
41
|
-
description: Rails Vault
|
|
42
|
-
|
|
40
|
+
description: Rails Vault adds settings and preferences to ActiveRecord models. The
|
|
41
|
+
settings are stored as JSON in a separate table.
|
|
43
42
|
email:
|
|
44
43
|
- devs@railsdesigner.com
|
|
45
44
|
executables: []
|
|
@@ -54,9 +53,10 @@ files:
|
|
|
54
53
|
- bin/release
|
|
55
54
|
- bin/setup
|
|
56
55
|
- db/migrate/20241128150951_create_rails_vaults.rb
|
|
57
|
-
- lib/generators/rails_vault/add_generator.rb
|
|
58
56
|
- lib/generators/rails_vault/install_generator.rb
|
|
59
|
-
- lib/generators/
|
|
57
|
+
- lib/generators/templates/vault.rb.tt
|
|
58
|
+
- lib/generators/vault_generator.rb
|
|
59
|
+
- lib/generators/vault_templates.rb
|
|
60
60
|
- lib/rails_vault.rb
|
|
61
61
|
- lib/rails_vault/base.rb
|
|
62
62
|
- lib/rails_vault/engine.rb
|
|
@@ -69,7 +69,6 @@ licenses:
|
|
|
69
69
|
metadata:
|
|
70
70
|
homepage_uri: https://railsdesigner.com/rails-vault/
|
|
71
71
|
source_code_uri: https://github.com/Rails-Designer/rails_vault/
|
|
72
|
-
post_install_message:
|
|
73
72
|
rdoc_options: []
|
|
74
73
|
require_paths:
|
|
75
74
|
- lib
|
|
@@ -84,8 +83,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
84
83
|
- !ruby/object:Gem::Version
|
|
85
84
|
version: '0'
|
|
86
85
|
requirements: []
|
|
87
|
-
rubygems_version: 3.
|
|
88
|
-
signing_key:
|
|
86
|
+
rubygems_version: 3.6.7
|
|
89
87
|
specification_version: 4
|
|
90
|
-
summary: Simple and easy to add settings, preferences and so on to any
|
|
88
|
+
summary: Simple and easy to add settings, preferences and so on to any ActiveRecord
|
|
89
|
+
model.
|
|
91
90
|
test_files: []
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "rails/generators/named_base"
|
|
4
|
-
|
|
5
|
-
module RailsVault
|
|
6
|
-
module Generators
|
|
7
|
-
class AddGenerator < Rails::Generators::NamedBase
|
|
8
|
-
source_root File.expand_path("../templates", __FILE__)
|
|
9
|
-
|
|
10
|
-
argument :attributes, type: :array, default: [], banner: "field:type field:type"
|
|
11
|
-
|
|
12
|
-
def create_vault_file
|
|
13
|
-
template "vault.rb", File.join("app/models", class_path, "#{file_name}.rb")
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def inject_vault_into_model
|
|
17
|
-
parent_class = class_name.split("::").first
|
|
18
|
-
|
|
19
|
-
inject_into_class "app/models/#{class_path.join("/")}.rb", parent_class do
|
|
20
|
-
" vault :#{plural_name}\n"
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|