formtastic_tristate_radio 0.2.4 → 0.2.5
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/CHANGELOG.md +10 -0
- data/README.md +1 -1
- data/app/inputs/tristate_radio_input.rb +2 -3
- data/formtastic_tristate_radio-0.2.4.gem +0 -0
- data/formtastic_tristate_radio.gemspec +1 -1
- data/lib/formtastic_tristate_radio/configuration.rb +19 -1
- data/lib/formtastic_tristate_radio/engine.rb +1 -1
- data/lib/formtastic_tristate_radio/i18n/error.rb +1 -1
- data/lib/formtastic_tristate_radio/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b26a9dab6e7233cd6a694dc88f59d08f6d47263c900abfc07416679a87f7c974
|
4
|
+
data.tar.gz: 0a399b71d713ce0f4488f1f7461694d824d43c8f0f42db848daf4c0ad2caa0db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0339d723213d63e7355ca4c50f120f6b08b22d406ba042ad47a89414708d4e07a1748dfa6d530190d2ca45ffd5dff0402779d53a225d9af80449c86b90d85a88'
|
7
|
+
data.tar.gz: b36093c5c3207e2375adb7c80769f890ac3b433c178128add4fa0d24ebd68aff11c5421b783213ff4d3e25d0f3603bf3b49ab8f794475f958e6aa909c879a088
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [0.2.5] - 2021-11-10
|
4
|
+
|
5
|
+
- Corrects an error introduced in 0.2.4
|
6
|
+
- Moves error-related code into a new module
|
7
|
+
- Type-checks the `unset_value` passed into configuration
|
8
|
+
|
9
|
+
## [0.2.4] - 2021-11-09
|
10
|
+
|
11
|
+
- Add translations into most popular languages (although the problem with loading them seems to persist)
|
12
|
+
|
3
13
|
## [0.2.2] - 2021-11-05
|
4
14
|
|
5
15
|
- Make the gem configurable
|
data/README.md
CHANGED
@@ -190,8 +190,8 @@ ActiveModel::Type::Boolean.new.cast(:nil) #=> nil
|
|
190
190
|
- [ ] Remove `require_relative "../app/models/active_record/base"` from main file
|
191
191
|
- [x] Make the gem configurable
|
192
192
|
- [x] Pull the key used for “unset” choice value into configuration
|
193
|
+
- [x] Add translations into most popular languages
|
193
194
|
- [ ] Load translations from gem
|
194
|
-
- [ ] Add translations into most popular languages
|
195
195
|
- [ ] Rgister `:tristate_radio` for Boolean columns with `null`
|
196
196
|
- [ ] Decouple `ActiveModel::Type::Boolean` thing from Formtastic things, maybe into a separate gem
|
197
197
|
- [ ] Decouple from Rails
|
@@ -52,11 +52,10 @@ class TristateRadioInput < Formtastic::Inputs::RadioInput
|
|
52
52
|
#
|
53
53
|
# @return [String] Label of the radio that stands for the unknown choice
|
54
54
|
#
|
55
|
-
# @raise [
|
56
|
-
# @see missing_i18n_error_msg
|
55
|
+
# @raise [FormtasticTristateRadio::I18n::Error] if the translation could not be found
|
57
56
|
#
|
58
57
|
def label_text_for_unset
|
59
|
-
options.fetch(:null, Formtastic::I18n.t(UNSET_KEY)).presence or fail FormtasticTristateRadio::I18n::Error.new(locale, UNSET_KEY)
|
58
|
+
options.fetch(:null, Formtastic::I18n.t(UNSET_KEY)).presence or fail FormtasticTristateRadio::I18n::Error.new(I18n.locale, UNSET_KEY)
|
60
59
|
end
|
61
60
|
|
62
61
|
|
Binary file
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.description = <<~HEREDOC
|
19
19
|
#{spec.summary}. This gem:
|
20
20
|
1. Provides a custom Formtastic input type `:tristate_radio` which renders 3 radios (“Yes”, “No”, “Unset”) instead of a checkbox (only where you put it).
|
21
|
-
2. Teaches Rails recognize `"null"` and `"nil"` param values as `nil
|
21
|
+
2. Teaches Rails recognize `"null"` and `"nil"` param values as `nil`
|
22
22
|
3. Encourages you to add translations for ActiveAdmin “status tag” so that `nil` be correctly translated as “Unset” instead of “False”.
|
23
23
|
Does not change controls, you need to turn it on via `as: :tristate_radio` option.
|
24
24
|
HEREDOC
|
@@ -14,12 +14,30 @@ module FormtasticTristateRadio
|
|
14
14
|
yield(config)
|
15
15
|
end
|
16
16
|
|
17
|
+
# Configuration block pattern
|
18
|
+
#
|
19
|
+
# @see https://thoughtbot.com/blog/mygem-configure-block
|
20
|
+
# @see https://brandonhilkert.com/blog/ruby-gem-configuration-patterns/
|
21
|
+
#
|
17
22
|
class Configuration
|
18
|
-
attr_accessor :unset_key
|
19
23
|
|
20
24
|
def initialize
|
21
25
|
@unset_key = :null
|
22
26
|
end
|
27
|
+
|
28
|
+
# @!attribute [r] unset_key
|
29
|
+
# @return [Symbol, String] the value of <var>@unset_key</var>
|
30
|
+
#
|
31
|
+
attr_reader :unset_key
|
32
|
+
|
33
|
+
# @return [Symbol, String, Integer] value that was passed into the method
|
34
|
+
#
|
35
|
+
# @raise [TypeError] because no other types seem to make sence here
|
36
|
+
#
|
37
|
+
def unset_key=(value)
|
38
|
+
fail TypeError, "`unset_key` must be a Symbol, String or Integer" unless [Symbol, String, Integer].include? value.class
|
39
|
+
@unset_key = value
|
40
|
+
end
|
23
41
|
end
|
24
42
|
|
25
43
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module FormtasticTristateRadio
|
4
4
|
|
5
5
|
# This is standard Rails way to autoload gem’s contents dynamically as an “engine”
|
6
|
-
# https://guides.rubyonrails.org/engines.html
|
6
|
+
# @see https://guides.rubyonrails.org/engines.html Rails guide on engines
|
7
7
|
#
|
8
8
|
class Engine < ::Rails::Engine
|
9
9
|
end
|
@@ -27,7 +27,7 @@ module FormtasticTristateRadio
|
|
27
27
|
#
|
28
28
|
# @return [String] error message with YAML examples for the “unset” label translation lookup error
|
29
29
|
#
|
30
|
-
# @see
|
30
|
+
# @see https://github.com/ruby-i18n/i18n/blob/master/lib/i18n/exceptions.rb#L63 Original I18n method
|
31
31
|
#
|
32
32
|
def message
|
33
33
|
msg = []
|
metadata
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formtastic_tristate_radio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Pedan
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
11
|
date: 2021-11-09 00:00:00.000000000 Z
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
description: |
|
88
88
|
Have 3-state radiobuttons instead of a 2-state checkbox for your Boolean columns which can store NULL. This gem:
|
89
89
|
1. Provides a custom Formtastic input type `:tristate_radio` which renders 3 radios (“Yes”, “No”, “Unset”) instead of a checkbox (only where you put it).
|
90
|
-
2. Teaches Rails recognize `"null"` and `"nil"` param values as `nil
|
90
|
+
2. Teaches Rails recognize `"null"` and `"nil"` param values as `nil`
|
91
91
|
3. Encourages you to add translations for ActiveAdmin “status tag” so that `nil` be correctly translated as “Unset” instead of “False”.
|
92
92
|
Does not change controls, you need to turn it on via `as: :tristate_radio` option.
|
93
93
|
email:
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- config/locales/active_admin.yml
|
111
111
|
- config/locales/formtastic.yml
|
112
112
|
- config/routes.rb
|
113
|
+
- formtastic_tristate_radio-0.2.4.gem
|
113
114
|
- formtastic_tristate_radio.gemspec
|
114
115
|
- lib/formtastic_tristate_radio.rb
|
115
116
|
- lib/formtastic_tristate_radio/configuration.rb
|
@@ -124,7 +125,7 @@ metadata:
|
|
124
125
|
documentation_uri: https://www.rubydoc.info/gems/formtastic_tristate_radio
|
125
126
|
homepage_uri: https://github.com/sergeypedan/formtastic-tristate-radio
|
126
127
|
source_code_uri: https://github.com/sergeypedan/formtastic-tristate-radio
|
127
|
-
post_install_message:
|
128
|
+
post_install_message:
|
128
129
|
rdoc_options:
|
129
130
|
- "--charset=UTF-8"
|
130
131
|
require_paths:
|
@@ -144,9 +145,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
145
|
- !ruby/object:Gem::Version
|
145
146
|
version: '0'
|
146
147
|
requirements: []
|
147
|
-
|
148
|
-
|
149
|
-
signing_key:
|
148
|
+
rubygems_version: 3.2.15
|
149
|
+
signing_key:
|
150
150
|
specification_version: 4
|
151
151
|
summary: Have 3-state radiobuttons instead of a 2-state checkbox for your Boolean
|
152
152
|
columns which can store NULL
|