eac_rails_utils 0.22.3 → 0.23.1

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: 502d1a6b9d9fabc7dd27f46a6d6cde1e7e8636b5b611db680565a40e5084d47e
4
- data.tar.gz: d1a1161de0a84bd1a5419b34747d1f5bbb70d273a6234d776faf273e8c9f42d1
3
+ metadata.gz: d9f7ed3ae0a13dc0aa2f380322270a36a0c35784c6bb9b13a5145dcade4ce9ab
4
+ data.tar.gz: e87c326dca2c7c0e1de5f8cdabcf35d3daab5bd907d6812b1144cd5c24a4c901
5
5
  SHA512:
6
- metadata.gz: ec590a4a5c4e94fb820412f17da3a2e8ccae156fb516450d61df417213327fb3b64052c4e02967dcb59d7c169172021f0158b07a7f3c7509ee26559ebe40b1a9
7
- data.tar.gz: 2c06361f27ce85bb7bb7d362e2d0437f4d823f743c7ce6e4f13f72120ed45f787dce16eaed99eee4b71ac341962a34dba00b6866b62130e4c4c87f8696a4d7d0
6
+ metadata.gz: cd14c49a2cd8e303b5542d5d50913ff455c9dd8e8f463ecfad41544c35ebaae034cee96c7d1a14de81f6532613eee511c058425dc6b83fb2d3af94cbf7b21f16
7
+ data.tar.gz: 55f27beab83da5a622866bb40f911ee7374e088609040cb7df50ed32262b5e5d76ceba41b95ee97210c6a405c09105e3bb7608447478bdc5e2d096dcfcdf92b4
@@ -5,8 +5,10 @@ module EacRailsUtils
5
5
  def validate_each(record, attribute, value)
6
6
  return if Cpf.new(value).valid?
7
7
 
8
- record.errors[attribute] << (options[:message] || # rubocop:disable Rails/DeprecatedActiveModelErrorsMethods
9
- 'CPF inválido (9 caracteres, somente dígitos)')
8
+ record.errors.add(
9
+ attribute,
10
+ options[:message] || 'CPF inválido (9 caracteres, somente dígitos)'
11
+ )
10
12
  end
11
13
 
12
14
  class Cpf
@@ -6,7 +6,7 @@ module EacRailsUtils
6
6
  def validate_each(record, attribute, _value)
7
7
  return if record.send(attribute).blank?
8
8
 
9
- record.errors[attribute] << (options[:message] || 'must be blank') # rubocop:disable Rails/DeprecatedActiveModelErrorsMethods
9
+ record.errors.add(attribute, options[:message] || 'must be blank')
10
10
  end
11
11
  end
12
12
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'addressable'
4
+
5
+ module EacRailsUtils
6
+ class UriValidator < ActiveModel::EachValidator
7
+ def validate_each(record, attribute, value)
8
+ r = ::Addressable::URI.parse(value)
9
+ raise ::Addressable::URI::InvalidURIError, 'No scheme' if r.scheme.blank?
10
+ rescue ::Addressable::URI::InvalidURIError => e
11
+ record.errors.add(attribute, options[:message] || e.message)
12
+ end
13
+ end
14
+ end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'activemodel/associations'
4
- require 'eac_rails_utils/patches/rails_4'
5
4
  require 'eac_rails_utils/patches/rails_5_2'
6
5
 
7
6
  module EacRailsUtils
@@ -10,18 +9,9 @@ module EacRailsUtils
10
9
  module Hooks
11
10
  class << self
12
11
  def init
13
- init_rails_4 if ::EacRailsUtils::Patches::Rails4.enabled?
14
12
  init_rails_5_2 if ::EacRailsUtils::Patches::Rails52.enabled?
15
13
  end
16
14
 
17
- def init_rails_4 # rubocop:disable Naming/VariableNumber
18
- ActiveSupport.on_load(:active_record) do
19
- ActiveRecord::Associations::AssociationScope.prepend(
20
- ::EacRailsUtils::Patches::Rails4::ActiveRecordAssociationsAssociationScope
21
- )
22
- end
23
- end
24
-
25
15
  def init_rails_5_2 # rubocop:disable Naming/VariableNumber
26
16
  rails_5_2_fix_activemodel_associations_methods
27
17
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRailsUtils
4
- VERSION = '0.22.3'
4
+ VERSION = '0.23.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_rails_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.3
4
+ version: 0.23.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - E.A.C.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-06 00:00:00.000000000 Z
11
+ date: 2024-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bootstrap-sass
@@ -44,40 +44,20 @@ dependencies:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '0.121'
47
- - !ruby/object:Gem::Dependency
48
- name: htmlbeautifier
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - "~>"
52
- - !ruby/object:Gem::Version
53
- version: '1.4'
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: 1.4.3
57
- type: :runtime
58
- prerelease: false
59
- version_requirements: !ruby/object:Gem::Requirement
60
- requirements:
61
- - - "~>"
62
- - !ruby/object:Gem::Version
63
- version: '1.4'
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- version: 1.4.3
67
47
  - !ruby/object:Gem::Dependency
