eac_rails_utils 0.11.0 → 0.11.5

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: fdc60e761e13bcdf41dd921a5501fa3d6e4e372f3d3c2af48eef03a3f7bee723
4
- data.tar.gz: 6121db8bfd8023c7360fea7d7f40c159a8411462970b37705e3d5c0217e8238f
3
+ metadata.gz: 5e74de3cf5f5df2ebc5dbf47d99ccf3adb446b60debbc0ae0ba4bdc0341b0702
4
+ data.tar.gz: 1fc1a3c6b2f1e28cca60ee396a69dcd682e739390c321c3b0ca6a4bb74aa19a0
5
5
  SHA512:
6
- metadata.gz: 5171b49a17923a648dc8a94b45d4386f1aec8c9079941da2ff66744347b07bc46ab6f64f42c0a46475fb258fa41fe78e755a8d0d1140497fafd10e19cbbfe902
7
- data.tar.gz: 486f7961912a84ee2cc74ff6b91c13e9c19364a42b41ee75af835a6cda82fed07c097bf9ba15007f0207eb9f6f986a84fa329c3be87b0b6776dfe147f14a7bb7
6
+ metadata.gz: f2227dab9cbab9704b6a227a29873c2d9db7de472cbe78e0546728ca171dff4b6e9af70b412b984ccfbf5c608bb501d03ba9ee23ac796877bf5759cd71bf542d
7
+ data.tar.gz: bc70bf917704e2c28f0d2a0fedeacdee1d09e48384f1ffd8fd5ed180b6d24ff77f1257c2081ea449999236c0a9a2c862e4f2897cc56904e036798489b6116476
@@ -1,10 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/require_sub'
3
+ require 'action_view/helpers/form_helper'
4
+ require 'eac_ruby_utils/core_ext'
4
5
 
5
6
  module EacRailsUtils
6
7
  module CommonFormHelper
7
- ::EacRubyUtils.require_sub __FILE__
8
+ common_concern do
9
+ include ::ActionView::Helpers::FormHelper
10
+ end
11
+ require_sub __FILE__
8
12
 
9
13
  def common_form(model_instance, options = {}, &block)
10
14
  submit_label = options.delete(:submit_label)
@@ -7,7 +7,8 @@ module EacRailsUtils
7
7
  def select_field(field_name, options = {})
8
8
  options = options.dup
9
9
  field(field_name, options) do
10
- form.select(field_name, select_options(field_name, options))
10
+ form.select(field_name, select_options(field_name, options),
11
+ options, options[:html] || {})
11
12
  end
12
13
  end
13
14
 
@@ -4,24 +4,24 @@ module EacRailsUtils
4
4
  module LinksHelper
5
5
  def short_delete_link(object)
6
6
  short_object_link object, '', class: 'delete_link', method: :delete, target: '_blank',
