loadable 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.ruby +51 -0
- data/.yardopts +6 -0
- data/COPYING.rdoc +31 -0
- data/HISTORY.rdoc +46 -0
- data/INFRACTIONS.rdoc +401 -0
- data/README.md +192 -0
- data/lib/loadable/class_require.rb +10 -0
- data/lib/loadable/core_ext/rubygems.rb +81 -0
- data/lib/loadable/domain.rb +64 -0
- data/lib/loadable/kernel.rb +35 -0
- data/lib/loadable/loaders/gem_loader.rb +98 -0
- data/lib/loadable/loaders/original_loader.rb +63 -0
- data/lib/loadable/loaders/roll_loader.rb +21 -0
- data/lib/loadable/loaders/ruby_loader.rb +81 -0
- data/lib/loadable/loaders/vendor_loader.rb +109 -0
- data/lib/loadable/mixin.rb +100 -0
- data/lib/loadable/system.rb +11 -0
- data/lib/loadable/version.rb +20 -0
- data/lib/loadable.rb +5 -0
- data/spec/fixture/abbrev.rb +3 -0
- data/spec/fixture/ansi.rb +3 -0
- data/spec/fixture/subpro/.ruby +5 -0
- data/spec/fixture/subpro/lib/subpro.rb +1 -0
- data/spec/gem_loader_spec.rb +49 -0
- data/spec/helper.rb +6 -0
- data/spec/ruby_loader_spec.rb +38 -0
- data/spec/vendor_loader_spec.rb +30 -0
- metadata +125 -0
data/.ruby
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
---
|
2
|
+
authors:
|
3
|
+
- name: Thomas Sawyer
|
4
|
+
email: transfire@gmail.com
|
5
|
+
copyrights:
|
6
|
+
- holder: Thomas Sawyer, RubyWorks
|
7
|
+
year: '2010'
|
8
|
+
license: BSD-2-Clause
|
9
|
+
replacements: []
|
10
|
+
conflicts: []
|
11
|
+
requirements:
|
12
|
+
- name: detroit
|
13
|
+
groups:
|
14
|
+
- build
|
15
|
+
development: true
|
16
|
+
- name: minitest
|
17
|
+
groups:
|
18
|
+
- test
|
19
|
+
development: true
|
20
|
+
- name: minitap
|
21
|
+
groups:
|
22
|
+
- test
|
23
|
+
development: true
|
24
|
+
- name: rake
|
25
|
+
groups:
|
26
|
+
- build
|
27
|
+
development: true
|
28
|
+
dependencies: []
|
29
|
+
repositories:
|
30
|
+
- uri: git://github.com/rubyworks/loadable.git
|
31
|
+
scm: git
|
32
|
+
name: upstream
|
33
|
+
resources:
|
34
|
+
home: http://rubyworks.github.com/loadable
|
35
|
+
code: http://github.com/rubyworks/loadable
|
36
|
+
load_path:
|
37
|
+
- lib
|
38
|
+
extra: {}
|
39
|
+
source:
|
40
|
+
- Profile
|
41
|
+
alternatives: []
|
42
|
+
revision: 0
|
43
|
+
created: '2010-07-21'
|
44
|
+
summary: Safely Customize Ruby's Load System
|
45
|
+
title: Loadable
|
46
|
+
name: loadable
|
47
|
+
version: 1.2.0
|
48
|
+
description: Loadable modifieds Ruby's load/require system to handle "load wedges",
|
49
|
+
which work much like routes in web frameworks, but in this case determine which
|
50
|
+
files get loaded.
|
51
|
+
date: '2011-10-17'
|
data/.yardopts
ADDED
data/COPYING.rdoc
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
= COPYRIGHT NOTICES
|
2
|
+
|
3
|
+
== Load System
|
4
|
+
|
5
|
+
Copyright:: (c) 2010 Rubyworks, Thomas Sawyer
|
6
|
+
License:: BSD-2-Clause
|
7
|
+
Wedsite:: http://rubyworks.github.com/wedge
|
8
|
+
|
9
|
+
Copyright 2010 Rubyworks, Thomas Sawyer. All rights reserved.
|
10
|
+
|
11
|
+
Redistribution and use in source and binary forms, with or without modification, are
|
12
|
+
permitted provided that the following conditions are met:
|
13
|
+
|
14
|
+
1. Redistributions of source code must retain the above copyright notice, this list of
|
15
|
+
conditions and the following disclaimer.
|
16
|
+
|
17
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list
|
18
|
+
of conditions and the following disclaimer in the documentation and/or other materials
|
19
|
+
provided with the distribution.
|
20
|
+
|
21
|
+
THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
22
|
+
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
|
24
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
25
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
27
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
28
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
29
|
+
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
|
31
|
+
(http://www.spdx.org/licenses/BSD-2-Clause)
|
data/HISTORY.rdoc
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
= RELEASE HISTORY
|
2
|
+
|
3
|
+
== 1.2.0 / 2011-10-15
|
4
|
+
|
5
|
+
This release brings an almost complete rewrite of the API and
|
6
|
+
a renaming of the project form 'wedge' to 'loadable'. See the
|
7
|
+
API documentaiton for details.
|
8
|
+
|
9
|
+
Changes:
|
10
|
+
|
11
|
+
* Rewrite API almost entirely.
|
12
|
+
* Rename project from 'wedge' to 'loadable'.
|
13
|
+
* Utilize mixin rather than sublcass for loader classes.
|
14
|
+
* OriginalLoader handles Ruby's default load mechanism.
|
15
|
+
* New VendorLoader to support development.
|
16
|
+
|
17
|
+
|
18
|
+
== 1.1.0 / 2011-07-03
|
19
|
+
|
20
|
+
The Ruby wedge is no longer automatuically loaded when using
|
21
|
+
`require "wedge"`. Load it manually loaded with `require "wedge/ruby`".
|
22
|
+
|
23
|
+
Changes:
|
24
|
+
|
25
|
+
* Ruby wedge is not automatically loaded with wedge library.
|
26
|
+
|
27
|
+
|
28
|
+
== 1.0.0 / 2010-09-03
|
29
|
+
|
30
|
+
This release is simply a maintenance release, updating some project metadata.
|
31
|
+
No functionality has been changed.
|
32
|
+
|
33
|
+
Changes:
|
34
|
+
|
35
|
+
* Uupdate project metadata to latest POM.
|
36
|
+
|
37
|
+
|
38
|
+
== 1.0.0 / 2010-08-01
|
39
|
+
|
40
|
+
Initial release of Wedge, a tool for easily creating custom
|
41
|
+
load managers.
|
42
|
+
|
43
|
+
Changes:
|
44
|
+
|
45
|
+
* Happy Brithday!
|
46
|
+
|
data/INFRACTIONS.rdoc
ADDED
@@ -0,0 +1,401 @@
|
|
1
|
+
= INFRACTIONS
|
2
|
+
|
3
|
+
One of the rarely mentioned edge cases with the way in which RubyGems loads
|
4
|
+
library files, and in fact the way Ruby's load system works in general, is
|
5
|
+
that the _lib space_ is a free for all. Any library can drop any file into
|
6
|
+
their package's loadpath (i.e. the lib/ directory) and potentially clobber
|
7
|
+
a file of the same name in some one else's library.
|
8
|
+
|
9
|
+
Here's an example irb session that demonstrate the issue. Here I already added
|
10
|
+
a `matrix.rb` file, the did nothing but <code>puts "HERE!"</code>, to the +cuts+
|
11
|
+
gem and installed it.
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
=> true
|
15
|
+
gem "cuts"
|
16
|
+
=> true
|
17
|
+
require 'matrix'
|
18
|
+
HERE!
|
19
|
+
=> true
|
20
|
+
|
21
|
+
Now, a good <i>gem citizen</i> knows to put their scripts in a directory with
|
22
|
+
the same name as their gem package, nonetheless you might be surprised to see
|
23
|
+
how often this simple but important practice is violated.
|
24
|
+
Consequently the order in which such gems are searched becomes of
|
25
|
+
paramount importance --something that worked just fine on one machine can
|
26
|
+
suddenly stop working on another for no obvious reason.
|
27
|
+
|
28
|
+
|
29
|
+
== ISOLATIONISTS
|
30
|
+
|
31
|
+
It is also worth noting that the recent crop of gem isolation systems, such as
|
32
|
+
Bundler and Isolate, while serving to reduce the likelihood of possible name
|
33
|
+
clashes still do not fully remedy the issue. They merely reduce the number to
|
34
|
+
gems that could cause the problem for any given dependent application.
|
35
|
+
|
36
|
+
|
37
|
+
== SOLUTION
|
38
|
+
|
39
|
+
The Ruby and Gem wedges solves the issue entirely by allowing us to load files
|
40
|
+
from a single gem and only that gem. It does so by adding a new valid syntax
|
41
|
+
to Ruby's #load and #require methods. As an example, let's say we wanted to
|
42
|
+
load the troff.rb script from the unroller library.
|
43
|
+
|
44
|
+
require 'unroller:troff'
|
45
|
+
|
46
|
+
The colon is used to separate the gem name from the rest of the pathname.
|
47
|
+
With this we can be 100% certain that the troff.rb file was required
|
48
|
+
from the unroller gem and not a 'troff.rb' file from any other
|
49
|
+
gem that might have created a script by the same name.
|
50
|
+
|
51
|
+
|
52
|
+
== EXTENT OF THE ISSUE
|
53
|
+
|
54
|
+
You might be suprised to find out how many libraries violate the best practice
|
55
|
+
of putting all thier scripts in a subdirectory by the same name as the package.
|
56
|
+
Just on my development system alone, which really has but a small number of
|
57
|
+
gems installed, there are quite a few cases.
|
58
|
+
|
59
|
+
ParseTree-2.2.0/lib/:
|
60
|
+
|
61
|
+
composite_sexp_processor.rb
|
62
|
+
parse_tree.rb
|
63
|
+
sexp.rb
|
64
|
+
sexp_processor.rb
|
65
|
+
unified_ruby.rb
|
66
|
+
unique.rb
|
67
|
+
|
68
|
+
ParseTree-3.0.3/lib/:
|
69
|
+
|
70
|
+
gauntlet_parsetree.rb
|
71
|
+
parse_tree.rb
|
72
|
+
parse_tree_extensions.rb
|
73
|
+
unified_ruby.rb
|
74
|
+
unique.rb
|
75
|
+
|
76
|
+
RedCloth-4.1.9/lib/:
|
77
|
+
|
78
|
+
case_sensitive_require
|
79
|
+
redcloth
|
80
|
+
redcloth.rb
|
81
|
+
redcloth_scan.so
|
82
|
+
|
83
|
+
RedCloth-4.2.2/lib/:
|
84
|
+
|
85
|
+
case_sensitive_require
|
86
|
+
redcloth
|
87
|
+
redcloth.rb
|
88
|
+
redcloth_scan.so
|
89
|
+
tasks
|
90
|
+
|
91
|
+
ZenTest-4.0.0/lib/:
|
92
|
+
autotest
|
93
|
+
autotest.rb
|
94
|
+
focus.rb
|
95
|
+
functional_test_matrix.rb
|
96
|
+
multiruby.rb
|
97
|
+
unit_diff.rb
|
98
|
+
zentest.rb
|
99
|
+
zentest_mapping.rb
|
100
|
+
|
101
|
+
bossman-0.4.1/lib/:
|
102
|
+
|
103
|
+
bossman
|
104
|
+
bossman.rb
|
105
|
+
extensions
|
106
|
+
|
107
|
+
builder-2.1.2/lib/:
|
108
|
+
|
109
|
+
blankslate.rb
|
110
|
+
builder
|
111
|
+
builder.rb
|
112
|
+
|
113
|
+
chardet-0.9.0/lib/:
|
114
|
+
|
115
|
+
Big5Freq.rb
|
116
|
+
Big5Prober.rb
|
117
|
+
CharDistributionAnalysis.rb
|
118
|
+
CharSetGroupProber.rb
|
119
|
+
CharSetProber.rb
|
120
|
+
CodingStateMachine.rb
|
121
|
+
ESCSM.rb
|
122
|
+
EUCJPProber.rb
|
123
|
+
EUCKRFreq.rb
|
124
|
+
EUCKRProber.rb
|
125
|
+
EUCTWFreq.rb
|
126
|
+
EUCTWProber.rb
|
127
|
+
EscCharSetProber.rb
|
128
|
+
GB2312Freq.rb
|
129
|
+
GB2312Prober.rb
|
130
|
+
HebrewProber.rb
|
131
|
+
JISFreq.rb
|
132
|
+
JapaneseContextAnalysis.rb
|
133
|
+
LangBulgarianModel.rb
|
134
|
+
LangCyrillicModel.rb
|
135
|
+
LangGreekModel.rb
|
136
|
+
LangHebrewModel.rb
|
137
|
+
LangHungarianModel.rb
|
138
|
+
LangThaiModel.rb
|
139
|
+
Latin1Prober.rb
|
140
|
+
MBCSGroupProber.rb
|
141
|
+
MBCSSM.rb
|
142
|
+
MultiByteCharSetProber.rb
|
143
|
+
SBCSGroupProber.rb
|
144
|
+
SJISProber.rb
|
145
|
+
SingleByteCharSetProber.rb
|
146
|
+
UTF8Prober.rb
|
147
|
+
UniversalDetector.rb
|
148
|
+
|
149
|
+
eventmachine-0.12.10/lib/:
|
150
|
+
|
151
|
+
em
|
152
|
+
eventmachine.rb
|
153
|
+
evma
|
154
|
+
evma.rb
|
155
|
+
fastfilereaderext.so
|
156
|
+
jeventmachine.rb
|
157
|
+
pr_eventmachine.rb
|
158
|
+
rubyeventmachine.so
|
159
|
+
|
160
|
+
grosser-parallel-0.3.1/lib/:
|
161
|
+
|
162
|
+
parallel.rb
|
163
|
+
|
164
|
+
hpricot-0.8.1/lib/:
|
165
|
+
|
166
|
+
fast_xs.so
|
167
|
+
hpricot
|
168
|
+
hpricot.rb
|
169
|
+
hpricot_scan.so
|
170
|
+
|
171
|
+
html5-0.10.0/lib/:
|
172
|
+
|
173
|
+
core_ext
|
174
|
+
html5
|
175
|
+
html5.rb
|
176
|
+
|
177
|
+
http_router-0.2.5/lib/:
|
178
|
+
|
179
|
+
ext
|
180
|
+
http_router
|
181
|
+
http_router.rb
|
182
|
+
|
183
|
+
httpclient-2.1.5.2/lib/:
|
184
|
+
|
185
|
+
http-access2
|
186
|
+
http-access2.rb
|
187
|
+
httpclient
|
188
|
+
httpclient.rb
|
189
|
+
tags
|
190
|
+
|
191
|
+
linecache-0.43/lib/:
|
192
|
+
|
193
|
+
linecache.rb
|
194
|
+
trace_nums.so
|
195
|
+
tracelines.rb
|
196
|
+
|
197
|
+
liquid-2.0.0/lib/:
|
198
|
+
|
199
|
+
extras
|
200
|
+
liquid
|
201
|
+
liquid.rb
|
202
|
+
|
203
|
+
mail-2.2.5/lib/:
|
204
|
+
|
205
|
+
VERSION
|
206
|
+
mail
|
207
|
+
mail.rb
|
208
|
+
mail.rbc
|
209
|
+
tasks
|
210
|
+
|
211
|
+
maruku-0.5.9/lib/:
|
212
|
+
|
213
|
+
maruku
|
214
|
+
maruku.rb
|
215
|
+
sort_prof.rb
|
216
|
+
|
217
|
+
mechanize-0.9.3/lib/:
|
218
|
+
|
219
|
+
mechanize.rb
|
220
|
+
www
|
221
|
+
|
222
|
+
memcache-client-1.7.8/lib/:
|
223
|
+
|
224
|
+
continuum_native.rb
|
225
|
+
memcache.rb
|
226
|
+
memcache_util.rb
|
227
|
+
|
228
|
+
mocha-0.9.8/lib/:
|
229
|
+
|
230
|
+
mocha
|
231
|
+
mocha.rb
|
232
|
+
mocha_standalone.rb
|
233
|
+
stubba.rb
|
234
|
+
|
235
|
+
packr-3.1.0/lib/:
|
236
|
+
|
237
|
+
packr
|
238
|
+
packr.rb
|
239
|
+
string.rb
|
240
|
+
|
241
|
+
qed-2.3.0/lib/:
|
242
|
+
|
243
|
+
qed
|
244
|
+
qed.rb
|
245
|
+
qedoc
|
246
|
+
|
247
|
+
quality_extensions-1.1.6/lib/:
|
248
|
+
|
249
|
+
Xfind_bug_test.rb
|
250
|
+
quality_extensions
|
251
|
+
quality_extensions.rb
|
252
|
+
|
253
|
+
radiant-0.8.2/lib/:
|
254
|
+
|
255
|
+
annotatable.rb
|
256
|
+
autotest
|
257
|
+
generators
|
258
|
+
inheritable_class_attributes.rb
|
259
|
+
local_time.rb
|
260
|
+
login_system.rb
|
261
|
+
method_observer.rb
|
262
|
+
plugins
|
263
|
+
radiant
|
264
|
+
radiant.rb
|
265
|
+
simpleton.rb
|
266
|
+
task_support.rb
|
267
|
+
tasks
|
268
|
+
|
269
|
+
rails-2.3.5/lib/:
|
270
|
+
|
271
|
+
code_statistics.rb
|
272
|
+
commands
|
273
|
+
commands.rb
|
274
|
+
console_app.rb
|
275
|
+
console_sandbox.rb
|
276
|
+
console_with_helpers.rb
|
277
|
+
dispatcher.rb
|
278
|
+
fcgi_handler.rb
|
279
|
+
initializer.rb
|
280
|
+
performance_test_help.rb
|
281
|
+
rails
|
282
|
+
rails_generator
|
283
|
+
rails_generator.rb
|
284
|
+
railties_path.rb
|
285
|
+
ruby_version_check.rb
|
286
|
+
rubyprof_ext.rb
|
287
|
+
source_annotation_extractor.rb
|
288
|
+
tasks
|
289
|
+
test_help.rb
|
290
|
+
webrick_server.rb
|
291
|
+
|
292
|
+
railties-3.0.0.beta/lib/:
|
293
|
+
|
294
|
+
generators
|
295
|
+
rails
|
296
|
+
rails.rb
|
297
|
+
|
298
|
+
ramaze-2010.01/lib/:
|
299
|
+
|
300
|
+
proto
|
301
|
+
ramaze
|
302
|
+
ramaze.rb
|
303
|
+
vendor
|
304
|
+
|
305
|
+
rdiscount-1.3.5/lib/:
|
306
|
+
|
307
|
+
markdown.rb
|
308
|
+
rdiscount.rb
|
309
|
+
rdiscount.so
|
310
|
+
|
311
|
+
red-3.5.0/lib/:
|
312
|
+
|
313
|
+
javascripts
|
314
|
+
red
|
315
|
+
red.rb
|
316
|
+
|
317
|
+
red-4.1.7/lib/:
|
318
|
+
|
319
|
+
red
|
320
|
+
red.rb
|
321
|
+
source
|
322
|
+
|
323
|
+
rmagick-2.12.2/lib/:
|
324
|
+
|
325
|
+
RMagick.rb
|
326
|
+
RMagick2.so
|
327
|
+
rvg
|
328
|
+
|
329
|
+
ruby-prof-0.7.3/lib/:
|
330
|
+
|
331
|
+
ruby-prof
|
332
|
+
ruby-prof.rb
|
333
|
+
ruby_prof.so
|
334
|
+
unprof.rb
|
335
|
+
|
336
|
+
ruby_parser-2.0.4/lib/:
|
337
|
+
|
338
|
+
gauntlet_rubyparser.rb
|
339
|
+
ruby_lexer.rb
|
340
|
+
ruby_parser.rb
|
341
|
+
ruby_parser.y
|
342
|
+
ruby_parser_extras.rb
|
343
|
+
|
344
|
+
rubygems-update-1.3.7/lib/:
|
345
|
+
|
346
|
+
gauntlet_rubygems.rb
|
347
|
+
rbconfig
|
348
|
+
rubygems
|
349
|
+
rubygems.rb
|
350
|
+
ubygems.rb
|
351
|
+
|
352
|
+
s3sync-1.2.5/lib/:
|
353
|
+
|
354
|
+
HTTPStreaming.rb
|
355
|
+
S3.rb
|
356
|
+
S3_s3sync_mod.rb
|
357
|
+
S3encoder.rb
|
358
|
+
s3config.rb
|
359
|
+
s3try.rb
|
360
|
+
thread_generator.rb
|
361
|
+
version.rb
|
362
|
+
|
363
|
+
sexp_processor-3.0.1/lib/:
|
364
|
+
|
365
|
+
composite_sexp_processor.rb
|
366
|
+
sexp.rb
|
367
|
+
sexp_processor.rb
|
368
|
+
|
369
|
+
sexp_processor-3.0.3/lib/:
|
370
|
+
|
371
|
+
composite_sexp_processor.rb
|
372
|
+
sexp.rb
|
373
|
+
sexp_processor.rb
|
374
|
+
unique.rb
|
375
|
+
|
376
|
+
slim_scrooge-1.0.5/lib/:
|
377
|
+
|
378
|
+
callsite_hash.so
|
379
|
+
slim_scrooge
|
380
|
+
slim_scrooge.rb
|
381
|
+
|
382
|
+
treetop-1.2.4/lib/:
|
383
|
+
|
384
|
+
metagrammar.rb
|
385
|
+
treetop
|
386
|
+
treetop.rb
|
387
|
+
|
388
|
+
unroller-1.0.0/lib/:
|
389
|
+
|
390
|
+
troff.rb
|
391
|
+
tron.rb
|
392
|
+
unroller.rb
|
393
|
+
|
394
|
+
xcb-0.0.1/lib/:
|
395
|
+
|
396
|
+
directory_monitor.rb
|
397
|
+
extreme_continuous_builder.rb
|
398
|
+
notifiers.rb
|
399
|
+
stacking_config.rb
|
400
|
+
xcb_command.rb
|
401
|
+
|