eac_rails_utils 0.4.0 → 0.5.0

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: 4331a79b726cdb7d57b195aa6a353100a40e0b13105e8af73b5de0d0ef772de8
4
- data.tar.gz: 6708069f999d4dc7870caed8f3201c3f74b1e949f8c58b38eeb3e9ebaddd3fc0
3
+ metadata.gz: a200b85b318ad4085a58fecff3d3d9dddb54d8a6fa96a3f6d07d53a7f417e898
4
+ data.tar.gz: 5052af7b7693cf6e6687fc7deea1d74f90998c9bdf20907ea751cd353ec3c9fd
5
5
  SHA512:
6
- metadata.gz: 138f4bebee91229a8fb9a6ff5ad7f87174cd6910d6a7e7d811f54d62f8cfff3cf85b03e3cb49284c6cafa74c23e055028a58e4543d713ce9a96108857e17bf72
7
- data.tar.gz: 89118f011528541ab4cb106cce163bdf03bf0a056304edcdf9157e9b5baedd3709bfa184bdbd08222f00092095cbe69c493a3888eeffce6b7728d1a9f520b534
6
+ metadata.gz: 60c966c2c0a6657912a4a5b3cfbc792bf16508677d8a562955d9758fad49784b194a822af00c71bb962e1f458261ed7d4662955c09e3e2c5049af599136b4f2d
7
+ data.tar.gz: e63356d26e664857f41685f490a35348248d85457da86ea37286a8aa64f682f36517b84adbe4747406461846a0bafbae52a2f17cd65078616db4c18cf12ce776
@@ -8,6 +8,7 @@ module Eac
8
8
  include DateField
9
9
  include RadioSelectField
10
10
  include FieldsFor
11
+ include FileField
11
12
  include SelectField
12
13
  include TimeField
13
14
  include YearMonthField
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+ module Eac
3
+ module CommonFormHelper
4
+ class FormBuilder
5
+ module FileField
6
+ def file_field(field_name, options = {})
7
+ options = options.dup
8
+ field(field_name, options) do
9
+ form.file_field(field_name, options)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -19,6 +19,7 @@ module EacRailsUtils
19
19
  require 'eac/common_form_helper/form_builder/currency_field'
20
20
  require 'eac/common_form_helper/form_builder/date_field'
21
21
  require 'eac/common_form_helper/form_builder/fields_for'
22
+ require 'eac/common_form_helper/form_builder/file_field'
22
23
  require 'eac/common_form_helper/form_builder/radio_select_field'
23
24
  require 'eac/common_form_helper/form_builder/searchable_association_field'
24
25
  require 'eac/common_form_helper/form_builder/select_field'
@@ -37,7 +38,6 @@ module EacRailsUtils
37
38
  require 'eac/model'
38
39
  require 'eac/no_presence_validator'
39
40
  require 'eac/parsers/files_test'
40
- require 'eac/simple_cache'
41
41
  require 'eac/source_target_fixtures'
42
42
  require 'eac/test_utils'
43
43
 
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module EacRailsUtils
3
- VERSION = '0.4.0'
3
+ VERSION = '0.5.0'
4
4
  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.4.0
4
+ version: 0.5.0
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: 2019-05-31 00:00:00.000000000 Z
11
+ date: 2019-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel-associations
@@ -153,6 +153,7 @@ files:
153
153
  - lib/eac/common_form_helper/form_builder/currency_field.rb
154
154
  - lib/eac/common_form_helper/form_builder/date_field.rb
155
155
  - lib/eac/common_form_helper/form_builder/fields_for.rb
156
+ - lib/eac/common_form_helper/form_builder/file_field.rb
156
157
  - lib/eac/common_form_helper/form_builder/radio_select_field.rb
157
158
  - lib/eac/common_form_helper/form_builder/searchable_association_field.rb
158
159
  - lib/eac/common_form_helper/form_builder/select_field.rb
@@ -173,7 +174,6 @@ files:
173
174
  - lib/eac/model.rb
