deco_lite 1.5.2 → 1.5.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b7c43249616f91c50aa1452769ec55d957ff8dd280823202bcae9c35d64cf036
4
- data.tar.gz: 0e99b572d6e8a8d4f1c0070a9a24f76acf5b0d31b9fa89af2fc87da5cccbe2a2
3
+ metadata.gz: c4ef46454894f50d482c367ec123ad7d917ffd881ed049d3f1e19b76af40c1d8
4
+ data.tar.gz: 30d3b18a200c2bac48f522ce2d81503a92ecd833182a29f769b170b1d31e6429
5
5
  SHA512:
6
- metadata.gz: ff288dbc7abe43674ce30bf7008346151ea486cbbaf1ebf43852ae47cf1a8dc5d723ddc7b04355f96b8762f29a0aa8521951ed1834e58d33e30e9b6ae074a198
7
- data.tar.gz: 393764155f69b9e73e19581d53c0020dc65f01052cd62e577d78bf10499f4ca804129cd39582df018d523957873966ae6922b4c8b90b51e727c670e86f89e260
6
+ metadata.gz: 98261afe547fd112944482847039be47b975eafc4616b6f3c4bba5f1891cbb7e871481602d97fad0d1ffd94e7d8bf4c10f50a614b9b549210cf3cf514fe5bf4d
7
+ data.tar.gz: '089a684ab72f74fd52ca879869016766c49c6dc6b2c35a598d4f63eb1fadbe82e81176d0f3cc972d3f96cbad2b7a3f4a20925cde86369b52ab4a1fd5b8b5f454'
@@ -0,0 +1,16 @@
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for all configuration options:
4
+ # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
+
6
+ version: 2
7
+ updates:
8
+ - package-ecosystem: "bundler"
9
+ directory: "/" # Location of package manifests
10
+ schedule:
11
+ interval: "weekly"
12
+ groups:
13
+ production-dependencies:
14
+ dependency-type: "production"
15
+ development-dependencies:
16
+ dependency-type: "development"
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ### 1.5.4
2
+
3
+ * Changes
4
+ * Update ruby gems
5
+
6
+ ### 1.5.3
7
+ * Bugs
8
+ * Fix bug that raised an exception when using `validates_with <Custom Validator>` because `#attributes` is not found on custom validators.
9
+ * Changes
10
+ * You can now use `validates_with <Custom Validator>` by passing the attribute name(s) to your custom validator via the `#options` hash with a key of `:attributes` OR `:fields`. For example: `validates_with MyCustomValidator, attributes: %i[field1 field2]` of `validates_with MyCustomValidator, fields: %i[field1 field2]`
11
+ * Updated README.md for the above change.
12
+ * Update bundled gems.
1
13
  ### 1.5.2
2
14
  * Changes
3
15
  * Update ruby gems. Remedy activesupport dependabot alert.
data/Gemfile.lock CHANGED
@@ -1,90 +1,99 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- deco_lite (1.5.2)
4
+ deco_lite (1.5.4)
5
5
  activemodel (~> 7.0, >= 7.0.3.1)
6
6
  activesupport (~> 7.0, >= 7.0.3.1)
7
- immutable_struct_ex (~> 0.2.0)
8
- mad_flatter (~> 2.0)
7
+ immutable_struct_ex (~> 1.0, >= 1.0.1)
8
+ mad_flatter (~> 3.0)
9
9
 
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- activemodel (7.0.4.3)
14
- activesupport (= 7.0.4.3)
15
- activesupport (7.0.4.3)
13
+ activemodel (7.0.7)
14
+ activesupport (= 7.0.7)
15
+ activesupport (7.0.7)
16
16
  concurrent-ruby (~> 1.0, >= 1.0.2)
17
17
  i18n (>= 1.6, < 2)
18
18
  minitest (>= 5.1)
19
19
  tzinfo (~> 2.0)
20
20
  ast (2.4.2)
21
+ base64 (0.1.1)
21
22
  byebug (11.1.3)
22
23
  coderay (1.1.3)
23
24
  concurrent-ruby (1.2.2)
24
25
  diff-lcs (1.5.0)
25
26
  docile (1.4.0)
