formatic 0.1.9 → 0.1.11
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/README.md +8 -2
- data/app/components/formatic/base.rb +2 -0
- data/app/components/formatic/wrapper.rb +2 -0
- data/lib/formatic/version.rb +1 -1
- data/lib/formatic/wrappers/required.rb +10 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3aa59c1de738606890249939bd03ea999d85146596328d3b4cb089c90bcf466
|
4
|
+
data.tar.gz: 19f8a6f0cf613e3bf1820734e100303956600eb3eb4fb8d87c47ee852343f9fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45ec92aca95ef678f972b1c5508fcbd6ddf1480c3ea9be18f954f9df60dc0c9a89510a3f9fedb54c2f24d47bd647d08fa0191af158448556a5797aa3034cdfa8
|
7
|
+
data.tar.gz: e719a1e116ede4bf8224687f0a7ec8c7befba4579f10a0cef2663fe664c326616e68995065dd974ade491eb8043b4be4ca8ad660094d0784524be270220dd322
|
data/README.md
CHANGED
@@ -13,16 +13,22 @@ Opinionated ViewComponents for building forms.
|
|
13
13
|
|
14
14
|
Install the gem and add to the application's Gemfile by executing:
|
15
15
|
|
16
|
-
|
16
|
+
bundle add formatic
|
17
17
|
|
18
18
|
If bundler is not being used to manage dependencies, install the gem by executing:
|
19
19
|
|
20
|
-
|
20
|
+
gem install formatic
|
21
21
|
|
22
22
|
## Development
|
23
23
|
|
24
24
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/ci` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
25
25
|
|
26
|
+
## Testing
|
27
|
+
|
28
|
+
Run one test individually with:
|
29
|
+
|
30
|
+
bundle exec ruby -I test test/lib/wrappers/test_required.rb
|
31
|
+
|
26
32
|
## Contributing
|
27
33
|
|
28
34
|
Bug reports and pull requests are welcome on GitHub at https://github.com/halo/formatic.
|
@@ -32,6 +32,7 @@ module Formatic
|
|
32
32
|
|
33
33
|
# See `Formatic::Wrapper`
|
34
34
|
option :label, default: -> { true }
|
35
|
+
option :hint, optional: true
|
35
36
|
option :label_for_id, optional: true
|
36
37
|
option :readonly, as: :readonly, default: -> { false }
|
37
38
|
option :required, optional: true
|
@@ -42,6 +43,7 @@ module Formatic
|
|
42
43
|
f:,
|
43
44
|
attribute_name:,
|
44
45
|
label:,
|
46
|
+
hint:,
|
45
47
|
required:,
|
46
48
|
prevent_submit_on_enter:,
|
47
49
|
label_for_id:,
|
data/lib/formatic/version.rb
CHANGED
@@ -17,13 +17,22 @@ module Formatic
|
|
17
17
|
return false if manual_required == false
|
18
18
|
return false if validators.empty?
|
19
19
|
|
20
|
-
validators.any? { _1
|
20
|
+
validators.any? { applicable?(_1) }
|
21
21
|
end
|
22
22
|
|
23
|
+
private
|
24
|
+
|
23
25
|
# All applicable validatiors of this attribute.
|
24
26
|
def validators
|
25
27
|
@validators ||= ::Formatic::Wrappers::Validators.call(object:, attribute_name:)
|
26
28
|
end
|
29
|
+
|
30
|
+
def applicable?(validator)
|
31
|
+
validator.options.keys.exclude?(:if) &&
|
32
|
+
validator.options.keys.exclude?(:unless) &&
|
33
|
+
validator.options.keys.exclude?(:on) &&
|
34
|
+
validator.kind == :presence
|
35
|
+
end
|
27
36
|
end
|
28
37
|
end
|
29
38
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formatic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- halo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-04-
|
11
|
+
date: 2025-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|