eac_ruby_utils 0.38.0 → 0.39.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: 5fc852bc0ba01d1706a2f6c6dc7a0a09b1725b3dc3e54741abbf4c1d2022cac0
4
- data.tar.gz: 288360947e10bbef4f1b4cf100306e8bfcb7b5e146adead41184c96e4c66c2d3
3
+ metadata.gz: f2a4b0d92b253248df0a2e7ec093f1056a822602cfcce7376d2b91e28b9f2d22
4
+ data.tar.gz: b0590f577360628d7f399981270a2a46914e3398ffb8af511a36ac40f67a9494
5
5
  SHA512:
6
- metadata.gz: 579594be75a7160855c0b530cd4b5d9bf8f918f065b5e2d4938274d2395dd47f14ee7b827c8461fa6775a7962936ae729d90320124398d3f8220eb0c914243eb
7
- data.tar.gz: d287cd78c95da6e3d28c628c6059af23b3710d70f150672cbe13c47e80caa2989b3c93b084292e253380ef342128f780cc9b302cc09dfd36d9a0142ebf9a564b
6
+ metadata.gz: c42cfcbfb7bcc6a0ed2d6df02959de8496e131cbe1d2448e1ebeffa8b2dab284dcb4cdc535605eeaff9efdae0134aa473458b570ab511db4e1e41b6fe9d6af5b
7
+ data.tar.gz: d989ccc189773585f71ad08f42f41400d3bddd8caf4914f452abffb28e0640f7bc64359c8374dfe20af115ecbbc48317ce623d3533ca1be947344d5b4c43db03
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'active_support/inflector'
4
+
3
5
  module EacRubyUtils
4
6
  class << self
5
7
  def require_sub(file, options = {})
@@ -26,6 +28,23 @@ module EacRubyUtils
26
28
 
27
29
  private
28
30
 
31
+ def active_support_require(path)
32
+ return false unless options[REQUIRE_DEPENDENCY_OPTION_KEY]
33
+
34
+ ::Kernel.require_dependency(path)
35
+ true
36
+ end
37
+
38
+ def autoload_require(path)
39
+ return false unless base?
40
+
41
+ basename = ::File.basename(path, '.*')
42
+ return false if basename.start_with?('_')
43
+
44
+ base.autoload ::ActiveSupport::Inflector.camelize(basename), path
45
+ true
46
+ end
47
+
29
48
  def include_modules
30
49
  return unless options[INCLUDE_MODULES_OPTION_KEY]
31
50
 
@@ -41,14 +60,22 @@ module EacRubyUtils
41
60
  options[BASE_OPTION_KEY] || raise('Option :base not setted')
42
61
  end
43
62
 
63
+ def base?
64
+ options[BASE_OPTION_KEY] ? true : false
65
+ end
66
+
67
+ def kernel_require(path)
68
+ ::Kernel.require(path)
69
+ end
70
+
44
71
  def require_sub_files
45
72
  Dir["#{File.dirname(file)}/#{::File.basename(file, '.*')}/*.rb"].sort.each do |path|
46
- if options[REQUIRE_DEPENDENCY_OPTION_KEY]
47
- require_dependency path
48
- else
49
- require path
50
- end
73
+ require_sub_file(path)
51
74
  end
52
75
  end
76
+
77
+ def require_sub_file(path)
78
+ active_support_require(path) || autoload_require(path) || kernel_require(path)
79
+ end
53
80
  end
54
81
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.38.0'
4
+ VERSION = '0.39.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_ruby_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.38.0
4
+ version: 0.39.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-02 00:00:00.000000000 Z
11
+ date: 2020-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport