formtastic_tristate_radio 0.2.4 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6cb90abb9a912c583ace9c1ce3c7fabdf27e3b0b
4
- data.tar.gz: fd220427f9e5d0f573c3533d186c85c47dffd581
2
+ SHA256:
3
+ metadata.gz: 16111918c29fe0d4cb698f6321de6bd6f27c7764b6666b5671550ac9a2d42c28
4
+ data.tar.gz: efa567e0508d0eb6b6c2210f3d070aff8b56dd15c3a8e62a8af202aac8ee507d
5
5
  SHA512:
6
- metadata.gz: 47c7eb5acfd279ce25b9b61216951004aa76c472260d01053ffc91925c2ea078c2428287593e746e62239b984a90b3f3f6f2a299ae2f928024b5702c4e19202f
7
- data.tar.gz: 0f76c972c65fd6d2e1e78b69e7d5b1868345d0a04a3755a7b39719fc9fffc16e7b0fa5776861202d2638ecfa267a5ee1431493576b5d6467fbba2096d95fb0a1
6
+ metadata.gz: 6dbb31774cd0ffcde1568e5c5aa121c2ba1b0c60cc4087e9746de4883423a9e8032a6856bf6c48f163852113205e6f6472c807d200fec00b75cc952f57481eb2
7
+ data.tar.gz: 730bb0a2c35960e993dd5748ec1283d9d204ee8ebeb51d41d1ea62c590327317480c0d4f2d0bc4977b9f2b8e879412725ee990448b710e2af0300faabfa6c125
data/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.7] - 2022-06-10
4
+
5
+ - Corrects load bug introduced in the previous version (probably due to changed loading behavior in Rails)
6
+
7
+ ## [0.2.6] - 2022-06-10
8
+
9
+ - Upgrades dependencies in Gemfile.lock
10
+
11
+ ## [0.2.5] - 2021-11-10
12
+
13
+ - Corrects an error introduced in 0.2.4
14
+ - Moves error-related code into a new module
15
+ - Type-checks the `unset_value` passed into configuration
16
+
17
+ ## [0.2.4] - 2021-11-09
18
+
19
+ - Add translations into most popular languages (although the problem with loading them seems to persist)
20
+
3
21
  ## [0.2.2] - 2021-11-05
4
22
 
5
23
  - Make the gem configurable
data/Gemfile.lock CHANGED
@@ -1,84 +1,91 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- formtastic_tristate_radio (0.2.3)
4
+ formtastic_tristate_radio (0.2.7)
5
5
  formtastic (>= 3, < 5)
6
- rails (>= 4, < 7)
6
+ rails (>= 4, < 8)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actioncable (6.1.4.1)
12
- actionpack (= 6.1.4.1)
13
- activesupport (= 6.1.4.1)
11
+ actioncable (7.0.3)
12
+ actionpack (= 7.0.3)
13
+ activesupport (= 7.0.3)
14
14
  nio4r (~> 2.0)
15
15
  websocket-driver (>= 0.6.1)
16
- actionmailbox (6.1.4.1)
17
- actionpack (= 6.1.4.1)
18
- activejob (= 6.1.4.1)
19
- activerecord (= 6.1.4.1)
20
- activestorage (= 6.1.4.1)
21
- activesupport (= 6.1.4.1)
16
+ actionmailbox (7.0.3)
17
+ actionpack (= 7.0.3)
18
+ activejob (= 7.0.3)
19
+ activerecord (= 7.0.3)
20
+ activestorage (= 7.0.3)
21
+ activesupport (= 7.0.3)
22
22
  mail (>= 2.7.1)
23
- actionmailer (6.1.4.1)
24
- actionpack (= 6.1.4.1)
25
- actionview (= 6.1.4.1)
26
- activejob (= 6.1.4.1)
27
- activesupport (= 6.1.4.1)
23
+ net-imap
24
+ net-pop
25
+ net-smtp
26
+ actionmailer (7.0.3)
27
+ actionpack (= 7.0.3)
28
+ actionview (= 7.0.3)
29
+ activejob (= 7.0.3)
30
+ activesupport (= 7.0.3)
28
31
  mail (~> 2.5, >= 2.5.4)
