eac_rails_utils 0.23.0 → 0.23.2

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
2
  SHA256:
3
- metadata.gz: b0ab91f74f6a656bab19d9e3fa4205943442f4c43a706b6c38bb37e1cb8cf580
4
- data.tar.gz: 552cac7832c619d0f7a6e7f31025b695fdaecd3ce70eb22c2835ba2483b6d4b6
3
+ metadata.gz: 37d81790aad3527689a15e70896e071c3b774059fb137f6667ffb752d282a5d8
4
+ data.tar.gz: 1f59bb6c219f6097ac000bc5912b659e8046c261bf7a4b5cd5c69e7c45d7b1c9
5
5
  SHA512:
6
- metadata.gz: 68233af01e090a2e474bac06f735a373fc976016f25dbc998cc612ae972517f530375e755b1716ab95cb0ec974ade30a4393abe99e0a546d817630ec45d30f7e
7
- data.tar.gz: 12460dced27d15eaf70d5e8248cb1c57f7a6c65fb57173017c9a9bb6dfc983c3ba4c765ce3cd04979cf46f1420156c765757e3807e4f0dc02edadcd0486aae32
6
+ metadata.gz: 563bf50cb087e260e139f1c6ea3fd91d097286b181804df6783e52b83f83820a7540fa6e5f873a75290609945cce074dbed181733049ad4370e73e0f0ac9d7ee
7
+ data.tar.gz: 4286edfb6b487ba5e5a85a747b29a6346aca7299f025135ee7f1205dd57cb7fb02bcc2081b6d01a214f3de6b3de28fa3efd6f1a0e20f8296fd3efb51426f6ed2
@@ -45,7 +45,7 @@ module EacRailsUtils
45
45
  private
46
46
 
47
47
  def node_value(node, subpath)
48
- return node if subpath.empty?
48
+ node if subpath.empty?
49
49
  end
50
50
  end
51
51
  end
@@ -22,7 +22,7 @@ module EacRailsUtils
22
22
 
23
23
  # @return [Hash]
24
24
  def tag_attributes
25
- column.value_cell_attributes.map { |k, v| [k, tag_attribute_value(v)] }.to_h
25
+ column.value_cell_attributes.map { |k, v| [k, tag_attribute_value(v)] }.to_h # rubocop:disable Style/HashTransformValues, Style/MapToHash
26
26
  end
27
27
  end
28
28
  end
@@ -12,7 +12,7 @@ module EacRailsUtils
12
12
 
13
13
  id = SecureRandom.hex(5)
14
14
  GuiBuilder.new(self).build(entries, id: id, class: 'jMenu') <<
15
- javascript_tag("$(document).ready(function(){$('\##{id}').jMenu();});")
15
+ javascript_tag("$(document).ready(function(){$('##{id}').jMenu();});")
16
16
  end
17
17
 
18
18
  def bootstrap_dropdown_menu(entries, options = {})
@@ -39,7 +39,7 @@ module EacRailsUtils
39
39
  def children_tags
40
40
  view.capture do
41
41
  view.concat tag
42
- @children.values.each do |child| # rubocop:disable Rails/HelperInstanceVariable
42
+ @children.values.each do |child| # rubocop:disable Rails/HelperInstanceVariable, Style/HashEachMethods
43
43
  view.concat(child.children_tags)
44
44
  view.concat("\n")
45
45
  end
@@ -59,7 +59,7 @@ module EacRailsUtils
59
59
  attr_reader :parent, :suffix
60
60
 
61
61
  def initialize(view, parent, suffix)
62
- super view
62
+ super(view)
63
63
  @parent = parent # rubocop:disable Rails/HelperInstanceVariable
64
64
  @suffix = suffix # rubocop:disable Rails/HelperInstanceVariable
65
65
  end
@@ -3,9 +3,9 @@
3
3
  def patch_json?
4
4
  require 'json'
5
5
 
