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 +4 -4
- data/lib/eac_ruby_utils/require_sub.rb +32 -5
- data/lib/eac_ruby_utils/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2a4b0d92b253248df0a2e7ec093f1056a822602cfcce7376d2b91e28b9f2d22
|
4
|
+
data.tar.gz: b0590f577360628d7f399981270a2a46914e3398ffb8af511a36ac40f67a9494
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
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.
|
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-
|
11
|
+
date: 2020-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|