26
- i18n (1.12.0)
27
+ i18n (1.14.1)
27
28
  concurrent-ruby (~> 1.0)
28
- immutable_struct_ex (0.2.3)
29
+ immutable_struct_ex (1.0.1)
29
30
  json (2.6.3)
30
31
  kwalify (0.7.2)
31
- mad_flatter (2.0.0)
32
+ language_server-protocol (3.17.0.3)
33
+ mad_flatter (3.0.0)
32
34
  activesupport (~> 7.0, >= 7.0.3.1)
33
- immutable_struct_ex (~> 0.2.0)
35
+ immutable_struct_ex (~> 1.0)
34
36
  method_source (1.0.0)
35
- minitest (5.18.0)
36
- parallel (1.22.1)
37
- parser (3.2.1.1)
37
+ minitest (5.19.0)
38
+ parallel (1.23.0)
39
+ parser (3.2.2.3)
38
40
  ast (~> 2.4.1)
41
+ racc
39
42
  pry (0.14.2)
40
43
  coderay (~> 1.1)
41
44
  method_source (~> 1.0)
42
45
  pry-byebug (3.10.1)
43
46
  byebug (~> 11.0)
44
47
  pry (>= 0.13, < 0.15)
48
+ racc (1.7.1)
45
49
  rainbow (3.1.1)
46
50
  rake (13.0.6)
47
51
  reek (6.1.4)
48
52
  kwalify (~> 0.7.0)
49
53
  parser (~> 3.2.0)
50
54
  rainbow (>= 2.0, < 4.0)
51
- regexp_parser (2.7.0)
52
- rexml (3.2.5)
55
+ regexp_parser (2.8.1)
56
+ rexml (3.2.6)
53
57
  rspec (3.12.0)
54
58
  rspec-core (~> 3.12.0)
55
59
  rspec-expectations (~> 3.12.0)
56
60
  rspec-mocks (~> 3.12.0)
57
- rspec-core (3.12.1)
61
+ rspec-core (3.12.2)
58
62
  rspec-support (~> 3.12.0)
59
- rspec-expectations (3.12.2)
63
+ rspec-expectations (3.12.3)
60
64
  diff-lcs (>= 1.2.0, < 2.0)
61
65
  rspec-support (~> 3.12.0)
62
- rspec-mocks (3.12.4)
66
+ rspec-mocks (3.12.6)
63
67
  diff-lcs (>= 1.2.0, < 2.0)
64
68
  rspec-support (~> 3.12.0)
65
- rspec-support (3.12.0)
66
- rubocop (1.48.1)
69
+ rspec-support (3.12.1)
70
+ rubocop (1.56.0)
71
+ base64 (~> 0.1.1)
67
72
  json (~> 2.3)
73
+ language_server-protocol (>= 3.17.0)
68
74
  parallel (~> 1.10)
69
- parser (>= 3.2.0.0)
75
+ parser (>= 3.2.2.3)
70
76
  rainbow (>= 2.2.2, < 4.0)
71
77
  regexp_parser (>= 1.8, < 3.0)
72
78
  rexml (>= 3.2.5, < 4.0)
73
- rubocop-ast (>= 1.26.0, < 2.0)
79
+ rubocop-ast (>= 1.28.1, < 2.0)
74
80
  ruby-progressbar (~> 1.7)
75
81
  unicode-display_width (>= 2.4.0, < 3.0)
76
- rubocop-ast (1.27.0)
82
+ rubocop-ast (1.29.0)
77
83
  parser (>= 3.2.1.0)
78
- rubocop-capybara (2.17.1)
84
+ rubocop-capybara (2.18.0)
79
85
  rubocop (~> 1.41)
80
- rubocop-performance (1.16.0)
86
+ rubocop-factory_bot (2.23.1)
87
+ rubocop (~> 1.33)
88
+ rubocop-performance (1.19.0)
81
89
  rubocop (>= 1.7.0, < 2.0)
82
90
  rubocop-ast (>= 0.4.0)
83
- rubocop-rspec (2.19.0)
91
+ rubocop-rspec (2.23.2)
84
92
  rubocop (~> 1.33)
85
93
  rubocop-capybara (~> 2.17)
94
+ rubocop-factory_bot (~> 2.22)
86
95
  ruby-progressbar (1.13.0)
