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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 251b662a3b3fa4fbb57b49ba2221129c156f8844
4
- data.tar.gz: bfa7481ad5aaddabb1f936f37a0cf7fede8fcf8c
3
+ metadata.gz: a8d1e0254ff832c3f8dbdc6ab4198a7ef5a6d7ad
4
+ data.tar.gz: 7e1f8bb5dce71966b91ea1b1e00a3cb5b1b61906
5
5
  SHA512:
6
- metadata.gz: f5a3019008b0bd2ca68d58a3625603606bdeeb3ed1c9f352dbd05c80c0bcd2b8f3b4aaf165af9e1b61028c79f3fcfa52013303dd2e5918f30e494c75e6d8c712
7
- data.tar.gz: 2e198a51f1ebced488274f322971a21e64375086bfd53600714d26e95bfb33abe668063b56c917dec3a25a046480d9431e1cbee06cf16edb68f280268c0865c1
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 first few work just like above
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
@@ -1,4 +1,4 @@
1
1
  module AwesomeLoader
2
2
  # Library version
3
- VERSION = '1.1.0'.freeze
3
+ VERSION = '1.3.0'.freeze
4
4
  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.1.0
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-10 00:00:00.000000000 Z
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