68
48
  name: rails
69
49
  requirement: !ruby/object:Gem::Requirement
70
50
  requirements:
71
51
  - - ">="
72
52
  - !ruby/object:Gem::Version
73
- version: 4.2.11
53
+ version: 5.2.8.1
74
54
  type: :runtime
75
55
  prerelease: false
76
56
  version_requirements: !ruby/object:Gem::Requirement
77
57
  requirements:
78
58
  - - ">="
79
59
  - !ruby/object:Gem::Version
80
- version: 4.2.11
60
+ version: 5.2.8.1
81
61
  - !ruby/object:Gem::Dependency
82
62
  name: virtus
83
63
  requirement: !ruby/object:Gem::Requirement
@@ -118,20 +98,14 @@ dependencies:
118
98
  requirements:
119
99
  - - "~>"
120
100
  - !ruby/object:Gem::Version
121
- version: '0.9'
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: 0.9.2
101
+ version: '0.10'
125
102
  type: :development
126
103
  prerelease: false
127
104
  version_requirements: !ruby/object:Gem::Requirement
128
105
  requirements:
129
106
  - - "~>"
130
107
  - !ruby/object:Gem::Version
131
- version: '0.9'
132
- - - ">="
133
- - !ruby/object:Gem::Version
134
- version: 0.9.2
108
+ version: '0.10'
135
109
  description:
136
110
  email:
137
111
  executables: []
@@ -187,6 +161,7 @@ files:
187
161
  - app/validators/eac_rails_utils/cpf_validator.rb
188
162
  - app/validators/eac_rails_utils/immutable_validator.rb
189
163
  - app/validators/eac_rails_utils/no_presence_validator.rb
164
+ - app/validators/eac_rails_utils/uri_validator.rb
190
165
  - app/validators/eac_rails_utils/yaml_validator.rb
191
166
  - config/initializers/assets.rb
192
167
  - config/initializers/json.rb
@@ -198,7 +173,6 @@ files:
198
173
  - lib/eac_rails_utils.rb
199
174
  - lib/eac_rails_utils/engine.rb
200
175
  - lib/eac_rails_utils/engine_helper.rb
201
- - lib/eac_rails_utils/htmlbeautifier.rb
202
176
  - lib/eac_rails_utils/menus.rb
203
177
  - lib/eac_rails_utils/menus/action.rb
204
178
  - lib/eac_rails_utils/menus/group.rb
@@ -228,8 +202,6 @@ files:
228
202
  - lib/eac_rails_utils/patches/application.rb
229
203
  - lib/eac_rails_utils/patches/numeric.rb
230
204
  - lib/eac_rails_utils/patches/numeric/number_helper.rb
231
- - lib/eac_rails_utils/patches/rails_4.rb
232
- - lib/eac_rails_utils/patches/rails_4/active_record_associations_association_scope.rb
233
205
  - lib/eac_rails_utils/patches/rails_5_2.rb
234
206
  - lib/eac_rails_utils/patches/rails_5_2/active_model_association_method_fix.rb
235
207
  - lib/eac_rails_utils/rspec.rb
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'htmlbeautifier'
4
-
5
- module EacRailsUtils
6
- class Htmlbeautifier
7
- def self.beautify(string)
8
- ::HtmlBeautifier.beautify(string, tab_stops: 2) + "\n"
9
- end
10
-
11
- def self.file_beautified?(file)
12
- input = File.read(file)
13
- input == beautify(input)
14
- end
15
-
16
- def self.beautify_file(file)
17
- input = File.read(file)
18
- output = beautify(input)
19
- if input == output
20
- false
21
- else
22
- File.write(file, output)
23
- true
24
- end
25
- end
26
- end
27
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'activemodel/associations'
4
-
5
- module EacRailsUtils
6
- module Patches
7
- module Rails4
8
- module ActiveRecordAssociationsAssociationScope
9
- def add_constraints(scope, owner, association_klass, *extra_args)
10
- if extra_args.any?
11
- refl = extra_args.first
12
- if refl.options[:active_model]
13
- target_ids = refl.options[:target_ids]
14
- return scope.where(id: owner[target_ids])
15
- end
16
- end
17
-
18
- super
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_rails_utils/models/tableless_associations/hooks'
4
- require 'eac_ruby_utils/require_sub'
5
-
6
- module EacRailsUtils
7
- module Patches
8
- module Rails4
9
- ::EacRubyUtils.require_sub __FILE__
10
-
11
- class << self
12
- def enabled?
13
- ::Rails.version < '5'
14
- end
15
- end
16
- end
17
- end
18
- end