subload 1.0.3 → 1.1.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.
- data/CHANGELOG.rdoc +7 -0
- data/Manifest.txt +19 -0
- data/README.rdoc +117 -0
- data/Rakefile +19 -101
- data/lib/subload.rb +4 -2
- data/subload.gemspec +52 -0
- data/test/test_subload.rb +7 -3
- metadata +82 -27
- data/README +0 -77
data/CHANGELOG.rdoc
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
CHANGELOG.rdoc
|
2
|
+
Manifest.txt
|
3
|
+
README.rdoc
|
4
|
+
Rakefile
|
5
|
+
examples/a.rb
|
6
|
+
examples/a/foo.rb
|
7
|
+
examples/a/foo/bar.rb
|
8
|
+
examples/a/foo/baz.rb
|
9
|
+
examples/rails/loader.rb
|
10
|
+
lib/subload.rb
|
11
|
+
subload.gemspec
|
12
|
+
test/test_subload.rb
|
13
|
+
test/test_subload/a.rb
|
14
|
+
test/test_subload/b.rb
|
15
|
+
test/test_subload/c.rb
|
16
|
+
test/test_subload/d.rb
|
17
|
+
test/test_subload/e.rb
|
18
|
+
test/test_subload/f.rb
|
19
|
+
test/test_subload/f/a.rb
|
data/README.rdoc
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
= subload
|
2
|
+
|
3
|
+
* http://rubygems.org/gems/subload
|
4
|
+
* docs: http://libraggi.rubyforge.org/subload/
|
5
|
+
* source: http://github.com/raggi/subload/
|
6
|
+
* issues: http://github.com/raggi/subload/issues
|
7
|
+
* rubyforge: http://rubyforge.org/projects/libraggi
|
8
|
+
|
9
|
+
== DESCRIPTION:
|
10
|
+
|
11
|
+
A handy dandy autoload / require / load helper for your rubies. Similar to
|
12
|
+
using[1], but with a few differences of opinion, and a bit shorter.
|
13
|
+
|
14
|
+
Basically, expand path is fine, up until a point. Sometimes there's no point
|
15
|
+
(i.e. when the load path already contains most of the path you're trying to
|
16
|
+
open). When you're writing libs that users might require sub parts with
|
17
|
+
'libname/sub_part', then expand_path combined with say, rubygems, can lead to
|
18
|
+
double requires. Lets not do that. :-)
|
19
|
+
|
20
|
+
[1] http://github.com/smtlaissezfaire/using/
|
21
|
+
|
22
|
+
== FEATURES/PROBLEMS:
|
23
|
+
|
24
|
+
* File.expand_path: Expand path is good if you're traversing up directories.
|
25
|
+
It is bad if you're loading something within a library that is on the load
|
26
|
+
path. If the library is on the load path, and you require files with an
|
27
|
+
expanded path, there is the likelihood of a double require when other code
|
28
|
+
contains a require that is expectant of the load path modification.
|
29
|
+
|
30
|
+
* Frameworks: Sometimes require explicit load order control. In these cases,
|
31
|
+
overriding the loader and either tracking, or performing stateful operations
|
32
|
+
works well.
|
33
|
+
|
34
|
+
* Abusive use of override_mode: Override mode is potentially dangerous. As per
|
35
|
+
the other documentation, override mode should be reserved for use in
|
36
|
+
application code only. Libraries setting override mode could cause
|
37
|
+
additional failure cases for foreign libraries, although gratuitous addition
|
38
|
+
of loading mechanisms is not recommended.
|
39
|
+
|
40
|
+
* Generated code loading: When you're doing code generation, sometimes it is
|
41
|
+
desirable to have tow locations from which to load a class. One will contain
|
42
|
+
custom class defintions, and the other will contain generated definitions.
|
43
|
+
Using a custom loader, one can then utilise a single subload statement to
|
44
|
+
correctly load both files.
|
45
|
+
|
46
|
+
* TODO Chaotic Overloading
|
47
|
+
|
48
|
+
* Consider vertical vs. horizontal delegation rules and use cases for new
|
49
|
+
loaders in non-framework libraries that perform custom loads such that it is
|
50
|
+
easy to say "invoke the current load mode with the following options".
|
51
|
+
|
52
|
+
== SYNOPSIS:
|
53
|
+
|
54
|
+
module A
|
55
|
+
|
56
|
+
# The nominal use case, A.autoload :B, 'a/b'
|
57
|
+
# You rarely need much else!
|
58
|
+
subload :B
|
59
|
+
|
60
|
+
# A custom path, A.autoload :C, 'a/c'
|
61
|
+
subload :C, :path => 'a/c'
|
62
|
+
# For example when 'a/c' defines several constants:
|
63
|
+
subload :Ca, :path => 'a/c'
|
64
|
+
subload :Cb, :path => 'a/c'
|
65
|
+
|
66
|
+
# An expanded path, A.autoload :D, File.join(Dir.pwd, 'a/d')
|
67
|
+
subload :D, :expand_path => true
|
68
|
+
# This has interesting uses in combination, although not generally
|
69
|
+
# recommended:
|
70
|
+
subload :E, :path => '../../path/e', :expand_path => true
|
71
|
+
|
72
|
+
# Explicitly override the mode, for this call only, A.require 'a/f'
|
73
|
+
subload :F, :mode => :require
|
74
|
+
|
75
|
+
# Set the mode for all subsiquent calls to subload in this class/module
|
76
|
+
subload_with :require
|
77
|
+
subload :G # => require 'a/g'
|
78
|
+
subload :H # => require 'a/h'
|
79
|
+
|
80
|
+
# Other features intended for library and framework developers are described
|
81
|
+
# in the class documentation.
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
== REQUIREMENTS:
|
87
|
+
|
88
|
+
* ruby
|
89
|
+
|
90
|
+
== INSTALL:
|
91
|
+
|
92
|
+
* gem install subload
|
93
|
+
|
94
|
+
== LICENSE:
|
95
|
+
|
96
|
+
(The MIT License)
|
97
|
+
|
98
|
+
Copyright (c) 2010 James Tucker <raggi@rubyforge.org>
|
99
|
+
|
100
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
101
|
+
a copy of this software and associated documentation files (the
|
102
|
+
'Software'), to deal in the Software without restriction, including
|
103
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
104
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
105
|
+
permit persons to whom the Software is furnished to do so, subject to
|
106
|
+
the following conditions:
|
107
|
+
|
108
|
+
The above copyright notice and this permission notice shall be
|
109
|
+
included in all copies or substantial portions of the Software.
|
110
|
+
|
111
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
112
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
113
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
114
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
115
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
116
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
117
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
CHANGED
@@ -1,109 +1,27 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
|
-
require 'rake/clean'
|
3
2
|
|
4
|
-
|
3
|
+
require 'hoe'
|
4
|
+
Hoe.plugin :doofus, :git, :gemcutter
|
5
5
|
|
6
|
-
|
7
|
-
@
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
def spec.filename; @filename; end
|
16
|
-
spec
|
17
|
-
end
|
6
|
+
hoe = Hoe.spec 'subload' do
|
7
|
+
developer "James Tucker", "raggi@rubyforge.org"
|
8
|
+
extra_dev_deps << %w(hoe-doofus >=1.0.0)
|
9
|
+
extra_dev_deps << %w(hoe-git >=1.3.0)
|
10
|
+
extra_dev_deps << %w(hoe-gemcutter >=1.0.0)
|
11
|
+
self.extra_rdoc_files = FileList["**/*.rdoc"]
|
12
|
+
self.history_file = "CHANGELOG.rdoc"
|
13
|
+
self.readme_file = "README.rdoc"
|
14
|
+
self.rubyforge_name = 'libraggi'
|
18
15
|
end
|
19
16
|
|
20
|
-
|
17
|
+
# TODO make a plugin to deal with this
|
18
|
+
gem_spec_file = hoe.spec.name + '.gemspec'
|
19
|
+
version_file = %Q{lib/#{hoe.spec.name}.rb}
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
rescue LoadError
|
26
|
-
require 'rake/gempackagetask'
|
27
|
-
Rake::GemPackageTask
|
21
|
+
desc "Generate #{gem_spec_file}"
|
22
|
+
file gem_spec_file => hoe.spec.files - [gem_spec_file] do
|
23
|
+
open(gem_spec_file, 'w') { |f| f.write hoe.spec.to_ruby }
|
28
24
|
end
|
29
|
-
def gem_task; @gem_task ||= @gem_package_task_type.new(spec); end
|
30
|
-
gem_task.define
|
31
|
-
Rake::Task[:clobber].enhance [:clobber_package]
|
32
25
|
|
33
|
-
|
34
|
-
|
35
|
-
t.test_files = spec.test_files
|
36
|
-
t.ruby_opts = ['-rubygems'] if defined? Gem
|
37
|
-
t.warning = true
|
38
|
-
end unless spec.test_files.empty?
|
39
|
-
|
40
|
-
rdoc_task_type = begin
|
41
|
-
require 'rdoc/task'
|
42
|
-
RDoc::Task
|
43
|
-
rescue LoadError
|
44
|
-
require 'rake/rdoctask'
|
45
|
-
Rake::RDocTask
|
46
|
-
end
|
47
|
-
df = begin; require 'rdoc/generator/darkfish'; true; rescue LoadError; end
|
48
|
-
rdtask = rdoc_task_type.new do |rd|
|
49
|
-
rd.title = spec.name
|
50
|
-
rd.main = spec.extra_rdoc_files.first
|
51
|
-
lib_rexp = spec.require_paths.map { |p| Regexp.escape p }.join('|')
|
52
|
-
rd.rdoc_files.include(*manifest.grep(/^(?:#{lib_rexp})/))
|
53
|
-
rd.rdoc_files.include(*spec.extra_rdoc_files)
|
54
|
-
rd.template = 'darkfish' if df
|
55
|
-
end
|
56
|
-
|
57
|
-
Rake::Task[:clobber].enhance [:clobber_rdoc]
|
58
|
-
|
59
|
-
require 'yaml'
|
60
|
-
require 'rake/contrib/sshpublisher'
|
61
|
-
desc "Publish rdoc to rubyforge"
|
62
|
-
task :publish => rdtask.name do
|
63
|
-
rf_cfg = File.expand_path '~/.rubyforge/user-config.yml'
|
64
|
-
host = "#{YAML.load_file(rf_cfg)['username']}@rubyforge.org"
|
65
|
-
remote_dir = "/var/www/gforge-projects/#{spec.rubyforge_project}/#{spec.name}/"
|
66
|
-
Rake::SshDirPublisher.new(host, remote_dir, rdtask.rdoc_dir).upload
|
67
|
-
end
|
68
|
-
|
69
|
-
desc 'Generate and open documentation'
|
70
|
-
task :docs => :rdoc do
|
71
|
-
path = rdtask.send :rdoc_target
|
72
|
-
case RUBY_PLATFORM
|
73
|
-
when /darwin/ ; sh "open #{path}"
|
74
|
-
when /mswin|mingw/ ; sh "start #{path}"
|
75
|
-
else
|
76
|
-
sh "firefox #{path}"
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
desc "Regenerate gemspec"
|
81
|
-
task :gemspec => spec.filename
|
82
|
-
|
83
|
-
task spec.filename do
|
84
|
-
spec.files = manifest
|
85
|
-
spec.test_files = FileList['{test,spec}/**/{test,spec}_*.rb']
|
86
|
-
open(spec.filename, 'w') { |w| w.write spec.to_ruby }
|
87
|
-
end
|
88
|
-
|
89
|
-
desc "Bump version from #{spec.version} to #{spec.version.to_s.succ}"
|
90
|
-
task :bump do
|
91
|
-
spec.version = spec.version.to_s.succ
|
92
|
-
end
|
93
|
-
|
94
|
-
desc "Tag version #{spec.version}"
|
95
|
-
task :tag do
|
96
|
-
tagged = Dir.new('.git/refs/tags').entries.include? spec.version.to_s
|
97
|
-
if tagged
|
98
|
-
warn "Tag #{spec.version} already exists"
|
99
|
-
else
|
100
|
-
# TODO release message in tag message
|
101
|
-
sh "git tag #{spec.version}"
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
desc "Release #{gem_task.gem_file} to rubyforge and gemcutter"
|
106
|
-
task :release => [:tag, :gem, :publish] do |t|
|
107
|
-
sh "rubyforge add_release #{spec.rubyforge_project} #{spec.name} #{spec.version} #{gem_task.package_dir}/#{gem_task.gem_file}"
|
108
|
-
sh "gem push #{gem_task.package_dir}/#{gem_task.gem_file}"
|
109
|
-
end
|
26
|
+
task :package => gem_spec_file
|
27
|
+
task :check_manifest => gem_spec_file
|
data/lib/subload.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# TODO convert to yardoc
|
2
2
|
module Subload
|
3
|
+
VERSION = '1.1.0'
|
4
|
+
|
3
5
|
# To add modes to subload, simply add them to this hash. Please use the
|
4
6
|
# a namespace convention, starting with +:projectname_operationdescription+.
|
5
7
|
MODES = {
|
@@ -62,7 +64,7 @@ module Subload
|
|
62
64
|
subload_with(mode)[self, symbol, path, options]
|
63
65
|
end
|
64
66
|
|
65
|
-
LONG_UPPER_CONSTS = [/([A-Z]+)([A-Z][a-z]+)/, '\1_\2']
|
67
|
+
LONG_UPPER_CONSTS = [/([A-Z\d]+)([A-Z][a-z]+)/, '\1_\2']
|
66
68
|
TAIL_UPPER_CONSTS = [/([a-z])([A-Z])/, '\1_\2']
|
67
69
|
DOUBLE_UNDERSCORE = '__'
|
68
70
|
DOUBLE_COLON = '::'
|
@@ -98,4 +100,4 @@ class Module
|
|
98
100
|
else
|
99
101
|
alias __name__ name
|
100
102
|
end
|
101
|
-
end
|
103
|
+
end
|
data/subload.gemspec
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{subload}
|
5
|
+
s.version = "1.1.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["James Tucker"]
|
9
|
+
s.date = %q{2010-03-17}
|
10
|
+
s.description = %q{A handy dandy autoload / require / load helper for your rubies. Similar to
|
11
|
+
using[1], but with a few differences of opinion, and a bit shorter.
|
12
|
+
|
13
|
+
Basically, expand path is fine, up until a point. Sometimes there's no point
|
14
|
+
(i.e. when the load path already contains most of the path you're trying to
|
15
|
+
open). When you're writing libs that users might require sub parts with
|
16
|
+
'libname/sub_part', then expand_path combined with say, rubygems, can lead to
|
17
|
+
double requires. Lets not do that. :-)
|
18
|
+
|
19
|
+
[1] http://github.com/smtlaissezfaire/using/}
|
20
|
+
s.email = ["raggi@rubyforge.org"]
|
21
|
+
s.extra_rdoc_files = ["Manifest.txt", "CHANGELOG.rdoc", "README.rdoc"]
|
22
|
+
s.files = ["CHANGELOG.rdoc", "Manifest.txt", "README.rdoc", "Rakefile", "examples/a.rb", "examples/a/foo.rb", "examples/a/foo/bar.rb", "examples/a/foo/baz.rb", "examples/rails/loader.rb", "lib/subload.rb", "subload.gemspec", "test/test_subload.rb", "test/test_subload/a.rb", "test/test_subload/b.rb", "test/test_subload/c.rb", "test/test_subload/d.rb", "test/test_subload/e.rb", "test/test_subload/f.rb", "test/test_subload/f/a.rb"]
|
23
|
+
s.homepage = %q{http://rubygems.org/gems/subload}
|
24
|
+
s.rdoc_options = ["--main", "README.rdoc"]
|
25
|
+
s.require_paths = ["lib"]
|
26
|
+
s.rubyforge_project = %q{libraggi}
|
27
|
+
s.rubygems_version = %q{1.3.6}
|
28
|
+
s.summary = %q{A handy dandy autoload / require / load helper for your rubies}
|
29
|
+
s.test_files = ["test/test_subload.rb"]
|
30
|
+
|
31
|
+
if s.respond_to? :specification_version then
|
32
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
33
|
+
s.specification_version = 3
|
34
|
+
|
35
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
36
|
+
s.add_development_dependency(%q<hoe-doofus>, [">= 1.0.0"])
|
37
|
+
s.add_development_dependency(%q<hoe-git>, [">= 1.3.0"])
|
38
|
+
s.add_development_dependency(%q<hoe-gemcutter>, [">= 1.0.0"])
|
39
|
+
s.add_development_dependency(%q<hoe>, [">= 2.3.3"])
|
40
|
+
else
|
41
|
+
s.add_dependency(%q<hoe-doofus>, [">= 1.0.0"])
|
42
|
+
s.add_dependency(%q<hoe-git>, [">= 1.3.0"])
|
43
|
+
s.add_dependency(%q<hoe-gemcutter>, [">= 1.0.0"])
|
44
|
+
s.add_dependency(%q<hoe>, [">= 2.3.3"])
|
45
|
+
end
|
46
|
+
else
|
47
|
+
s.add_dependency(%q<hoe-doofus>, [">= 1.0.0"])
|
48
|
+
s.add_dependency(%q<hoe-git>, [">= 1.3.0"])
|
49
|
+
s.add_dependency(%q<hoe-gemcutter>, [">= 1.0.0"])
|
50
|
+
s.add_dependency(%q<hoe>, [">= 2.3.3"])
|
51
|
+
end
|
52
|
+
end
|
data/test/test_subload.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
require "test/unit"
|
2
|
-
|
3
|
-
$:.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
|
4
2
|
require "subload"
|
5
3
|
|
6
4
|
class TestSubload < Test::Unit::TestCase
|
@@ -68,4 +66,10 @@ class TestSubload < Test::Unit::TestCase
|
|
68
66
|
assert_equal("Module", Module.__name__)
|
69
67
|
end
|
70
68
|
|
71
|
-
|
69
|
+
def test_to_path
|
70
|
+
assert_equal 'c2c2_api', Subload.to_path('C2C2Api')
|
71
|
+
assert_equal '123_api', Subload.to_path('123Api')
|
72
|
+
assert_equal 'http_error', Subload.to_path('HTTPError')
|
73
|
+
assert_equal 'no_method_error', Subload.to_path('NoMethodError')
|
74
|
+
end
|
75
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: subload
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 1.1.0
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- James Tucker
|
@@ -9,39 +14,90 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date:
|
17
|
+
date: 2010-03-17 00:00:00 +00:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
21
|
+
name: hoe-doofus
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 0
|
30
|
+
- 0
|
31
|
+
version: 1.0.0
|
17
32
|
type: :development
|
18
|
-
|
19
|
-
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: hoe-git
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
20
38
|
requirements:
|
21
39
|
- - ">="
|
22
40
|
- !ruby/object:Gem::Version
|
23
|
-
|
24
|
-
|
41
|
+
segments:
|
42
|
+
- 1
|
43
|
+
- 3
|
44
|
+
- 0
|
45
|
+
version: 1.3.0
|
46
|
+
type: :development
|
47
|
+
version_requirements: *id002
|
25
48
|
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
49
|
+
name: hoe-gemcutter
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
segments:
|
56
|
+
- 1
|
57
|
+
- 0
|
58
|
+
- 0
|
59
|
+
version: 1.0.0
|
27
60
|
type: :development
|
28
|
-
|
29
|
-
|
61
|
+
version_requirements: *id003
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: hoe
|
64
|
+
prerelease: false
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
30
66
|
requirements:
|
31
67
|
- - ">="
|
32
68
|
- !ruby/object:Gem::Version
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
69
|
+
segments:
|
70
|
+
- 2
|
71
|
+
- 3
|
72
|
+
- 3
|
73
|
+
version: 2.3.3
|
74
|
+
type: :development
|
75
|
+
version_requirements: *id004
|
76
|
+
description: |-
|
77
|
+
A handy dandy autoload / require / load helper for your rubies. Similar to
|
78
|
+
using[1], but with a few differences of opinion, and a bit shorter.
|
79
|
+
|
80
|
+
Basically, expand path is fine, up until a point. Sometimes there's no point
|
81
|
+
(i.e. when the load path already contains most of the path you're trying to
|
82
|
+
open). When you're writing libs that users might require sub parts with
|
83
|
+
'libname/sub_part', then expand_path combined with say, rubygems, can lead to
|
84
|
+
double requires. Lets not do that. :-)
|
85
|
+
|
86
|
+
[1] http://github.com/smtlaissezfaire/using/
|
87
|
+
email:
|
88
|
+
- raggi@rubyforge.org
|
37
89
|
executables: []
|
38
90
|
|
39
91
|
extensions: []
|
40
92
|
|
41
93
|
extra_rdoc_files:
|
42
|
-
-
|
94
|
+
- Manifest.txt
|
95
|
+
- CHANGELOG.rdoc
|
96
|
+
- README.rdoc
|
43
97
|
files:
|
44
|
-
-
|
98
|
+
- CHANGELOG.rdoc
|
99
|
+
- Manifest.txt
|
100
|
+
- README.rdoc
|
45
101
|
- Rakefile
|
46
102
|
- examples/a.rb
|
47
103
|
- examples/a/foo.rb
|
@@ -49,6 +105,7 @@ files:
|
|
49
105
|
- examples/a/foo/baz.rb
|
50
106
|
- examples/rails/loader.rb
|
51
107
|
- lib/subload.rb
|
108
|
+
- subload.gemspec
|
52
109
|
- test/test_subload.rb
|
53
110
|
- test/test_subload/a.rb
|
54
111
|
- test/test_subload/b.rb
|
@@ -58,37 +115,35 @@ files:
|
|
58
115
|
- test/test_subload/f.rb
|
59
116
|
- test/test_subload/f/a.rb
|
60
117
|
has_rdoc: true
|
61
|
-
homepage: http://
|
118
|
+
homepage: http://rubygems.org/gems/subload
|
62
119
|
licenses: []
|
63
120
|
|
64
121
|
post_install_message:
|
65
122
|
rdoc_options:
|
66
|
-
- --line-numbers
|
67
|
-
- --inline-source
|
68
|
-
- --title
|
69
|
-
- Subload
|
70
123
|
- --main
|
71
|
-
- README
|
124
|
+
- README.rdoc
|
72
125
|
require_paths:
|
73
126
|
- lib
|
74
127
|
required_ruby_version: !ruby/object:Gem::Requirement
|
75
128
|
requirements:
|
76
129
|
- - ">="
|
77
130
|
- !ruby/object:Gem::Version
|
131
|
+
segments:
|
132
|
+
- 0
|
78
133
|
version: "0"
|
79
|
-
version:
|
80
134
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
135
|
requirements:
|
82
136
|
- - ">="
|
83
137
|
- !ruby/object:Gem::Version
|
138
|
+
segments:
|
139
|
+
- 0
|
84
140
|
version: "0"
|
85
|
-
version:
|
86
141
|
requirements: []
|
87
142
|
|
88
143
|
rubyforge_project: libraggi
|
89
|
-
rubygems_version: 1.3.
|
144
|
+
rubygems_version: 1.3.6
|
90
145
|
signing_key:
|
91
|
-
specification_version:
|
92
|
-
summary:
|
146
|
+
specification_version: 3
|
147
|
+
summary: A handy dandy autoload / require / load helper for your rubies
|
93
148
|
test_files:
|
94
149
|
- test/test_subload.rb
|
data/README
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
subload
|
2
|
-
|
3
|
-
A handy dandy autoload / require / load helper for your rubies. Similar to
|
4
|
-
using[1], but with a few differences of opinion, and a bit shorter.
|
5
|
-
|
6
|
-
Basically, expand path is fine, up until a point. Sometimes there's no point
|
7
|
-
(i.e. when the load path already contains most of the path you're trying to
|
8
|
-
open). When you're writing libs that users might require sub parts with
|
9
|
-
'libname/sub_part', then expand_path combined with say, rubygems, can lead to
|
10
|
-
double requires. Lets not do that. :-)
|
11
|
-
|
12
|
-
[1] http://github.com/smtlaissezfaire/using/
|
13
|
-
|
14
|
-
TODO - replace me... more...
|
15
|
-
|
16
|
-
Examples:
|
17
|
-
|
18
|
-
module A
|
19
|
-
|
20
|
-
# The nominal use case, A.autoload :B, 'a/b'
|
21
|
-
# You rarely need much else!
|
22
|
-
subload :B
|
23
|
-
|
24
|
-
# A custom path, A.autoload :C, 'a/c'
|
25
|
-
subload :C, :path => 'a/c'
|
26
|
-
# For example when 'a/c' defines several constants:
|
27
|
-
subload :Ca, :path => 'a/c'
|
28
|
-
subload :Cb, :path => 'a/c'
|
29
|
-
|
30
|
-
# An expanded path, A.autoload :D, File.join(Dir.pwd, 'a/d')
|
31
|
-
subload :D, :expand_path => true
|
32
|
-
# This has interesting uses in combination, although not generally
|
33
|
-
# recommended:
|
34
|
-
subload :E, :path => '../../path/e', :expand_path => true
|
35
|
-
|
36
|
-
# Explicitly override the mode, for this call only, A.require 'a/f'
|
37
|
-
subload :F, :mode => :require
|
38
|
-
|
39
|
-
# Set the mode for all subsiquent calls to subload in this class/module
|
40
|
-
subload_with :require
|
41
|
-
subload :G # => require 'a/g'
|
42
|
-
subload :H # => require 'a/h'
|
43
|
-
|
44
|
-
# Other features intended for library and framework developers are described
|
45
|
-
# in the class documentation.
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
Some Notes:
|
50
|
-
|
51
|
-
* File.expand_path: Expand path is good if you're traversing up directories.
|
52
|
-
It is bad if you're loading something within a library that is on the load
|
53
|
-
path. If the library is on the load path, and you require files with an
|
54
|
-
expanded path, there is the likelihood of a double require when other code
|
55
|
-
contains a require that is expectant of the load path modification.
|
56
|
-
|
57
|
-
* Frameworks: Sometimes require explicit load order control. In these cases,
|
58
|
-
overriding the loader and either tracking, or performing stateful operations
|
59
|
-
works well.
|
60
|
-
|
61
|
-
* Abusive use of override_mode: Override mode is potentially dangerous. As per
|
62
|
-
the other documentation, override mode should be reserved for use in
|
63
|
-
application code only. Libraries setting override mode could cause
|
64
|
-
additional failure cases for foreign libraries, although gratuitous addition
|
65
|
-
of loading mechanisms is not recommended.
|
66
|
-
|
67
|
-
* Generated code loading: When you're doing code generation, sometimes it is
|
68
|
-
desirable to have tow locations from which to load a class. One will contain
|
69
|
-
custom class defintions, and the other will contain generated definitions.
|
70
|
-
Using a custom loader, one can then utilise a single subload statement to
|
71
|
-
correctly load both files.
|
72
|
-
|
73
|
-
TODO Chaotic Overloading
|
74
|
-
|
75
|
-
Consider vertical vs. horizontal delegation rules and use cases for new
|
76
|
-
loaders in non-framework libraries that perform custom loads such that it is
|
77
|
-
easy to say "invoke the current load mode with the following options".
|