6
- ::Gem::Version.new(RUBY_VERSION) >= ::Gem::Version.new('2.7') &&
7
- ::Gem::Version.new(JSON::VERSION) < ::Gem::Version.new('2')
8
- rescue ::LoadError
6
+ Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7') &&
7
+ Gem::Version.new(JSON::VERSION) < Gem::Version.new('2')
8
+ rescue LoadError
9
9
  false
10
10
  end
11
11
 
@@ -1,23 +1,23 @@
1
- module ActiveRecord::Associations::Builder
1
+ module ActiveRecord::Associations::Builder # rubocop:disable Style/ClassAndModuleChildren, Style/FrozenStringLiteralComment
2
2
  class HasManyForActiveModel < HasMany
3
- if ActiveRecord.version >= Gem::Version.new("5.0.0.beta")
4
- AR_CALLBACK_METHODS = %i(define_callback before_validation after_validation before_save
5
- after_save before_update after_update)
3
+ if ActiveRecord.version >= Gem::Version.new('5.0.0.beta')
4
+ AR_CALLBACK_METHODS = %i[define_callback before_validation after_validation before_save
5
+ after_save before_update after_update].freeze
6
6
 
7
7
  def self.valid_options(_options)
8
- super + [:active_model,
9
- :target_ids] - [:through, :dependent, :source, :source_type, :counter_cache, :as]
8
+ super + %i[active_model
9
+ target_ids] - %i[through dependent source source_type counter_cache as]
10
10
  end
11
11
 
12
12
  def self.define_callbacks(model, reflection)
13
- if AR_CALLBACK_METHODS.all? { |meth| self.respond_to?(meth) }
14
- super
15
- end
13
+ return unless AR_CALLBACK_METHODS.all? { |meth| respond_to?(meth) }
14
+
15
+ super
16
16
  end
17
17
  else
18
18
  def valid_options
19
- super + [:active_model,
20
- :target_ids] - [:through, :dependent, :source, :source_type, :counter_cache, :as]
19
+ super + %i[active_model
20
+ target_ids] - %i[through dependent source source_type counter_cache as]
21
21
  end
22
22
  end
23
23
  end
@@ -1,4 +1,4 @@
1
- module ActiveRecord::Associations
1
+ module ActiveRecord::Associations # rubocop:disable Style/ClassAndModuleChildren, Style/FrozenStringLiteralComment
2
2
  class HasManyForActiveModelAssociation < HasManyAssociation
3
3
  # remove conditions: owner.new_record?, foreign_key_present?
4
4
  def find_target?
@@ -1,15 +1,13 @@
1
- require "active_model"
2
- require "active_record"
3
- require "active_support"
4
- require "eac_rails_utils/models/tableless_associations"
5
- require "eac_rails_utils/models/tableless_associations/hooks"
1
+ require 'active_model' # rubocop:disable Style/FrozenStringLiteralComment
2
+ require 'active_record'
3
+ require 'active_support'
4
+ require 'eac_rails_utils/models/tableless_associations'
5
+ require 'eac_rails_utils/models/tableless_associations/hooks'
6
6
 
7
7
  # Load Railtie
8
8
  begin
9
- require "rails"
9
+ require 'rails'
10
10
  rescue LoadError # rubocop:disable Lint/SuppressedException
11
11
  end
12
12
 
13
- if defined?(Rails)
14
- require "eac_rails_utils/models/tableless_associations/railtie"
15
- end
13
+ require 'eac_rails_utils/models/tableless_associations/railtie' if defined?(Rails)
@@ -10,7 +10,7 @@ module EacRailsUtils
10
10
  # Um array de colunas pode ser passado em options[:skip] de colunas em record que não
11
11
  # terão suas falhas adicionadas.
12
12
  def fetch_record_errors(record, options = {})
13
- record.errors.keys.each do |column| # rubocop:disable Rails/DeprecatedActiveModelErrorsMethods
13
+ record.errors.keys.each do |column| # rubocop:disable Rails/DeprecatedActiveModelErrorsMethods, Style/HashEachMethods
14
14
  fetch_column_errors(record, column, column, options)
