awesome_loader 1.1.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -6
- data/lib/awesome_loader/autoloader.rb +15 -1
- data/lib/awesome_loader/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8d1e0254ff832c3f8dbdc6ab4198a7ef5a6d7ad
|
4
|
+
data.tar.gz: 7e1f8bb5dce71966b91ea1b1e00a3cb5b1b61906
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf7502582e600441d8873161ec2cda3fa94105c97d6d128c416d09f0c78655280a60b426ac6dee6348cbdccfc3ea749729d9b948d921af1dfbd2908f460e4112
|
7
|
+
data.tar.gz: 51645940d502c3fd65ec678dd2d20b9e8d55d372a58b972a4ae78d5291b45c0d58a24e0d61f5de18ce90de7b6a546e740a54734b3a5fd700e8d9e14176543efc
|
data/README.md
CHANGED
@@ -27,16 +27,18 @@ Given those files and their contents, this is all you have to tell `awesome_load
|
|
27
27
|
Maybe your app structure is more complicated. That's fine too. Note the `root_depth: 2` argument. That's saying, "Only start creating modules for dirs after the first 2 levels." That means `app` and `app/*` won't get any modules, but deeper directories, like `app/models/billing`, will. `2` is the default, as you can see in the above example.
|
28
28
|
|
29
29
|
AwesomeLoader.autoload root_depth: 2 do
|
30
|
-
# These
|
31
|
-
paths %w(app models ** *.rb)
|
32
|
-
paths %w(app helpers ** *.rb)
|
33
|
-
|
34
|
-
# But the files in these dirs have top-level Routes and Entities modules
|
30
|
+
# These files have top-level Routes and Entities modules
|
35
31
|
paths %w(app routes ** *.rb), root_depth: 1
|
36
32
|
paths %w(app entities ** *.rb), root_depth: 1
|
33
|
+
|
34
|
+
# Load everything else using the default root_depth
|
35
|
+
paths %w(app ** *.rb)
|
36
|
+
|
37
|
+
# Load your app's initializers. Any classes/modules in them will be autoloaded.
|
38
|
+
require %w(config initializers *.rb)
|
37
39
|
end
|
38
40
|
|
39
|
-
For more details and options, [check out the documentation](http://www.rubydoc.info/gems/awesome_loader).
|
41
|
+
For more details and options, [check out the documentation](http://www.rubydoc.info/gems/awesome_loader/1.1.0).
|
40
42
|
|
41
43
|
## Eager Loading
|
42
44
|
|
@@ -92,11 +92,25 @@ module AwesomeLoader
|
|
92
92
|
self
|
93
93
|
end
|
94
94
|
|
95
|
+
#
|
96
|
+
# Same as Ruby's built-in require, except that it accepts a blob and requires all matching files.
|
97
|
+
# The require is immediate, the path is relative to the root_path, and no dir modules are created.
|
98
|
+
#
|
99
|
+
# @param glob [Array<String>] A glob pattern as an array.
|
100
|
+
# @return [AwesomeLoader::Autoloader] returns self, so you can chain calls
|
101
|
+
#
|
102
|
+
def require(glob)
|
103
|
+
Dir.glob(File.join root_path.to_s, *glob).each do |file|
|
104
|
+
Kernel.require file
|
105
|
+
end
|
106
|
+
self
|
107
|
+
end
|
108
|
+
|
95
109
|
#
|
96
110
|
# Perform any final operations or cleanup. If eager_load is true, this is where they're loaded.
|
97
111
|
#
|
98
112
|
def finalize!
|
99
|
-
all_files.each { |f| require f } if eager_load
|
113
|
+
all_files.each { |f| Kernel.require f } if eager_load
|
100
114
|
all_files.clear
|
101
115
|
self
|
102
116
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awesome_loader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordan Hollinger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: An awesome wrapper for Ruby's built-in autoload
|
14
14
|
email: jordan.hollinger@gmail.com
|