formalism 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -1
- data/README.md +16 -0
- data/lib/formalism/form/coercion/_numeric.rb +1 -1
- data/lib/formalism/form/coercion.rb +1 -1
- data/lib/formalism/form/fields.rb +22 -8
- data/lib/formalism/form/filling.rb +1 -1
- data/lib/formalism/form/validation_error.rb +1 -1
- data/lib/formalism/form.rb +3 -0
- data/lib/formalism/version.rb +1 -1
- metadata +7 -164
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e4d832e0f29d4c483ca8abde0e9cda368ecc7780ab3486bbff2d2436acf3683
|
4
|
+
data.tar.gz: e3d4f0eca76bffa706c658644d4e612d3a11122a933c203b39b418bac1bae2ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cc302ffffc7acb362dab453f56cf96bd669845b8f8cf74acfd0e8c268cb76f5599872a039e62430dc4945500b74570ce35963808a7ae48d057eeb5f9643984f
|
7
|
+
data.tar.gz: 016edfd06e2f810efac6a14325d75ea4c81ccae1bbcac93cf6cdd2c8c98555e9ea4ab3053c8948168b1770b5afbc96ce064e2f56764ce7ecac43d76edebeaa70
|
data/CHANGELOG.md
CHANGED
@@ -2,9 +2,20 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## 0.6.0 (2025-01-06)
|
6
|
+
|
7
|
+
* Drop Ruby 2.6 and 2.7 support.
|
8
|
+
* Add Ruby 3.2, 3.3 and 3.4 support.
|
9
|
+
* Lock Ruby version more strict.
|
10
|
+
There can be breaking changes in minor updates.
|
11
|
+
* Improve documentation.
|
12
|
+
* Update development dependencies.
|
13
|
+
* Resolve new offenses from RuboCop.
|
14
|
+
* Move development dependencies from `gemspec` into `Gemfile`.
|
15
|
+
|
5
16
|
## 0.5.1 (2022-09-24)
|
6
17
|
|
7
|
-
*
|
18
|
+
* Allow `gorilla_patch` version 5.
|
8
19
|
|
9
20
|
## 0.5.0 (2022-09-24)
|
10
21
|
|
data/README.md
CHANGED
@@ -289,6 +289,22 @@ form.to_params
|
|
289
289
|
For actions without fields, nesting and validation you can use
|
290
290
|
`Formalism::Action` (the parent of `Formalism::Form`).
|
291
291
|
|
292
|
+
|
293
|
+
### Plugins
|
294
|
+
|
295
|
+
There is a few plugins which I personally need for:
|
296
|
+
|
297
|
+
* [`formalism-model_forms`](https://github.com/AlexWayfer/formalism-model_forms)
|
298
|
+
Default CRUD forms for [Sequel](https://sequel.jeremyevans.net/) DB models.
|
299
|
+
Can be renamed!
|
300
|
+
|
301
|
+
* [`formalism-sequel_transactions`](https://github.com/AlexWayfer/formalism-sequel_transactions)
|
302
|
+
[Sequel](https://sequel.jeremyevans.net/) transactions inside forms.
|
303
|
+
|
304
|
+
* [`formalism-r18n_errors`](https://github.com/AlexWayfer/formalism-r18n_errors)
|
305
|
+
[R18n](https://github.com/r18n/r18n) errors inside forms, including validation helpers.
|
306
|
+
Can be separated!
|
307
|
+
|
292
308
|
## Development
|
293
309
|
|
294
310
|
After checking out the repo, run `bundle install` to install dependencies.
|
@@ -52,7 +52,7 @@ module Formalism
|
|
52
52
|
fields_and_nested_forms.delete name
|
53
53
|
|
54
54
|
undef_method name
|
55
|
-
undef_method "#{name}="
|
55
|
+
undef_method :"#{name}="
|
56
56
|
end
|
57
57
|
|
58
58
|
def define_field_methods(name)
|
@@ -61,18 +61,31 @@ module Formalism
|
|
61
61
|
|
62
62
|
private
|
63
63
|
|
64
|
-
define_method
|
64
|
+
define_method :"#{name}=" do |value|
|
65
65
|
options = self.class.fields_and_nested_forms[name]
|
66
|
-
coerced_value =
|
67
|
-
Coercion.new(*options.values_at(:type, :of)).result_for(value)
|
66
|
+
coerced_value = Coercion.new(*options.values_at(:type, :of)).result_for(value)
|
68
67
|
fields[name] = coerced_value
|
69
68
|
end
|
70
69
|
end
|
70
|
+
|
71
|
+
reset_undefined_field_methods(name)
|
72
|
+
end
|
73
|
+
|
74
|
+
def reset_undefined_field_methods(name)
|
75
|
+
class_exec do
|
76
|
+
define_method(name) { super() }
|
77
|
+
remove_method name
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
define_method(:"#{name}=") { |value| super(value) }
|
82
|
+
remove_method :"#{name}="
|
83
|
+
end
|
71
84
|
end
|
72
85
|
|
73
86
|
def define_nested_form_methods(name)
|
74
87
|
module_for_accessors.instance_exec do
|
75
|
-
define_method("#{name}_form") { nested_forms[name] }
|
88
|
+
define_method(:"#{name}_form") { nested_forms[name] }
|
76
89
|
|
77
90
|
define_method(name) { nested_forms[name].instance }
|
78
91
|
end
|
@@ -83,13 +96,14 @@ module Formalism
|
|
83
96
|
def define_params_for_nested_method(name)
|
84
97
|
params_method_name = "params_for_nested_#{name}"
|
85
98
|
params_method_defined =
|
86
|
-
method_defined?(params_method_name) ||
|
87
|
-
|
99
|
+
method_defined?(params_method_name) || private_method_defined?(params_method_name)
|
100
|
+
|
101
|
+
return if params_method_defined
|
88
102
|
|
89
103
|
module_for_accessors.instance_exec do
|
90
104
|
private
|
91
105
|
|
92
|
-
define_method(params_method_name) { @params[name] }
|
106
|
+
define_method(params_method_name) { @params[name] }
|
93
107
|
end
|
94
108
|
end
|
95
109
|
|
@@ -72,7 +72,7 @@ module Formalism
|
|
72
72
|
|
73
73
|
def args_for_nested_form(name, options)
|
74
74
|
if @params.key?(name)
|
75
|
-
[send("params_for_nested_#{name}")]
|
75
|
+
[send(:"params_for_nested_#{name}")]
|
76
76
|
elsif instance_respond_to?(name)
|
77
77
|
[instance_public_send(name)]
|
78
78
|
elsif options.key?(:default)
|
data/lib/formalism/form.rb
CHANGED
@@ -32,7 +32,10 @@ module Formalism
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def valid?
|
35
|
+
## https://github.com/rubocop/rubocop/pull/11967#issuecomment-1605561645
|
36
|
+
# rubocop:disable Style/ReturnNilInPredicateMethodDefinition
|
35
37
|
return unless runnable
|
38
|
+
# rubocop:enable Style/ReturnNilInPredicateMethodDefinition
|
36
39
|
|
37
40
|
errors.clear
|
38
41
|
|
data/lib/formalism/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formalism
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Popov
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-01-06 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: gorilla_patch
|
@@ -44,160 +43,6 @@ dependencies:
|
|
44
43
|
- - "~>"
|
45
44
|
- !ruby/object:Gem::Version
|
46
45
|
version: 0.1.0
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: pry-byebug
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - "~>"
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '3.9'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - "~>"
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '3.9'
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: bundler
|
63
|
-
requirement: !ruby/object:Gem::Requirement
|
64
|
-
requirements:
|
65
|
-
- - "~>"
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: '2.0'
|
68
|
-
type: :development
|
69
|
-
prerelease: false
|
70
|
-
version_requirements: !ruby/object:Gem::Requirement
|
71
|
-
requirements:
|
72
|
-
- - "~>"
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: '2.0'
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
|
-
name: bundler-audit
|
77
|
-
requirement: !ruby/object:Gem::Requirement
|
78
|
-
requirements:
|
79
|
-
- - "~>"
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: 0.9.0
|
82
|
-
type: :development
|
83
|
-
prerelease: false
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
85
|
-
requirements:
|
86
|
-
- - "~>"
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: 0.9.0
|
89
|
-
- !ruby/object:Gem::Dependency
|
90
|
-
name: gem_toys
|
91
|
-
requirement: !ruby/object:Gem::Requirement
|
92
|
-
requirements:
|
93
|
-
- - "~>"
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version: 0.12.1
|
96
|
-
type: :development
|
97
|
-
prerelease: false
|
98
|
-
version_requirements: !ruby/object:Gem::Requirement
|
99
|
-
requirements:
|
100
|
-
- - "~>"
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: 0.12.1
|
103
|
-
- !ruby/object:Gem::Dependency
|
104
|
-
name: toys
|
105
|
-
requirement: !ruby/object:Gem::Requirement
|
106
|
-
requirements:
|
107
|
-
- - "~>"
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: 0.13.0
|
110
|
-
type: :development
|
111
|
-
prerelease: false
|
112
|
-
version_requirements: !ruby/object:Gem::Requirement
|
113
|
-
requirements:
|
114
|
-
- - "~>"
|
115
|
-
- !ruby/object:Gem::Version
|
116
|
-
version: 0.13.0
|
117
|
-
- !ruby/object:Gem::Dependency
|
118
|
-
name: rspec
|
119
|
-
requirement: !ruby/object:Gem::Requirement
|
120
|
-
requirements:
|
121
|
-
- - "~>"
|
122
|
-
- !ruby/object:Gem::Version
|
123
|
-
version: '3.9'
|
124
|
-
type: :development
|
125
|
-
prerelease: false
|
126
|
-
version_requirements: !ruby/object:Gem::Requirement
|
127
|
-
requirements:
|
128
|
-
- - "~>"
|
129
|
-
- !ruby/object:Gem::Version
|
130
|
-
version: '3.9'
|
131
|
-
- !ruby/object:Gem::Dependency
|
132
|
-
name: simplecov
|
133
|
-
requirement: !ruby/object:Gem::Requirement
|
134
|
-
requirements:
|
135
|
-
- - "~>"
|
136
|
-
- !ruby/object:Gem::Version
|
137
|
-
version: 0.21.2
|
138
|
-
type: :development
|
139
|
-
prerelease: false
|
140
|
-
version_requirements: !ruby/object:Gem::Requirement
|
141
|
-
requirements:
|
142
|
-
- - "~>"
|
143
|
-
- !ruby/object:Gem::Version
|
144
|
-
version: 0.21.2
|
145
|
-
- !ruby/object:Gem::Dependency
|
146
|
-
name: simplecov-cobertura
|
147
|
-
requirement: !ruby/object:Gem::Requirement
|
148
|
-
requirements:
|
149
|
-
- - "~>"
|
150
|
-
- !ruby/object:Gem::Version
|
151
|
-
version: '2.1'
|
152
|
-
type: :development
|
153
|
-
prerelease: false
|
154
|
-
version_requirements: !ruby/object:Gem::Requirement
|
155
|
-
requirements:
|
156
|
-
- - "~>"
|
157
|
-
- !ruby/object:Gem::Version
|
158
|
-
version: '2.1'
|
159
|
-
- !ruby/object:Gem::Dependency
|
160
|
-
name: rubocop
|
161
|
-
requirement: !ruby/object:Gem::Requirement
|
162
|
-
requirements:
|
163
|
-
- - "~>"
|
164
|
-
- !ruby/object:Gem::Version
|
165
|
-
version: 1.36.0
|
166
|
-
type: :development
|
167
|
-
prerelease: false
|
168
|
-
version_requirements: !ruby/object:Gem::Requirement
|
169
|
-
requirements:
|
170
|
-
- - "~>"
|
171
|
-
- !ruby/object:Gem::Version
|
172
|
-
version: 1.36.0
|
173
|
-
- !ruby/object:Gem::Dependency
|
174
|
-
name: rubocop-performance
|
175
|
-
requirement: !ruby/object:Gem::Requirement
|
176
|
-
requirements:
|
177
|
-
- - "~>"
|
178
|
-
- !ruby/object:Gem::Version
|
179
|
-
version: '1.0'
|
180
|
-
type: :development
|
181
|
-
prerelease: false
|
182
|
-
version_requirements: !ruby/object:Gem::Requirement
|
183
|
-
requirements:
|
184
|
-
- - "~>"
|
185
|
-
- !ruby/object:Gem::Version
|
186
|
-
version: '1.0'
|
187
|
-
- !ruby/object:Gem::Dependency
|
188
|
-
name: rubocop-rspec
|
189
|
-
requirement: !ruby/object:Gem::Requirement
|
190
|
-
requirements:
|
191
|
-
- - "~>"
|
192
|
-
- !ruby/object:Gem::Version
|
193
|
-
version: '2.0'
|
194
|
-
type: :development
|
195
|
-
prerelease: false
|
196
|
-
version_requirements: !ruby/object:Gem::Requirement
|
197
|
-
requirements:
|
198
|
-
- - "~>"
|
199
|
-
- !ruby/object:Gem::Version
|
200
|
-
version: '2.0'
|
201
46
|
description: 'Simple actions and complex forms with validations, nesting, etc.
|
202
47
|
|
203
48
|
'
|
@@ -237,13 +82,12 @@ licenses:
|
|
237
82
|
- MIT
|
238
83
|
metadata:
|
239
84
|
bug_tracker_uri: https://github.com/AlexWayfer/formalism/issues
|
240
|
-
changelog_uri: https://github.com/AlexWayfer/formalism/blob/v0.
|
241
|
-
documentation_uri: http://www.rubydoc.info/gems/formalism/0.
|
85
|
+
changelog_uri: https://github.com/AlexWayfer/formalism/blob/v0.6.0/CHANGELOG.md
|
86
|
+
documentation_uri: http://www.rubydoc.info/gems/formalism/0.6.0
|
242
87
|
homepage_uri: https://github.com/AlexWayfer/formalism
|
243
88
|
rubygems_mfa_required: 'true'
|
244
89
|
source_code_uri: https://github.com/AlexWayfer/formalism
|
245
90
|
wiki_uri: https://github.com/AlexWayfer/formalism/wiki
|
246
|
-
post_install_message:
|
247
91
|
rdoc_options: []
|
248
92
|
require_paths:
|
249
93
|
- lib
|
@@ -251,18 +95,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
251
95
|
requirements:
|
252
96
|
- - ">="
|
253
97
|
- !ruby/object:Gem::Version
|
254
|
-
version: '
|
98
|
+
version: '3.0'
|
255
99
|
- - "<"
|
256
100
|
- !ruby/object:Gem::Version
|
257
|
-
version: '
|
101
|
+
version: '3.5'
|
258
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
259
103
|
requirements:
|
260
104
|
- - ">="
|
261
105
|
- !ruby/object:Gem::Version
|
262
106
|
version: '0'
|
263
107
|
requirements: []
|
264
|
-
rubygems_version: 3.
|
265
|
-
signing_key:
|
108
|
+
rubygems_version: 3.6.2
|
266
109
|
specification_version: 4
|
267
110
|
summary: Forms with input data validations and nesting
|
268
111
|
test_files: []
|