15
15
  end
16
16
  end
@@ -83,7 +83,7 @@ module EacRailsUtils
83
83
  b = ''
84
84
  errors.messages.each do |field, messages|
85
85
  b += ' / ' if b != ''
86
- b += field.to_s + ': ' + messages.to_s
86
+ b += field.to_s + ': ' + messages.to_s # rubocop:disable Style/StringConcatenation
87
87
  end
88
88
  b
89
89
  end
@@ -32,7 +32,7 @@ module EacRailsUtils
32
32
  m = /\A(.+)\(([0-9]+)(.)\)\z/.match(key)
33
33
  return unless m
34
34
 
35
- ::OpenStruct.new(key: m[1], index: m[2].to_i - 1, converter: array_value_converter(m[3]))
35
+ ::OpenStruct.new(key: m[1], index: m[2].to_i - 1, converter: array_value_converter(m[3])) # rubocop:disable Style/OpenStructUse
36
36
  end
37
37
 
38
38
  def array_value_set(array_attr, value)
@@ -50,7 +50,9 @@ module EacRailsUtils
50
50
  # Build a list of candidates to search for
51
51
  def compute_type_candidates(type_name)
52
52
  candidates = []
53
- name.scan(/::|$/) { candidates.unshift "#{$`}::#{type_name}" }
53
+ name.scan(/::|$/) do
54
+ candidates.unshift "#{::Regexp.last_match.pre_match}::#{type_name}"
55
+ end
54
56
  candidates << type_name
55
57
  end
56
58
 
@@ -43,7 +43,7 @@ module EacRailsUtils
43
43
  ActiveRecord::Reflection.add_reflection self, name, reflection
44
44
 
45
45
  mixin = generated_association_methods
46
- mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1
46
+ mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1 # rubocop:disable Style/DocumentDynamicEvalDefinition
47
47
  def #{options[:target_ids]}=(other_ids)
48
48
  @#{options[:target_ids]} = other_ids
49
49
  association(:#{name}).reset
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_ruby_utils/require_sub'
4
- ::EacRubyUtils.require_sub __FILE__
4
+ EacRubyUtils.require_sub __FILE__
@@ -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,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_ruby_utils/require_sub'
4
- ::EacRubyUtils.require_sub __FILE__
4
+ EacRubyUtils.require_sub __FILE__
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRailsUtils
4
- VERSION = '0.23.0'
4
+ VERSION = '0.23.2'
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.23.0
4
+ version: 0.23.2
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-24 00:00:00.000000000 Z
11
+ date: 2024-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bootstrap-sass
@@ -99,6 +99,9 @@ dependencies:
99
99
  - - "~>"
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0.10'
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: 0.10.1
102
105
  type: :development
103
106
  prerelease: false
104
107
  version_requirements: !ruby/object:Gem::Requirement
@@ -106,6 +109,9 @@ dependencies:
106
109
  - - "~>"
107
110
  - !ruby/object:Gem::Version
108
111
  version: '0.10'
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: 0.10.1
109
115
  description:
110
116
  email:
111
117
  executables: []
@@ -202,8 +208,6 @@ files:
202
208
  - lib/eac_rails_utils/patches/application.rb
203
209
  - lib/eac_rails_utils/patches/numeric.rb
204
210
  - lib/eac_rails_utils/patches/numeric/number_helper.rb
205
- - lib/eac_rails_utils/patches/rails_4.rb
206
- - lib/eac_rails_utils/patches/rails_4/active_record_associations_association_scope.rb
207
211
  - lib/eac_rails_utils/patches/rails_5_2.rb
208
212
  - lib/eac_rails_utils/patches/rails_5_2/active_model_association_method_fix.rb
209
213
  - lib/eac_rails_utils/rspec.rb
@@ -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