32
+ net-imap
33
+ net-pop
34
+ net-smtp
29
35
  rails-dom-testing (~> 2.0)
30
- actionpack (6.1.4.1)
31
- actionview (= 6.1.4.1)
32
- activesupport (= 6.1.4.1)
33
- rack (~> 2.0, >= 2.0.9)
36
+ actionpack (7.0.3)
37
+ actionview (= 7.0.3)
38
+ activesupport (= 7.0.3)
39
+ rack (~> 2.0, >= 2.2.0)
34
40
  rack-test (>= 0.6.3)
35
41
  rails-dom-testing (~> 2.0)
36
42
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
37
- actiontext (6.1.4.1)
38
- actionpack (= 6.1.4.1)
39
- activerecord (= 6.1.4.1)
40
- activestorage (= 6.1.4.1)
41
- activesupport (= 6.1.4.1)
43
+ actiontext (7.0.3)
44
+ actionpack (= 7.0.3)
45
+ activerecord (= 7.0.3)
46
+ activestorage (= 7.0.3)
47
+ activesupport (= 7.0.3)
48
+ globalid (>= 0.6.0)
42
49
  nokogiri (>= 1.8.5)
43
- actionview (6.1.4.1)
44
- activesupport (= 6.1.4.1)
50
+ actionview (7.0.3)
51
+ activesupport (= 7.0.3)
45
52
  builder (~> 3.1)
46
53
  erubi (~> 1.4)
47
54
  rails-dom-testing (~> 2.0)
48
55
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
49
- activejob (6.1.4.1)
50
- activesupport (= 6.1.4.1)
56
+ activejob (7.0.3)
57
+ activesupport (= 7.0.3)
51
58
  globalid (>= 0.3.6)
52
- activemodel (6.1.4.1)
53
- activesupport (= 6.1.4.1)
54
- activerecord (6.1.4.1)
55
- activemodel (= 6.1.4.1)
56
- activesupport (= 6.1.4.1)
57
- activestorage (6.1.4.1)
58
- actionpack (= 6.1.4.1)
59
- activejob (= 6.1.4.1)
60
- activerecord (= 6.1.4.1)
61
- activesupport (= 6.1.4.1)
62
- marcel (~> 1.0.0)
59
+ activemodel (7.0.3)
60
+ activesupport (= 7.0.3)
61
+ activerecord (7.0.3)
62
+ activemodel (= 7.0.3)
63
+ activesupport (= 7.0.3)
64
+ activestorage (7.0.3)
65
+ actionpack (= 7.0.3)
66
+ activejob (= 7.0.3)
67
+ activerecord (= 7.0.3)
68
+ activesupport (= 7.0.3)
69
+ marcel (~> 1.0)
63
70
  mini_mime (>= 1.1.0)
64
- activesupport (6.1.4.1)
71
+ activesupport (7.0.3)
65
72
  concurrent-ruby (~> 1.0, >= 1.0.2)
66
73
  i18n (>= 1.6, < 2)
67
74
  minitest (>= 5.1)
68
75
  tzinfo (~> 2.0)
69
- zeitwerk (~> 2.3)
70
76
  builder (3.2.4)
71
- concurrent-ruby (1.1.9)
77
+ concurrent-ruby (1.1.10)
72
78
  crass (1.0.6)
73
- diff-lcs (1.4.4)
79
+ diff-lcs (1.5.0)
80
+ digest (3.1.0)
74
81
  erubi (1.10.0)
75
82
  formtastic (4.0.0)
76
83
  actionpack (>= 5.2.0)
77
- globalid (0.5.2)
84
+ globalid (1.0.0)
78
85
  activesupport (>= 5.0)
79
- i18n (1.8.11)
86
+ i18n (1.10.0)
80
87
  concurrent-ruby (~> 1.0)
81
- loofah (2.12.0)
88
+ loofah (2.18.0)
82
89
  crass (~> 1.0.2)
83
90
  nokogiri (>= 1.5.9)
84
91
  mail (2.7.1)
@@ -86,72 +93,83 @@ GEM
86
93
  marcel (1.0.2)
87
94
  method_source (1.0.0)
88
95
  mini_mime (1.1.2)