7
- title: ::I18n.t('eac_rails_base0.links.delete_object',
7
+ title: ::I18n.t('eac_rails_utils.links.delete_object',
8
8
  label: object.to_s),
9
9
  data: {
10
- confirm: ::I18n.t('eac_rails_base0.links.delete_confirm',
10
+ confirm: ::I18n.t('eac_rails_utils.links.delete_confirm',
11
11
  label: object.to_s)
12
12
  }
13
13
  end
14
14
 
15
15
  def short_edit_link(object)
16
16
  short_object_link object, 'edit', class: 'edit_link', target: '_blank',
17
- title: ::I18n.t('eac_rails_base0.links.edit_object',
17
+ title: ::I18n.t('eac_rails_utils.links.edit_object',
18
18
  label: object.to_s)
19
19
  end
20
20
 
21
21
  def short_goto_link(url)
22
22
  value_or_sign(url, '') do |value|
23
23
  link_to '', value, class: 'goto_link', target: '_blank',
24
- title: ::I18n.t('eac_rails_base0.links.goto_url', url: value.to_s),
24
+ title: ::I18n.t('eac_rails_utils.links.goto_url', url: value.to_s),
25
25
  rel: 'noopener'
26
26
  end
27
27
  end
@@ -54,7 +54,7 @@ module EacRailsUtils
54
54
  short_object_link object,
55
55
  detail ? 'detail' : nil,
56
56
  class: 'show_link', target: '_blank',
57
- title: ::I18n.t('eac_rails_base0.links.show_object', label: object.to_s)
57
+ title: ::I18n.t('eac_rails_utils.links.show_object', label: object.to_s)
58
58
  end
59
59
 
60
60
  def short_object_link(object, action = nil, options = {})
@@ -0,0 +1,8 @@
1
+ en:
2
+ eac_rails_utils:
3
+ links:
4
+ delete_confirm: Do you confirm "%{label}"'s removal?
5
+ delete_object: Remove "%{label}".
6
+ edit_object: Edit "%{label}".
7
+ goto_url: Go to %{url}.
8
+ show_object: Show "%{label}".
@@ -0,0 +1,8 @@
1
+ pt-BR:
2
+ eac_rails_utils:
3
+ links:
4
+ delete_confirm: Confirma a remoção de "%{label}"?
5
+ delete_object: Remover "%{label}".
6
+ edit_object: Editar "%{label}".
7
+ goto_url: Ir para %{url}.
8
+ show_object: Mostrar "%{label}".
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'activemodel/associations'
3
+ require 'eac_rails_utils/patches/active_model_associations'
4
4
  require 'virtus'
5
5
 
6
6
  module EacRailsUtils
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_model/associations/hooks'
4
+ require 'activemodel/associations'
5
+
6
+ module EacRailsUtils
7
+ module Patches
8
+ module ActiveModelAssociations
9
+ module ScopeExtensionPatch
10
+ def add_constraints(scope, owner, association_klass, *extra_args)
11
+ if extra_args.any?
12
+ refl = extra_args.first
13
+ if refl.options[:active_model]
14
+ target_ids = refl.options[:target_ids]
15
+ return scope.where(id: owner[target_ids])
16
+ end
17
+ end
18
+
19
+ super
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ module ActiveModel
27
+ module Associations
28
+ module Hooks
29
+ def self.init
30
+ return unless ::Rails.version < '5'
31
+
32
+ ActiveSupport.on_load(:active_record) do
33
+ ActiveRecord::Associations::AssociationScope.prepend(
34
+ ::EacRailsUtils::Patches::ActiveModelAssociations::ScopeExtensionPatch
35
+ )
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRailsUtils
4
- VERSION = '0.11.0'
4
+ VERSION = '0.11.5'
5
5
  end
@@ -0,0 +1,3 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../javascripts .js
3
+ //= link_directory ../stylesheets .css
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ APP_PATH = File.expand_path('../config/application', __dir__)
5
+ require_relative '../config/boot'
6
+ require 'rails/commands'
@@ -9,6 +9,6 @@ require 'eac_rails_utils'
9
9
 
10
10
  module Dummy
11
11
  class Application < Rails::Application
12
- config.active_record.raise_in_transactional_callbacks = true
12
+ config.active_record.raise_in_transactional_callbacks = true if ::Rails.version < '5'
13
13
  end
14
14
  end
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class CreateUsers < ActiveRecord::Migration
3
+ class CreateUsers < (
4
+ Rails.version < '5.2' ? ActiveRecord::Migration : ActiveRecord::Migration[4.2]
5
+ )
4
6
  def change
5
7
  create_table :users do |t|
6
8
  t.string :name
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class CreateJobs < ActiveRecord::Migration
3
+ class CreateJobs < (
4
+ Rails.version < '5.2' ? ActiveRecord::Migration : ActiveRecord::Migration[4.2]
5
+ )
4
6
  def change
5
7
  create_table :jobs do |t|
6
8
  t.string :name
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class AddJobToUsers < ActiveRecord::Migration
3
+ class AddJobToUsers < (
4
+ Rails.version < '5.2' ? ActiveRecord::Migration : ActiveRecord::Migration[4.2]
5
+ )
4
6
  def change
5
7
  add_belongs_to :users, :job
6
8
  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.11.0
4
+ version: 0.11.5
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: 2020-05-29 00:00:00.000000000 Z
11
+ date: 2020-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel-associations
@@ -128,6 +128,20 @@ dependencies:
128
128
  - - "~>"
129
129
  - !ruby/object:Gem::Version
130
130
  version: '0.1'
131
+ - !ruby/object:Gem::Dependency
132
+ name: rspec-rails
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
131
145
  - !ruby/object:Gem::Dependency
132
146
  name: sqlite3
133
147
  requirement: !ruby/object:Gem::Requirement
@@ -175,6 +189,8 @@ files:
175
189
  - app/helpers/eac_rails_utils/open_graph_protocol_helper.rb
176
190
  - app/validators/eac_rails_utils/cpf_validator.rb
177
191
  - app/validators/eac_rails_utils/no_presence_validator.rb
192
+ - config/locales/en.yml
193
+ - config/locales/pt-BR.yml
178
194
  - lib/assets/javascripts/currency_field.js
179
195
  - lib/assets/javascripts/eac_rails_utils.js
180
196
  - lib/assets/javascripts/input_searchable.js
@@ -197,10 +213,13 @@ files:
197
213
  - lib/eac_rails_utils/models/test_utils.rb
198
214
  - lib/eac_rails_utils/patches.rb
199
215
  - lib/eac_rails_utils/patches/action_controller_base.rb
216
+ - lib/eac_rails_utils/patches/active_model_associations.rb
200
217
  - lib/eac_rails_utils/version.rb
201
218
  - test/dummy/Rakefile
219
+ - test/dummy/app/assets/config/manifest.js
202
220
  - test/dummy/app/models/job.rb
203
221
  - test/dummy/app/models/user.rb
222
+ - test/dummy/bin/rails
204
223
  - test/dummy/config.ru
205
224
  - test/dummy/config/application.rb
206
225
  - test/dummy/config/boot.rb
@@ -214,7 +233,6 @@ files:
214
233
  - test/dummy/db/migrate/20160415143123_create_jobs.rb
215
234
  - test/dummy/db/migrate/20160415143229_add_job_to_users.rb
216
235
  - test/dummy/db/schema.rb
217
- - test/helpers/eac_rails_utils/common_form_helper_test.rb
218
236
  - test/helpers/eac_rails_utils/data_table_test_helper_test.rb
219
237
  - test/helpers/eac_rails_utils/formatter_helper_test.rb
220
238
  - test/lib/eac_rails_utils/models/attribute_required_test.rb
@@ -240,8 +258,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
240
258
  - !ruby/object:Gem::Version
241
259
  version: '0'
242
260
  requirements: []
243
- rubyforge_project:
244
- rubygems_version: 2.7.7
261
+ rubygems_version: 3.0.8
245
262
  signing_key:
246
263
  specification_version: 4
247
264
  summary: Código reutilizável para as aplicações Rails da E.A.C..
@@ -262,9 +279,10 @@ test_files:
262
279
  - test/dummy/db/migrate/20160415125333_create_users.rb
263
280
  - test/dummy/app/models/job.rb
264
281
  - test/dummy/app/models/user.rb
282
+ - test/dummy/app/assets/config/manifest.js
283
+ - test/dummy/bin/rails
265
284
  - test/test_helper.rb
266
285
  - test/validators/cpf_validator_test.rb
267
- - test/helpers/eac_rails_utils/common_form_helper_test.rb
268
286
  - test/helpers/eac_rails_utils/data_table_test_helper_test.rb
269
287
  - test/helpers/eac_rails_utils/formatter_helper_test.rb
270
288
  - test/lib/eac_rails_utils/models/attribute_required_test.rb
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
-
5
- module EacRailsUtils
6
- class CommonFormHelperTest < ActionView::TestCase
7
- include ::EacRailsUtils::CommonFormHelper
8
-
9
- setup do
10
- reset_test_database
11
- end
12
-
13
- test 'test common form' do
14
- common_form(User.new) do |f|
15
- f.text_field :name
16
- f.email_field :email
17
- f.password_field :password
18
- f.searchable_association_field :job, url: search_jobs_path
19
- end
20
- end
21
-
22
- test 'fields for' do
23
- common_form(Job.new) do |f|
24
- f.text_field :name
25
- f.fields_for :users do |nf|
26
- nf.text_field :name
27
- nf.email_field :email
28
- nf.password_field :password
29
- end
30
- end
31
- end
32
- end
33
- end