87
- simplecov (0.21.2)
96
+ simplecov (0.22.0)
88
97
  docile (~> 1.1)
89
98
  simplecov-html (~> 0.11)
90
99
  simplecov_json_formatter (~> 0.1)
@@ -107,7 +116,7 @@ DEPENDENCIES
107
116
  rubocop (~> 1.35)
108
117
  rubocop-performance (~> 1.14, >= 1.14.3)
109
118
  rubocop-rspec (~> 2.12, >= 2.12.1)
110
- simplecov (~> 0.21.2)
119
+ simplecov (~> 0.22.0)
111
120
 
112
121
  BUNDLED WITH
113
122
  2.3.22
data/README.md CHANGED
@@ -176,12 +176,20 @@ model.wife_info_address #=> 1 street, boonton, nj 07005
176
176
 
177
177
  #### Add validators to my model
178
178
 
179
- Simply add your `ActiveModel` validators just like you would any other `ActiveModel::Model` validator. However, be aware that any attribute (field) having an *explicit validation* associated with it, will automatically cause an `attr_accessor` to be created for that field; this is to avoid `NoMethodErrors` when validating the model (e.g. `#valid?`, `#validate`, etc.) *before* the data is loaded that would prompt the creation of the associated `attr_accessors` on the model:
179
+ Simply add your `ActiveModel` validators just like you would any other `ActiveModel::Model` validator, with one caveat noted below. It is important to note that any attribute (field) having an *explicit validation* associated with it, will automatically cause `DecoLite` to create an `attr_accessor` for that field; this is to avoid `NoMethodErrors` when validating the model (e.g. `#valid?`, `#validate`, etc.) *before* the data is loaded. Why does `DecoLite` need to do this? Typically, `DecoLite` dynamically creates `attr_accessors` using the keys from the `Hash` loaded into the model. If the `Hash` loaded into your `DecoLite` model _does not_ include a `Hash` key for the attribute referenced by any validators on your model, `DecoLite` will not create an `attr_accessor` for it; consequently, calling any validation method (e.g. `#valid?`, `#validate`, etc.) on your model will result in a `NoMethodError` for that attribute.
180
+
181
+ One caveat to note is when using Rails custom validators with `validates_with`. When using Rails custom validators via `validates_with`, you should pass the attribute names being validated to your custom validator via the `#options` `Hash` with a key of either `:attributes` or `:fields`. This is so that `DecoLite` can create dynamic `attr_accessors` for these attributes and avoid the aformentioned `NoMethodError` (see above):
180
182
 