89
- minitest (5.14.4)
96
+ minitest (5.15.0)
97
+ net-imap (0.2.3)
98
+ digest
99
+ net-protocol
100
+ strscan
101
+ net-pop (0.1.1)
102
+ digest
103
+ net-protocol
104
+ timeout
105
+ net-protocol (0.1.3)
106
+ timeout
107
+ net-smtp (0.3.1)
108
+ digest
109
+ net-protocol
110
+ timeout
90
111
  nio4r (2.5.8)
91
- nokogiri (1.12.5-x86_64-darwin)
112
+ nokogiri (1.13.6-arm64-darwin)
92
113
  racc (~> 1.4)
93
114
  racc (1.6.0)
94
- rack (2.2.3)
115
+ rack (2.2.3.1)
95
116
  rack-test (1.1.0)
96
117
  rack (>= 1.0, < 3)
97
- rails (6.1.4.1)
98
- actioncable (= 6.1.4.1)
99
- actionmailbox (= 6.1.4.1)
100
- actionmailer (= 6.1.4.1)
101
- actionpack (= 6.1.4.1)
102
- actiontext (= 6.1.4.1)
103
- actionview (= 6.1.4.1)
104
- activejob (= 6.1.4.1)
105
- activemodel (= 6.1.4.1)
106
- activerecord (= 6.1.4.1)
107
- activestorage (= 6.1.4.1)
108
- activesupport (= 6.1.4.1)
118
+ rails (7.0.3)
119
+ actioncable (= 7.0.3)
120
+ actionmailbox (= 7.0.3)
121
+ actionmailer (= 7.0.3)
122
+ actionpack (= 7.0.3)
123
+ actiontext (= 7.0.3)
124
+ actionview (= 7.0.3)
125
+ activejob (= 7.0.3)
126
+ activemodel (= 7.0.3)
127
+ activerecord (= 7.0.3)
128
+ activestorage (= 7.0.3)
129
+ activesupport (= 7.0.3)
109
130
  bundler (>= 1.15.0)
110
- railties (= 6.1.4.1)
111
- sprockets-rails (>= 2.0.0)
131
+ railties (= 7.0.3)
112
132
  rails-dom-testing (2.0.3)
113
133
  activesupport (>= 4.2.0)
114
134
  nokogiri (>= 1.6)
115
- rails-html-sanitizer (1.4.2)
135
+ rails-html-sanitizer (1.4.3)
116
136
  loofah (~> 2.3)
117
- railties (6.1.4.1)
118
- actionpack (= 6.1.4.1)
119
- activesupport (= 6.1.4.1)
137
+ railties (7.0.3)
138
+ actionpack (= 7.0.3)
139
+ activesupport (= 7.0.3)
120
140
  method_source
121
- rake (>= 0.13)
141
+ rake (>= 12.2)
122
142
  thor (~> 1.0)
143
+ zeitwerk (~> 2.5)
123
144
  rake (13.0.6)
124
- rspec (3.10.0)
125
- rspec-core (~> 3.10.0)
126
- rspec-expectations (~> 3.10.0)
127
- rspec-mocks (~> 3.10.0)
128
- rspec-core (3.10.1)
129
- rspec-support (~> 3.10.0)
130
- rspec-expectations (3.10.1)
145
+ rspec (3.11.0)
146
+ rspec-core (~> 3.11.0)
147
+ rspec-expectations (~> 3.11.0)
148
+ rspec-mocks (~> 3.11.0)
149
+ rspec-core (3.11.0)
150
+ rspec-support (~> 3.11.0)
151
+ rspec-expectations (3.11.0)
131
152
  diff-lcs (>= 1.2.0, < 2.0)
132
- rspec-support (~> 3.10.0)
133
- rspec-mocks (3.10.2)
153
+ rspec-support (~> 3.11.0)
154
+ rspec-mocks (3.11.1)
134
155
  diff-lcs (>= 1.2.0, < 2.0)
135
- rspec-support (~> 3.10.0)
136
- rspec-support (3.10.3)
137
- sprockets (4.0.2)
138
- concurrent-ruby (~> 1.0)
139
- rack (> 1, < 3)
140
- sprockets-rails (3.2.2)
141
- actionpack (>= 4.0)
142
- activesupport (>= 4.0)
143
- sprockets (>= 3.0.0)
144
- thor (1.1.0)
156
+ rspec-support (~> 3.11.0)
157
+ rspec-support (3.11.0)
158
+ strscan (3.0.3)
159
+ thor (1.2.1)
160
+ timeout (0.3.0)
145
161
  tzinfo (2.0.4)
