autoloaded 2.1.1 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.gitignore +4 -8
- data/.rspec +1 -1
- data/.travis.yml +20 -0
- data/Gemfile +14 -9
- data/Gemfile_ci_mri_19 +7 -0
- data/Guardfile +21 -22
- data/History.md +35 -10
- data/License.md +1 -1
- data/README.md +82 -68
- data/Rakefile +4 -0
- data/autoloaded.gemspec +41 -37
- data/bin/console +10 -0
- data/bin/setup +8 -0
- data/lib/autoloaded/autoloader.rb +24 -6
- data/lib/autoloaded/deprecation.rb +0 -2
- data/lib/autoloaded/inflection.rb +0 -2
- data/lib/autoloaded/load_pathed_directory.rb +2 -4
- data/lib/autoloaded/specification.rb +2 -0
- data/lib/autoloaded/specifications.rb +3 -3
- data/lib/autoloaded/version.rb +1 -1
- data/lib/autoloaded/warning.rb +1 -3
- data/lib/tasks/lib_each.rake +15 -3
- data/lib/tasks/spec.rake +3 -6
- metadata +20 -85
- data/spec/autoloaded/autoloader_spec.rb +0 -469
- data/spec/autoloaded/inflection_spec.rb +0 -30
- data/spec/autoloaded/load_pathed_directory_spec.rb +0 -120
- data/spec/autoloaded/specification_spec.rb +0 -98
- data/spec/autoloaded/specifications_spec.rb +0 -191
- data/spec/autoloaded/version_spec.rb +0 -3
- data/spec/autoloaded/warning_spec.rb +0 -115
- data/spec/autoloaded_macro_sharedspec.rb +0 -24
- data/spec/autoloaded_spec.rb +0 -173
- data/spec/fixtures/autoloaded_with_conventional_filename/N-est-ed.rb +0 -1
- data/spec/fixtures/autoloaded_with_conventional_filename/nest_ed.rb +0 -1
- data/spec/fixtures/autoloaded_with_conventional_filename/nested/doubly_nested.rb +0 -9
- data/spec/fixtures/autoloaded_with_conventional_filename/nested.rb +0 -16
- data/spec/fixtures/autoloaded_with_conventional_filename/old_school_autoload.rb +0 -5
- data/spec/fixtures/autoloaded_with_conventional_filename.rb +0 -12
- data/spec/fixtures/autoloaded_with_unconventional_filename/N-est-ed.rb +0 -7
- data/spec/fixtures/autoloaded_with_unconventional_filename/nest_ed.rb +0 -1
- data/spec/fixtures/autoloaded_with_unconventional_filename/old_school_autoload.rb +0 -5
- data/spec/fixtures/autoloaded_with_unconventional_filename.rb +0 -12
- data/spec/fixtures/filenames/AFilename.rb +0 -0
- data/spec/fixtures/filenames/a-file-name.rb +0 -0
- data/spec/fixtures/filenames/a-filename.rb +0 -0
- data/spec/fixtures/filenames/a_file_name.rb +0 -0
- data/spec/fixtures/filenames/a_filename.rb +0 -0
- data/spec/fixtures/filenames/afile-name.rb +0 -0
- data/spec/fixtures/filenames/afile_name.rb +0 -0
- data/spec/fixtures/not_autoloaded/nested.rb +0 -1
- data/spec/fixtures/not_autoloaded/old_school_autoload.rb +0 -5
- data/spec/fixtures/not_autoloaded.rb +0 -5
- data/spec/matchers.rb +0 -85
- data/spec/spec_helper.rb +0 -91
- data/spec/support/util.rb +0 -42
- data/spec/support/without_side_effects.rb +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4b09d46cc2228470952ca437e81c62d2ea3ac49d424b1e8bbffbc96dcff30696
|
4
|
+
data.tar.gz: 44678d29ea7284e29d62f2fb408d33a9c4f679f34905b864b02f56dd9e1a41fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b881749824f44669e8791ccb52c798b17976b5102f22e2d05e591e150f2fd7ca78fcb0384ff6ef27321cfddef0f5ac975f09b1cb5ce3f0375d732dc80210b039
|
7
|
+
data.tar.gz: 8db7e680a19458b5f4871f13ffbef88a58c7db78f2ac2a0fafc1420a5fabc1aa7b84e2988cfbf1ca50504fac91d2b18dfb7bada0fdf6b3162a298ce643ee86ac
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
data/.travis.yml
CHANGED
@@ -4,10 +4,30 @@ rvm:
|
|
4
4
|
- 1.9
|
5
5
|
- 2.0
|
6
6
|
- 2.1
|
7
|
+
- 2.2
|
8
|
+
- 2.3
|
9
|
+
- 2.4
|
10
|
+
- 2.5
|
11
|
+
- 2.6
|
12
|
+
- 2.7
|
13
|
+
- 3.0
|
7
14
|
- ruby-head
|
8
15
|
- jruby-head
|
16
|
+
- rbx
|
17
|
+
- rbx-2
|
9
18
|
script: "bundle exec rake test"
|
10
19
|
matrix:
|
11
20
|
allow_failures:
|
21
|
+
- rvm: 1.9
|
12
22
|
- rvm: ruby-head
|
13
23
|
- rvm: jruby-head
|
24
|
+
- rvm: rbx
|
25
|
+
- rvm: rbx-2
|
26
|
+
exclude:
|
27
|
+
- rvm: 1.9
|
28
|
+
include:
|
29
|
+
- rvm: 1.9
|
30
|
+
gemfile: Gemfile_ci_mri_19
|
31
|
+
branches:
|
32
|
+
except:
|
33
|
+
- /^gh-pages.*$/
|
data/Gemfile
CHANGED
@@ -3,22 +3,27 @@ source 'https://rubygems.org'
|
|
3
3
|
gemspec
|
4
4
|
|
5
5
|
group :debug do
|
6
|
-
gem 'pry-byebug',
|
7
|
-
|
6
|
+
gem 'pry-byebug', '~> 3', platforms: [:mri_20,
|
7
|
+
:mri_21,
|
8
|
+
:mri_22,
|
9
|
+
:mri_23,
|
10
|
+
:mri_24,
|
11
|
+
:mri_25]
|
12
|
+
gem 'pry-debugger', '~> 0', platforms: :mri_19
|
8
13
|
end
|
9
14
|
|
10
|
-
group :
|
11
|
-
gem '
|
12
|
-
gem 'rdiscount', '~> 2', require: false, platforms: :mri
|
15
|
+
group :development do
|
16
|
+
gem 'json', '~> 2', require: false
|
13
17
|
end
|
14
18
|
|
15
|
-
group :
|
16
|
-
gem '
|
19
|
+
group :doc do
|
20
|
+
gem 'yard', '>= 0.9.11', '< 1', require: false
|
21
|
+
gem 'rdiscount', '~> 2', require: false
|
17
22
|
end
|
18
23
|
|
19
24
|
group :tooling do
|
20
|
-
gem 'guard-rspec',
|
25
|
+
gem 'guard-rspec', '~> 4', require: false
|
21
26
|
if RUBY_PLATFORM =~ /darwin/i
|
22
|
-
gem 'rb-fsevent',
|
27
|
+
gem 'rb-fsevent', '~> 0', require: false
|
23
28
|
end
|
24
29
|
end
|
data/Gemfile_ci_mri_19
ADDED
data/Guardfile
CHANGED
@@ -1,38 +1,37 @@
|
|
1
|
-
|
1
|
+
require 'guard/rspec/dsl'
|
2
2
|
|
3
3
|
debugger_gem = %w(pry-byebug pry-debugger).detect do |gem|
|
4
4
|
`bundle show #{gem} 2>&1 >/dev/null`
|
5
5
|
$?.success?
|
6
6
|
end
|
7
7
|
debugger_require = debugger_gem ? " --require #{debugger_gem}" : nil
|
8
|
-
guard :rspec, all_after_pass: true,
|
9
|
-
all_on_start: true,
|
10
|
-
cmd: "bundle exec rspec#{debugger_require} --format progress" do
|
11
|
-
# Run the corresponding spec (or all specs) when code changes.
|
12
|
-
watch( %r{^lib/(.+)\.rb$} ) do |match|
|
13
|
-
Dir["spec/#{match[1]}_spec.rb"].first || 'spec'
|
14
|
-
end
|
15
8
|
|
16
|
-
|
17
|
-
|
9
|
+
guard :rspec, all_on_start: true,
|
10
|
+
all_after_pass: true,
|
11
|
+
cmd: "bundle exec rspec --format progress#{debugger_require}" do
|
12
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
13
|
+
rspec, ruby = dsl.rspec, dsl.ruby
|
18
14
|
|
19
|
-
#
|
20
|
-
watch(
|
15
|
+
# RSpec files
|
16
|
+
watch('.rspec') { rspec.spec_dir }
|
17
|
+
watch rspec.spec_helper { rspec.spec_dir }
|
18
|
+
watch rspec.spec_support { rspec.spec_dir }
|
19
|
+
watch(%r{^spec/support}) { rspec.spec_dir } # This should not be necessary.
|
20
|
+
watch rspec.spec_files
|
21
21
|
|
22
22
|
# Run all specs when a matcher changes.
|
23
|
-
watch(
|
23
|
+
watch('spec/matchers.rb') { 'spec' }
|
24
24
|
|
25
|
-
# Run all specs when a
|
26
|
-
watch(
|
25
|
+
# Run all specs when a shared spec changes.
|
26
|
+
watch(%r{^spec/.+_sharedspec\.rb$}) { rspec.spec_dir }
|
27
27
|
|
28
28
|
# Run all specs when a fixture changes.
|
29
|
-
watch(
|
30
|
-
|
31
|
-
# Run all specs when the RSpec configuration changes.
|
32
|
-
watch( '.rspec' ) { 'spec' }
|
33
|
-
watch( 'spec/spec_helper.rb' ) { 'spec' }
|
29
|
+
watch(%r{^spec/fixtures}) { rspec.spec_dir }
|
34
30
|
|
35
31
|
# Run all specs when the bundle changes.
|
36
|
-
watch(
|
37
|
-
watch(
|
32
|
+
watch('Gemfile.lock') { rspec.spec_dir }
|
33
|
+
watch(%r{^(.+)\.gemspec$}) { rspec.spec_dir }
|
34
|
+
|
35
|
+
# Ruby files
|
36
|
+
dsl.watch_spec_files_for ruby.lib_files
|
38
37
|
end
|
data/History.md
CHANGED
@@ -1,8 +1,28 @@
|
|
1
|
-
# Version history for the
|
1
|
+
# Version history for the *Autoloaded* project
|
2
|
+
|
3
|
+
## <a name="v2.4.0"></a>v2.4.0 and <a name="v1.7.0"></a>v1.7.0, Sat 9/19/2021
|
4
|
+
|
5
|
+
* Add support for Ruby v3 (thanks to [@krimsonkla][GitHub-user-krimsonkla])
|
6
|
+
|
7
|
+
## <a name="v2.3.0"></a>v2.3.0 and <a name="v1.6.0"></a>v1.6.0, Sun 4/05/2020
|
8
|
+
|
9
|
+
* Eliminate Ruby warnings about
|
10
|
+
[*Binding#source_location*][Ruby-Core-Binding-source_location] (thanks to
|
11
|
+
[@guss77][GitHub-user-guss77])
|
12
|
+
|
13
|
+
## <a name="v2.2.1"></a>v2.2.1 and <a name="v1.5.1"></a>v1.5.1, Wed 10/18/2017
|
14
|
+
|
15
|
+
* Eliminate Ruby warnings about undefined instance variables
|
16
|
+
|
17
|
+
## <a name="v2.2.0"></a>v2.2.0 and <a name="v1.5.0"></a>v1.5.0, Wed 2/22/2017
|
18
|
+
|
19
|
+
* Add support for Ruby load paths (`$:`) that contain one or more
|
20
|
+
[*Pathname*][Ruby-Stdlib-Pathname] objects (thanks to
|
21
|
+
[@ekampp][GitHub-user-ekampp])
|
2
22
|
|
3
23
|
## <a name="v2.1.1"></a>v2.1.1 and <a name="v1.4.1"></a>v1.4.1, Sat 1/24/2015
|
4
24
|
|
5
|
-
* Don’t warn about a
|
25
|
+
* Don’t warn about a *VERSION* constant presumably loaded by a *.gemspec*
|
6
26
|
|
7
27
|
## <a name="v2.0.0"></a>v2.0.0, Sat 12/27/2014
|
8
28
|
|
@@ -21,11 +41,11 @@
|
|
21
41
|
|
22
42
|
* Correct/improve autoload behavior
|
23
43
|
* Instead of returning the source **directory** path from
|
24
|
-
[
|
44
|
+
[*Module#autoload?*][Ruby-Core-Module-autoload], return one or more matching
|
25
45
|
source **file** path(s)
|
26
46
|
* Use Ruby load path (`$:`) to handle relative source file paths
|
27
|
-
* Explain
|
28
|
-
[
|
47
|
+
* Explain *Module#autoload?* and
|
48
|
+
[*Module#constants*][Ruby-Core-Module-constants] in the [readme][readme] and
|
29
49
|
in [inline documentation][inline-documentation]
|
30
50
|
|
31
51
|
## <a name="v1.0.0"></a>v1.0.0, Wed 10/29/2014
|
@@ -36,8 +56,13 @@
|
|
36
56
|
|
37
57
|
(First release)
|
38
58
|
|
39
|
-
[
|
40
|
-
[
|
41
|
-
[
|
42
|
-
[
|
43
|
-
[
|
59
|
+
[GitHub-user-krimsonkla]: https://github.com/krimsonkla "GitHub user @krimsonkla"
|
60
|
+
[GitHub-user-ekampp]: https://github.com/ekampp "GitHub user @ekampp"
|
61
|
+
[GitHub-user-guss77]: https://github.com/guss77 "GitHub user @guss77"
|
62
|
+
[JRuby]: https://www.jruby.org/
|
63
|
+
[Ruby-Core-Binding-source_location]: https://ruby-doc.org/core/Binding.html#method-i-source_location "‘Binding#source_location’ method in the Ruby Core Library"
|
64
|
+
[Ruby-Core-Module-autoload]: https://ruby-doc.org/core/Module.html#method-i-autoload-3F "‘Module#autoload’ method in the Ruby Core Library"
|
65
|
+
[Ruby-Core-Module-constants]: https://ruby-doc.org/core/Module.html#method-i-constants "‘Module#constants’ method in the Ruby Core Library"
|
66
|
+
[Ruby-Stdlib-Pathname]: https://ruby-doc.org/stdlib/libdoc/pathname/rdoc/Pathname.html "‘Pathname’ class in the Ruby Standard Library"
|
67
|
+
[readme]: https://github.com/njonsson/autoloaded/blob/master/README.md "Autoloaded readme"
|
68
|
+
[inline-documentation]: https://www.rubydoc.info/github/njonsson/autoloaded "Autoloaded inline documentation"
|
data/License.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License
|
2
2
|
|
3
|
-
Source code for
|
3
|
+
Source code for *Autoloaded* is Copyright © 2014 [Nils Jonsson][mail] and
|
4
4
|
[contributors][contributors].
|
5
5
|
|
6
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
data/README.md
CHANGED
@@ -6,18 +6,17 @@
|
|
6
6
|
[![Code Climate quality report] ][Code-Climate-report]
|
7
7
|
[![Code Climate coverage report]][Code-Climate-report]
|
8
8
|
|
9
|
-
[![Gemnasium build status] ][Gemnasium-build-status]
|
10
9
|
[![Inch CI build status] ][Inch-CI-build-status]
|
11
10
|
[![RubyGems release] ][RubyGems-release]
|
12
11
|
|
13
|
-
If you like the [
|
14
|
-
Ruby Core library, you may have wished for
|
12
|
+
If you like the [*Module#autoload*][Ruby-Core-Module-autoload] feature of the
|
13
|
+
Ruby Core library, you may have wished for *Autoloaded*. It eliminates the
|
15
14
|
drudgery of handcrafting an `autoload` statement for each Ruby source code file
|
16
15
|
in your project. It also avoids the limitations of rigid convention-driven
|
17
16
|
facilities such as those provided by the [ActiveSupport][ActiveSupport-Autoload]
|
18
17
|
RubyGem.
|
19
18
|
|
20
|
-
|
19
|
+
*Autoloaded* assumes, but does not enforce, `CamelCase`-to-`snake_case`
|
21
20
|
correspondence between the names of constants and source files. You can combine
|
22
21
|
conventions, even putting multiple autoloaded constants in a single source file.
|
23
22
|
|
@@ -27,7 +26,7 @@ Install [the RubyGem][RubyGems-release].
|
|
27
26
|
|
28
27
|
$ gem install autoloaded
|
29
28
|
|
30
|
-
Use
|
29
|
+
Use *Autoloaded* in your RubyGem project by making it a runtime dependency.
|
31
30
|
|
32
31
|
```ruby
|
33
32
|
# my_awesome_gem.gemspec
|
@@ -39,13 +38,13 @@ Gem::Specification.new do |spec|
|
|
39
38
|
end
|
40
39
|
```
|
41
40
|
|
42
|
-
Or you may want to make
|
41
|
+
Or you may want to make *Autoloaded* a dependency of your project by using
|
43
42
|
[Bundler][Bundler].
|
44
43
|
|
45
44
|
```ruby
|
46
45
|
# Gemfile
|
47
46
|
|
48
|
-
source '
|
47
|
+
source 'https://rubygems.org'
|
49
48
|
|
50
49
|
gem 'autoloaded', '~> 2'
|
51
50
|
```
|
@@ -66,15 +65,15 @@ Suppose you have the following source files.
|
|
66
65
|
│ └─ version.rb
|
67
66
|
└─ my_awesome_gem.rb
|
68
67
|
|
69
|
-
### The
|
68
|
+
### The *Autoloaded.module* or *Autoloaded.class* method
|
70
69
|
|
71
|
-
The
|
72
|
-
[
|
70
|
+
The *Autoloaded.module* and *Autoloaded.class* method calls below invoke
|
71
|
+
[*Module#autoload*][Ruby-Core-Module-autoload] for each source file in the
|
73
72
|
calling module’s corresponding directory. Note that these methods must receive a
|
74
73
|
block, even if it’s an empty block.
|
75
74
|
|
76
75
|
The file paths used are abbreviated, if possible, using a directory of the Ruby
|
77
|
-
load path (`$:`). They are also rendered without their
|
76
|
+
load path (`$:`). They are also rendered without their *.rb* extension.
|
78
77
|
|
79
78
|
```ruby
|
80
79
|
# lib/my_awesome_gem.rb
|
@@ -152,7 +151,7 @@ MyAwesomeGem::DB::Mysql # Raises NameError because
|
|
152
151
|
|
153
152
|
### The `with` specification
|
154
153
|
|
155
|
-
|
154
|
+
*Autoloaded* needs hints from you concerning unpredictable spellings,
|
156
155
|
stylization, and organization of constant names and/or source file names. You can
|
157
156
|
specify `with` as:
|
158
157
|
|
@@ -173,21 +172,21 @@ You can specify `with` multiple times, and its effects are cumulative.
|
|
173
172
|
# lib/my_awesome_gem.rb
|
174
173
|
module MyAwesomeGem
|
175
174
|
|
176
|
-
Autoloaded.module do |
|
177
|
-
|
175
|
+
Autoloaded.module do |autoloading|
|
176
|
+
autoloading.with :DB, :VERSION
|
178
177
|
# Or:
|
179
|
-
#
|
180
|
-
#
|
178
|
+
# autoloading.with :DB
|
179
|
+
# autoloading.with :VERSION
|
181
180
|
# Or:
|
182
|
-
#
|
181
|
+
# autoloading.with DB: 'db', VERSION: 'version'
|
183
182
|
# Or:
|
184
|
-
#
|
185
|
-
#
|
183
|
+
# autoloading.with DB: 'db'
|
184
|
+
# autoloading.with VERSION: 'version'
|
186
185
|
# Or:
|
187
|
-
#
|
186
|
+
# autoloading.with 'db' => :DB, 'version' => :VERSION
|
188
187
|
# Or:
|
189
|
-
#
|
190
|
-
#
|
188
|
+
# autoloading.with 'db' => :DB
|
189
|
+
# autoloading.with 'version' => :VERSION
|
191
190
|
end
|
192
191
|
|
193
192
|
# The above is the equivalent of:
|
@@ -202,20 +201,22 @@ module MyAwesomeGem
|
|
202
201
|
|
203
202
|
class DB
|
204
203
|
|
205
|
-
Autoloaded.class do |
|
206
|
-
|
204
|
+
Autoloaded.class do |autoloading|
|
205
|
+
autoloading.with :MySQL, :PostgreSQL, [:Access, :SQLServer] => 'MicroSoft'
|
207
206
|
# Or:
|
208
|
-
#
|
209
|
-
#
|
210
|
-
#
|
211
|
-
#
|
207
|
+
# autoloading.with :MySQL,
|
208
|
+
# :PostgreSQL,
|
209
|
+
# Access: 'MicroSoft',
|
210
|
+
# SQLServer: 'MicroSoft'
|
212
211
|
# Or:
|
213
|
-
#
|
212
|
+
# autoloading.with :MySQL,
|
213
|
+
# :PostgreSQL,
|
214
|
+
# 'MicroSoft' => [:Access, :SQLServer]
|
214
215
|
# Or:
|
215
|
-
#
|
216
|
-
#
|
217
|
-
#
|
218
|
-
#
|
216
|
+
# autoloading.with :MySQL,
|
217
|
+
# :PostgreSQL,
|
218
|
+
# 'MicroSoft' => :Access,
|
219
|
+
# 'MicroSoft' => :SQLServer
|
219
220
|
# Or ...
|
220
221
|
end
|
221
222
|
|
@@ -283,12 +284,12 @@ module MyAwesomeGem
|
|
283
284
|
|
284
285
|
class DB
|
285
286
|
|
286
|
-
Autoloaded.class do |
|
287
|
-
|
287
|
+
Autoloaded.class do |autoloading|
|
288
|
+
autoloading.with :MySQL, :PostgreSQL, [:Access, :SQLServer] => 'MicroSoft'
|
288
289
|
|
289
|
-
|
290
|
+
autoloading.except 'SELF-DESTRUCT!'
|
290
291
|
# Or:
|
291
|
-
#
|
292
|
+
# autoloading.except :SELF_DESTRUCT_
|
292
293
|
# Or ...
|
293
294
|
end
|
294
295
|
|
@@ -340,9 +341,9 @@ cumulative.
|
|
340
341
|
|
341
342
|
### The `from` specification
|
342
343
|
|
343
|
-
It’s recommended that you call
|
344
|
+
It’s recommended that you call *Autoloaded.module* or *Autoloaded.class* from
|
344
345
|
within the source file where your module or class is defined. This practice
|
345
|
-
allows
|
346
|
+
allows *Autoloaded* to assume that the source files to be autoloaded are in a
|
346
347
|
directory of the same name (and in the same location) as the module’s defining
|
347
348
|
source file.
|
348
349
|
|
@@ -357,12 +358,12 @@ which source files should be autoloaded.
|
|
357
358
|
|
358
359
|
module MyAwesomeGem
|
359
360
|
|
360
|
-
Autoloaded.module do |
|
361
|
+
Autoloaded.module do |autoloading|
|
361
362
|
# The following code is not actually very useful since the installed location
|
362
363
|
# of a RubyGem varies with the operating system and user preferences. How to
|
363
364
|
# compute the path properly is outside the scope of this readme and is left
|
364
365
|
# as an exercise for the reader.
|
365
|
-
|
366
|
+
autoloading.from '/absolute/path/to/my_awesome_gem'
|
366
367
|
end
|
367
368
|
|
368
369
|
end
|
@@ -371,18 +372,18 @@ end
|
|
371
372
|
A path provided to `from` cannot be relative; it must start with the filesystem
|
372
373
|
root.
|
373
374
|
|
374
|
-
If you specify `from` multiple times in an
|
375
|
+
If you specify `from` multiple times in an *Autoloaded* block, only the last one
|
375
376
|
takes effect.
|
376
377
|
|
377
|
-
### The
|
378
|
+
### The *Autoloaded.warn* method
|
378
379
|
|
379
|
-
There are two circumstances under which
|
380
|
+
There are two circumstances under which *Autoloaded* by default will write
|
380
381
|
warnings to stderr:
|
381
382
|
|
382
383
|
* Overriding an established autoload
|
383
384
|
* Establishing an autoload for a defined constant
|
384
385
|
|
385
|
-
You can silence these warnings by passing `false` to
|
386
|
+
You can silence these warnings by passing `false` to *Autoloaded.warn*. (Passing
|
386
387
|
`true` turns warnings on if they are off.)
|
387
388
|
|
388
389
|
```ruby
|
@@ -438,7 +439,7 @@ end
|
|
438
439
|
|
439
440
|
### How to debug autoloading
|
440
441
|
|
441
|
-
The
|
442
|
+
The *Autoloaded.module* or *Autoloaded.class* method returns an ordered list of
|
442
443
|
arguments it has passed to `autoload`.
|
443
444
|
|
444
445
|
```ruby
|
@@ -448,9 +449,11 @@ module MyAwesomeGem
|
|
448
449
|
|
449
450
|
class DB
|
450
451
|
|
451
|
-
results = Autoloaded.class do |
|
452
|
-
|
453
|
-
|
452
|
+
results = Autoloaded.class do |autoloading|
|
453
|
+
autoloading.with :MySQL,
|
454
|
+
:PostgreSQL,
|
455
|
+
[:Access, :SQLServer] => 'MicroSoft'
|
456
|
+
autoloading.except 'SELF-DESTRUCT!'
|
454
457
|
end
|
455
458
|
STDOUT.puts results.inspect # See output below.
|
456
459
|
|
@@ -465,20 +468,20 @@ end
|
|
465
468
|
# [:PostgreSQL, 'my_awesome_gem/db/postgre_sql']]
|
466
469
|
```
|
467
470
|
|
468
|
-
You can also hook [
|
469
|
-
[
|
471
|
+
You can also hook [*Module#autoload*][Ruby-Core-Module-autoload] and
|
472
|
+
[*Kernel#autoload*][Ruby-Core-Kernel-autoload] via monkeypatching or other means
|
470
473
|
in order to see what’s happening.
|
471
474
|
|
472
475
|
### Source filenames are relative to the `from` specification
|
473
476
|
|
474
477
|
You may have noticed that source filenames in the above examples are not
|
475
|
-
absolute. They are relative to the
|
478
|
+
absolute. They are relative to the *Autoloaded* block’s `from` specification
|
476
479
|
(which I recommend that you allow to be computed for you —
|
477
480
|
[see above](#the-from-specification)).
|
478
481
|
|
479
482
|
### Recursive autoloading not supported
|
480
483
|
|
481
|
-
|
484
|
+
*Autoloaded* does not perform deep autoloading of nested namespaces and
|
482
485
|
directories. This is by design.
|
483
486
|
|
484
487
|
## Contributing
|
@@ -489,6 +492,19 @@ directories. This is by design.
|
|
489
492
|
4. Push to the branch: `git push origin my-new-feature`.
|
490
493
|
5. [Create][compare-Autoloaded-branches] a new pull request.
|
491
494
|
|
495
|
+
Development
|
496
|
+
-----------
|
497
|
+
|
498
|
+
After cloning the repository, `bin/setup` to install dependencies. Then `rake` to
|
499
|
+
run the tests. You can also `bin/console` to get an interactive prompt that will
|
500
|
+
allow you to experiment.
|
501
|
+
|
502
|
+
To install this gem onto your local machine, `bundle exec rake install`. To
|
503
|
+
release a new version, update the version number in *lib/autoloaded/version.rb*,
|
504
|
+
and then `bundle exec rake release`, which will create a Git tag for the version,
|
505
|
+
push Git commits and tags, and push the *.gem* file to
|
506
|
+
[RubyGems.org](RubyGems-release).
|
507
|
+
|
492
508
|
## License
|
493
509
|
|
494
510
|
Released under the [MIT License][MIT-License].
|
@@ -497,20 +513,18 @@ Released under the [MIT License][MIT-License].
|
|
497
513
|
[Travis CI build status]: https://secure.travis-ci.org/njonsson/autoloaded.svg?branch=master
|
498
514
|
[Code Climate quality report]: https://codeclimate.com/github/njonsson/autoloaded/badges/gpa.svg
|
499
515
|
[Code Climate coverage report]: https://codeclimate.com/github/njonsson/autoloaded/badges/coverage.svg
|
500
|
-
[
|
501
|
-
[Inch CI build status]: http://inch-ci.org/github/njonsson/autoloaded.svg?branch=master
|
516
|
+
[Inch CI build status]: https://www.inch-ci.org/github/njonsson/autoloaded.svg?branch=master
|
502
517
|
[RubyGems release]: https://badge.fury.io/rb/autoloaded.svg
|
503
518
|
|
504
|
-
[spider-gear-image]: https://www.flickr.com/photos/dongkwan/4941065976
|
505
|
-
[Travis-CI-build-status]:
|
506
|
-
[Code-Climate-report]:
|
507
|
-
[
|
508
|
-
[
|
509
|
-
[
|
510
|
-
[
|
511
|
-
[
|
512
|
-
[
|
513
|
-
[
|
514
|
-
[
|
515
|
-
[
|
516
|
-
[MIT-License]: http://github.com/njonsson/autoloaded/blob/master/License.md "MIT License claim for Autoloaded"
|
519
|
+
[spider-gear-image]: https://www.flickr.com/photos/dongkwan/4941065976 "spider gear image by Ernesto Andrade"
|
520
|
+
[Travis-CI-build-status]: https://www.travis-ci.org/njonsson/autoloaded "Travis CI build status for Autoloaded"
|
521
|
+
[Code-Climate-report]: https://codeclimate.com/github/njonsson/autoloaded "Code Climate report for Autoloaded"
|
522
|
+
[Inch-CI-build-status]: https://www.inch-ci.org/github/njonsson/autoloaded "Inch CI build status for Autoloaded"
|
523
|
+
[RubyGems-release]: https://rubygems.org/gems/autoloaded "RubyGems release of Autoloaded"
|
524
|
+
[Ruby-Core-Module-autoload]: https://ruby-doc.org/core/Module.html#method-i-autoload "‘Module#autoload’ method in the Ruby Core Library"
|
525
|
+
[ActiveSupport-Autoload]: https://api.rubyonrails.org/classes/ActiveSupport/Autoload.html "‘ActiveSupport::Autoload’ module in the Rails API"
|
526
|
+
[Bundler]: https://bundler.io/
|
527
|
+
[Ruby-Core-Kernel-autoload]: https://ruby-doc.org/core/Kernel.html#method-i-autoload "‘Kernel#autoload’ method in the Ruby Core Library"
|
528
|
+
[fork-Autoloaded]: https://github.com/njonsson/autoloaded/fork "Fork the official repository of Autoloaded"
|
529
|
+
[compare-Autoloaded-branches]: https://github.com/njonsson/autoloaded/compare "Compare branches of Autoloaded repositories"
|
530
|
+
[MIT-License]: https://github.com/njonsson/autoloaded/blob/master/License.md "MIT License claim for Autoloaded"
|