181
183
  ```ruby
182
184
  class Model < DecoLite::Model
183
185
  validates :first, :last, :address, presence: true
184
186
  validates :age, numericality: true
187
+ # When using Rails custom validators via validates_with,
188
+ # pass the attribute name(s) being validated in an Array
189
+ # via the #options Hash, with a key of either :attributes
190
+ # or :fields. For example:
191
+ validates_with CustomFirstNameValidator, attributes: [:first]
192
+ validates_with CustomAgeValidator, fields: [:age]
185
193
  end
186
194
 
187
195
  # :address is missing
data/deco_lite.gemspec CHANGED
@@ -50,8 +50,8 @@ Gem::Specification.new do |spec|
50
50
 
51
51
  spec.add_runtime_dependency 'activemodel', '~> 7.0', '>= 7.0.3.1'
52
52
  spec.add_runtime_dependency 'activesupport', '~> 7.0', '>= 7.0.3.1'
53
- spec.add_runtime_dependency 'immutable_struct_ex', '~> 0.2.0'
54
- spec.add_runtime_dependency 'mad_flatter', '~> 2.0'
53
+ spec.add_runtime_dependency 'immutable_struct_ex', '~> 1.0', '>= 1.0.1'
54
+ spec.add_runtime_dependency 'mad_flatter', '~> 3.0'
55
55
  spec.add_development_dependency 'bundler', '~> 2.2', '>= 2.2.17'
56
56
  spec.add_development_dependency 'pry-byebug', '~> 3.9'
57
57
  spec.add_development_dependency 'reek', '~> 6.1', '>= 6.1.1'
@@ -59,6 +59,6 @@ Gem::Specification.new do |spec|
59
59
  spec.add_development_dependency 'rubocop', '~> 1.35'
60
60
  spec.add_development_dependency 'rubocop-performance', '~> 1.14', '>= 1.14.3'
61
61
  spec.add_development_dependency 'rubocop-rspec', '~> 2.12', '>= 2.12.1'
62
- spec.add_development_dependency 'simplecov', '~> 0.21.2'
62
+ spec.add_development_dependency 'simplecov', '~> 0.22.0'
63
63
  spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6'
64
64
  end
@@ -15,7 +15,20 @@ module DecoLite
15
15
  def auto_attr_accessors
16
16
  return @auto_attr_accessors.dup if defined?(@auto_attr_accessors)
17
17
 
18
- @auto_attr_accessors = self.class.validators.map(&:attributes)
18
+ @auto_attr_accessors = self.class.validators.filter_map do |validator|
19
+ if validator.respond_to?(:attributes)
20
+ validator.attributes
21
+ elsif validator.respond_to?(:options)
22
+ # This path handles the case where the validator is a custom validator
23
+ # (i.e. `validates_with MyCustomValidator`). deco_lite in this case, has
24
+ # no way of knowing what fields are being validated, so we have to rely
25
+ # on the user to tell us what fields are being validated by passing
26
+ # the attributes to validate in the #options hash. For example:
27
+ # `validates_with MyCustomValidator, attributes: %i[field1 field2]`)
28
+ # `validates_with MyCustomValidator, fields: %i[field1 field2]`)
29
+ validator.options[:attributes].presence || validator.options[:fields].presence
30
+ end
31
+ end
19
32
  @auto_attr_accessors = auto_attr_accessors_assign
20
33
  end
21
34
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the version of this gem.
4
4
  module DecoLite
5
- VERSION = '1.5.2'
5
+ VERSION = '1.5.4'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deco_lite
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 1.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gene M. Angelo, Jr.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-22 00:00:00.000000000 Z
11
+ date: 2023-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -56,28 +56,34 @@ dependencies:
56
56
  requirements:
57
57
  - - "~>"
58
58
  - !ruby/object:Gem::Version
59
- version: 0.2.0
59
+ version: '1.0'
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 1.0.1
60
63
  type: :runtime
61
64
  prerelease: false
62
65
  version_requirements: !ruby/object:Gem::Requirement
63
66
  requirements:
64
67
  - - "~>"
65
68
  - !ruby/object:Gem::Version
66
- version: 0.2.0
69
+ version: '1.0'
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 1.0.1
67
73
  - !ruby/object:Gem::Dependency
68
74
  name: mad_flatter
69
75
  requirement: !ruby/object:Gem::Requirement
70
76
  requirements:
71
77
  - - "~>"
72
78
  - !ruby/object:Gem::Version
73
- version: '2.0'
79
+ version: '3.0'
74
80
  type: :runtime
75
81
  prerelease: false
76
82
  version_requirements: !ruby/object:Gem::Requirement
77
83
  requirements:
78
84
  - - "~>"
79
85
  - !ruby/object:Gem::Version
80
- version: '2.0'
86
+ version: '3.0'
81
87
  - !ruby/object:Gem::Dependency
82
88
  name: bundler
83
89
  requirement: !ruby/object:Gem::Requirement
@@ -206,14 +212,14 @@ dependencies:
206
212
  requirements:
207
213
  - - "~>"
208
214
  - !ruby/object:Gem::Version
209
- version: 0.21.2
215
+ version: 0.22.0
210
216
  type: :development
211
217
  prerelease: false
212
218
  version_requirements: !ruby/object:Gem::Requirement
213
219
  requirements:
214
220
  - - "~>"
215
221
  - !ruby/object:Gem::Version
216
- version: 0.21.2
222
+ version: 0.22.0
217
223
  - !ruby/object:Gem::Dependency
218
224
  name: rake
219
225
  requirement: !ruby/object:Gem::Requirement
@@ -255,6 +261,7 @@ executables: []
255
261
  extensions: []
256
262
  extra_rdoc_files: []
257
263
  files:
264
+ - ".github/dependabot.yml"
258
265
  - ".gitignore"
259
266
  - ".reek.yml"
260
267
  - ".rspec"