146
162
  concurrent-ruby (~> 1.0)
163
+ webrick (1.7.0)
147
164
  websocket-driver (0.7.5)
148
165
  websocket-extensions (>= 0.1.0)
149
166
  websocket-extensions (0.1.5)
150
- yard (0.9.26)
151
- zeitwerk (2.5.1)
167
+ yard (0.9.28)
168
+ webrick (~> 1.7.0)
169
+ zeitwerk (2.5.4)
152
170
 
153
171
  PLATFORMS
154
- x86_64-darwin-17
172
+ arm64-darwin-21
155
173
 
156
174
  DEPENDENCIES
157
175
  formtastic_tristate_radio!
@@ -159,4 +177,4 @@ DEPENDENCIES
159
177
  yard (>= 0.9.20, < 1)
160
178
 
161
179
  BUNDLED WITH
162
- 2.2.27
180
+ 2.3.15
data/README.md CHANGED
@@ -62,7 +62,7 @@ ru:
62
62
  null: Неизвестно # <- this you must provide youself
63
63
  ```
64
64
 
65
- As noted in [Usage](#usage), you can override individual translations like so:
65
+ You can override individual translations like so:
66
66
 
67
67
  ```ruby
68
68
  f.input :attribute, as: :tristate_radio, null: "Your text"
@@ -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 [StandardError] if the translation could not be found
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
 
@@ -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`. See “[How it works](#how-it-works)” ☟ section for technical details on this.
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
@@ -43,7 +43,7 @@ Gem::Specification.new do |spec|
43
43
  spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
44
44
 
45
45
  spec.add_dependency "formtastic", ">= 3", "< 5"
46
- spec.add_dependency "rails", ">= 4", "< 7"
46
+ spec.add_dependency "rails", ">= 4", "< 8"
47
47
 
48
48
  spec.add_development_dependency "rspec", "~> 3"
49
49
  spec.add_development_dependency "yard", ">= 0.9.20", "< 1"
@@ -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 URL https://github.com/ruby-i18n/i18n/blob/master/lib/i18n/exceptions.rb#L63 Original I18n method
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 = []
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FormtasticTristateRadio
4
- VERSION = "0.2.4"
4
+ VERSION = "0.2.7"
5
5
  end
@@ -3,5 +3,6 @@ require_relative "formtastic_tristate_radio/configuration"
3
3
  require_relative "formtastic_tristate_radio/i18n/error"
4
4
  require_relative "formtastic_tristate_radio/engine"
5
5
  require_relative "../app/models/active_record/base"
6
+ require_relative "../app/inputs/tristate_radio_input"
6
7
 
7
8
  module FormtasticTristateRadio; end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: formtastic_tristate_radio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Pedan
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-09 00:00:00.000000000 Z
11
+ date: 2022-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: formtastic
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: '4'
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
- version: '7'
42
+ version: '8'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,7 +49,7 @@ dependencies:
49
49
  version: '4'
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: '7'
52
+ version: '8'
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: rspec
55
55
  requirement: !ruby/object:Gem::Requirement
@@ -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`. See “[How it works](#how-it-works)” ☟ section for technical details on this.
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:
@@ -124,7 +124,7 @@ metadata:
124
124
  documentation_uri: https://www.rubydoc.info/gems/formtastic_tristate_radio
125
125
  homepage_uri: https://github.com/sergeypedan/formtastic-tristate-radio
126
126
  source_code_uri: https://github.com/sergeypedan/formtastic-tristate-radio
127
- post_install_message:
127
+ post_install_message:
128
128
  rdoc_options:
129
129
  - "--charset=UTF-8"
130
130
  require_paths:
@@ -144,9 +144,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  requirements: []
147
- rubyforge_project:
148
- rubygems_version: 2.5.2.3
149
- signing_key:
147
+ rubygems_version: 3.3.7
148
+ signing_key:
150
149
  specification_version: 4
151
150
  summary: Have 3-state radiobuttons instead of a 2-state checkbox for your Boolean
152
151
  columns which can store NULL