174
175
  - lib/eac/no_presence_validator.rb
175
176
  - lib/eac/parsers/files_test.rb
176
- - lib/eac/simple_cache.rb
177
177
  - lib/eac/source_target_fixtures.rb
178
178
  - lib/eac/test_utils.rb
179
179
  - lib/eac_rails_utils.rb
@@ -210,7 +210,6 @@ files:
210
210
  - test/lib/eac/parsers/ok_test_files/a.target.yaml
211
211
  - test/lib/eac/parsers/ok_test_files/b.source.yaml
212
212
  - test/lib/eac/parsers/ok_test_files/b.target.yaml
213
- - test/lib/eac/simple_cache_test.rb
214
213
  - test/lib/eac/source_target_fixtures_test.rb
215
214
  - test/lib/eac/source_target_fixtures_test_files/a.source.html
216
215
  - test/lib/eac/source_target_fixtures_test_files/a.target.yaml
@@ -244,39 +243,38 @@ signing_key:
244
243
  specification_version: 4
245
244
  summary: Código reutilizável para as aplicações Rails da E.A.C..
246
245
  test_files:
247
- - test/dummy/Rakefile
248
- - test/dummy/config.ru
249
- - test/dummy/config/boot.rb
246
+ - test/lib/eac_rails_utils/tableless_model_test.rb
247
+ - test/lib/eac_rails_utils/helpers/formatter_test.rb
248
+ - test/lib/eac_rails_utils/patches/model_attribute_required_test.rb
249
+ - test/lib/eac/source_target_fixtures_test.rb
250
+ - test/lib/eac/listable_test.rb
251
+ - test/lib/eac/data_table_test_helper.rb
252
+ - test/lib/eac/cpf_validator_test.rb
253
+ - test/lib/eac/model_test.rb
254
+ - test/lib/eac/common_form_helper_test.rb
255
+ - test/lib/eac/source_target_fixtures_test_files/a.target.yaml
256
+ - test/lib/eac/source_target_fixtures_test_files/b.source.html
257
+ - test/lib/eac/source_target_fixtures_test_files/c.target.yaml
258
+ - test/lib/eac/source_target_fixtures_test_files/a.source.html
259
+ - test/lib/eac/parsers/files_test_test.rb
260
+ - test/lib/eac/parsers/ok_test_files/a.target.yaml
261
+ - test/lib/eac/parsers/ok_test_files/b.source.yaml
262
+ - test/lib/eac/parsers/ok_test_files/b.target.yaml
263
+ - test/lib/eac/parsers/ok_test_files/a.source.yaml
264
+ - test/dummy/config/routes.rb
250
265
  - test/dummy/config/database.yml
251
266
  - test/dummy/config/secrets.yml
252
267
  - test/dummy/config/locales/pt-BR.yml
268
+ - test/dummy/config/environment.rb
269
+ - test/dummy/config/boot.rb
253
270
  - test/dummy/config/application.rb
254
271
  - test/dummy/config/environments/test.rb
255
- - test/dummy/config/environment.rb
256
- - test/dummy/config/routes.rb
272
+ - test/dummy/Rakefile
273
+ - test/dummy/config.ru
274
+ - test/dummy/app/models/user.rb
275
+ - test/dummy/app/models/job.rb
257
276
  - test/dummy/db/schema.rb
277
+ - test/dummy/db/migrate/20160415125333_create_users.rb
258
278
  - test/dummy/db/migrate/20160415143123_create_jobs.rb
259
279
  - test/dummy/db/migrate/20160415143229_add_job_to_users.rb
260
- - test/dummy/db/migrate/20160415125333_create_users.rb
261
- - test/dummy/app/models/job.rb
262
- - test/dummy/app/models/user.rb
263
280
  - test/test_helper.rb
