eac_rails_utils 0.23.0 → 0.23.2
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 +4 -4
- data/app/helpers/eac_rails_utils/data_table_helper/column.rb +1 -1
- data/app/helpers/eac_rails_utils/data_table_helper/data_table/value_cell.rb +1 -1
- data/app/helpers/eac_rails_utils/menus_helper.rb +1 -1
- data/app/helpers/eac_rails_utils/open_graph_protocol_helper.rb +2 -2
- data/config/initializers/json.rb +3 -3
- data/lib/active_record/associations/builder/has_many_for_active_model.rb +11 -11
- data/lib/active_record/associations/has_many_for_active_model_association.rb +1 -1
- data/lib/activemodel/associations.rb +7 -9
- data/lib/eac_rails_utils/models/fetch_errors.rb +2 -2
- data/lib/eac_rails_utils/models/tableless/build_attributes.rb +1 -1
- data/lib/eac_rails_utils/models/tableless_associations/override_methods.rb +3 -1
- data/lib/eac_rails_utils/models/tableless_associations.rb +1 -1
- data/lib/eac_rails_utils/patches/active_model.rb +1 -1
- data/lib/eac_rails_utils/patches/active_model_associations.rb +0 -10
- data/lib/eac_rails_utils/patches/numeric.rb +1 -1
- data/lib/eac_rails_utils/version.rb +1 -1
- metadata +8 -4
- data/lib/eac_rails_utils/patches/rails_4/active_record_associations_association_scope.rb +0 -23
- data/lib/eac_rails_utils/patches/rails_4.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37d81790aad3527689a15e70896e071c3b774059fb137f6667ffb752d282a5d8
|
4
|
+
data.tar.gz: 1f59bb6c219f6097ac000bc5912b659e8046c261bf7a4b5cd5c69e7c45d7b1c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 563bf50cb087e260e139f1c6ea3fd91d097286b181804df6783e52b83f83820a7540fa6e5f873a75290609945cce074dbed181733049ad4370e73e0f0ac9d7ee
|
7
|
+
data.tar.gz: 4286edfb6b487ba5e5a85a747b29a6346aca7299f025135ee7f1205dd57cb7fb02bcc2081b6d01a214f3de6b3de28fa3efd6f1a0e20f8296fd3efb51426f6ed2
|
@@ -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(){$('
|
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
|
62
|
+
super(view)
|
63
63
|
@parent = parent # rubocop:disable Rails/HelperInstanceVariable
|
64
64
|
@suffix = suffix # rubocop:disable Rails/HelperInstanceVariable
|
65
65
|
end
|
data/config/initializers/json.rb
CHANGED
@@ -3,9 +3,9 @@
|
|
3
3
|
def patch_json?
|
4
4
|
require 'json'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
rescue
|
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(
|
4
|
-
AR_CALLBACK_METHODS = %i
|
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 + [
|
9
|
-
|
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
|
-
|
14
|
-
|
15
|
-
|
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 + [
|
20
|
-
|
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
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
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
|
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(/::|$/)
|
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,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
|
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.
|
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-
|
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
|