264
- - test/lib/eac_rails_utils/helpers/formatter_test.rb
265
- - test/lib/eac_rails_utils/patches/model_attribute_required_test.rb
266
- - test/lib/eac_rails_utils/tableless_model_test.rb
267
- - test/lib/eac/common_form_helper_test.rb
268
- - test/lib/eac/source_target_fixtures_test.rb
269
- - test/lib/eac/parsers/files_test_test.rb
270
- - test/lib/eac/parsers/ok_test_files/a.source.yaml
271
- - test/lib/eac/parsers/ok_test_files/a.target.yaml
272
- - test/lib/eac/parsers/ok_test_files/b.source.yaml
273
- - test/lib/eac/parsers/ok_test_files/b.target.yaml
274
- - test/lib/eac/cpf_validator_test.rb
275
- - test/lib/eac/data_table_test_helper.rb
276
- - test/lib/eac/simple_cache_test.rb
277
- - test/lib/eac/source_target_fixtures_test_files/c.target.yaml
278
- - test/lib/eac/source_target_fixtures_test_files/b.source.html
279
- - test/lib/eac/source_target_fixtures_test_files/a.target.yaml
280
- - test/lib/eac/source_target_fixtures_test_files/a.source.html
281
- - test/lib/eac/listable_test.rb
282
- - test/lib/eac/model_test.rb
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
- module Eac
3
- module SimpleCache
4
- def method_missing(method, *args, &block)
5
- uncached_method = "#{method}_uncached"
6
- if respond_to?(uncached_method, true)
7
- call_method_with_cache(uncached_method, args, &block)
8
- else
9
- super
10
- end
11
- end
12
-
13
- def respond_to?(method, include_all = false)
14
- super || super("#{method}_uncached", true)
15
- end
16
-
17
- def reset_cache
18
- @cache_keys = nil
19
- end
20
-
21
- private
22
-
23
- def call_method_with_cache(method, args, &block)
24
- raise 'Não é possível realizar o cache de métodos com bloco' if block
25
- key = ([method] + args).join('@@@')
26
- cache_keys[key] = send(method, *args) unless cache_keys.key?(key)
27
- cache_keys[key]
28
- end
29
-
30
- def cache_keys
31
- @cache_keys ||= {}
32
- end
33
- end
34
- end
@@ -1,63 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'test_helper'
3
-
4
- module Eac
5
- class SimpleCacheTest < ActionView::TestCase
6
- class CacheableObject
7
- include Eac::SimpleCache
8
-
9
- def my_method_uncached
10
- @counter ||= 0
11
- @counter += 1
12
- end
13
-
14
- def method_with_args_uncached(arg1)
15
- @counter2 ||= 0
16
- @counter2 += 1
17
- "#{arg1}/#{@counter2}"
18
- end
19
-
20
- private
21
-
22
- def private_method_uncached
23
- @counter3 ||= 0
24
- @counter3 += 1
25
- end
26
- end
27
-
28
- def setup
29
- @co = CacheableObject.new
30
- end
31
-
32
- def test_cached_value
33
- assert_not_equal @co.my_method_uncached, @co.my_method_uncached
34
- assert_equal @co.my_method, @co.my_method
35
- end
36
-
37
- def test_cached_value_with_args
38
- assert_not_equal @co.method_with_args_uncached('123'), @co.method_with_args_uncached('123')
39
- assert_not_equal @co.method_with_args_uncached('456'), @co.method_with_args_uncached('456')
40
- assert_equal @co.method_with_args('123'), @co.method_with_args('123')
41
- assert_equal @co.method_with_args('456'), @co.method_with_args('456')
42
- assert_not_equal @co.method_with_args('123'), @co.method_with_args('456')
43
- end
44
-
45
- def test_private_uncached_method
46
- assert_equal @co.private_method, @co.private_method
47
- end
48
-
49
- def test_respond_to
50
- assert @co.respond_to?(:my_method)
51
- assert @co.respond_to?(:private_method)
52
- assert @co.respond_to?(:method_with_args)
53
- end
54
-
55
- def test_reset
56
- @co = CacheableObject.new
57
- value = @co.my_method
58
- assert_equal value, @co.my_method
59
- @co.reset_cache
60
- assert_not_equal value, @co.my_method
61
- end
62
- end
63
- end