faster_require 0.6.0 → 0.7.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/README +31 -3
- data/Rakefile +8 -0
- data/VERSION +1 -1
- data/lib/faster_require.rb +143 -94
- data/spec/eval_me1.rb +1 -0
- data/spec/eval_me2.rb +1 -0
- data/spec/files/active_support_no_double_load.rb +15 -0
- data/spec/files/gem_after.rb +3 -1
- data/spec/files/load_various_gems.rb +12 -0
- data/spec/files/load_various_gems2.rb +7 -0
- data/spec/files/socket_load.rb +8 -0
- data/spec/spec.fast_require.rb +22 -14
- metadata +87 -94
data/README
CHANGED
|
@@ -2,7 +2,7 @@ A little utility to make
|
|
|
2
2
|
|
|
3
3
|
require 'xxx'
|
|
4
4
|
|
|
5
|
-
take much less time.
|
|
5
|
+
take much less time. As in much less. Well, on windows at least.
|
|
6
6
|
|
|
7
7
|
Well, mostly on windows--on linux it's a speedup of only 0.41 to 0.45s, or so. [1]
|
|
8
8
|
|
|
@@ -35,7 +35,7 @@ rails app, running script/console "puts 333"
|
|
|
35
35
|
with:
|
|
36
36
|
6s
|
|
37
37
|
|
|
38
|
-
rake -T
|
|
38
|
+
running "rake -T"
|
|
39
39
|
|
|
40
40
|
1.9.1
|
|
41
41
|
without: 3.75s
|
|
@@ -48,4 +48,32 @@ rake -T
|
|
|
48
48
|
Note: in reality what we should do is fix core so that it doesn't have such awful I/O time in windows. There may be some gross inefficiency in there. For now, this is a work-around.
|
|
49
49
|
|
|
50
50
|
[1] A sister project to this one, faster_gem_script, can make ruby scripts in linux run faster by 0.1s :) http://github.com/rdp/faster_gem_script
|
|
51
|
-
(in windows it's a much higher gain). Eventually they'll be combined into one "gem optimizer" gem.
|
|
51
|
+
(in windows it's a much higher gain). Eventually they'll be combined into one "gem optimizer" gem.
|
|
52
|
+
|
|
53
|
+
== How to use in Rails ==
|
|
54
|
+
|
|
55
|
+
You can either install the gem, then add a
|
|
56
|
+
|
|
57
|
+
require 'rubygems'
|
|
58
|
+
require 'faster_require'
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
in your config/environment.rb, or (the best way is as follows):
|
|
62
|
+
|
|
63
|
+
Unpack it somewhere, like lib
|
|
64
|
+
$ cd my_rails_app/lib
|
|
65
|
+
$ gem unpack faster_require
|
|
66
|
+
|
|
67
|
+
Now add this line to your config/environment.rb:
|
|
68
|
+
|
|
69
|
+
require File.dirname(__FILE__) + "/../lib/faster_require-0.7.0/lib/faster_require" # faster speeds all around...
|
|
70
|
+
|
|
71
|
+
*before* this other (existing) line:
|
|
72
|
+
|
|
73
|
+
require File.join(File.dirname(__FILE__), 'boot')
|
|
74
|
+
|
|
75
|
+
Now it will speedup loading rubygems and everything. Happiness.
|
|
76
|
+
|
|
77
|
+
Any problems report back: https://github.com/rdp/faster_require
|
|
78
|
+
|
|
79
|
+
Enjoy.
|
data/Rakefile
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
require 'rubygems' if RUBY_VERSION < "1.9'"
|
|
2
|
+
|
|
3
|
+
begin
|
|
4
|
+
require 'psych' # sigh
|
|
5
|
+
rescue ::LoadError
|
|
6
|
+
end
|
|
7
|
+
|
|
2
8
|
require 'jeweler'
|
|
3
9
|
Jeweler::Tasks.new do |s|
|
|
4
10
|
s.name = "faster_require"
|
|
@@ -8,6 +14,8 @@
|
|
|
8
14
|
s.homepage = "http://github.com/rdp/faster_require"
|
|
9
15
|
s.authors = ["Roger Pack"]
|
|
10
16
|
s.add_development_dependency 'redparse'
|
|
17
|
+
s.add_development_dependency 'active_support', '= 2.3.10'
|
|
18
|
+
# s.add_development_dependency 'ruby-debug' too... or ruby-debug19 pick your poison
|
|
11
19
|
s.add_development_dependency 'jeweler'
|
|
12
20
|
s.add_development_dependency 'rspec', '>= 2'
|
|
13
21
|
s.add_development_dependency 'sane'
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.7.0
|
data/lib/faster_require.rb
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
require 'rbconfig'
|
|
2
|
+
#require 'rubygems'
|
|
3
|
+
#require 'ruby-debug'
|
|
2
4
|
|
|
3
5
|
module FastRequire
|
|
4
|
-
$FAST_REQUIRE_DEBUG ||= $DEBUG # can set
|
|
6
|
+
$FAST_REQUIRE_DEBUG ||= $DEBUG # can set via $DEBUG, or on its own.
|
|
5
7
|
|
|
6
8
|
def self.setup
|
|
7
9
|
@@dir = File.expand_path('~/.ruby_faster_require_cache')
|
|
@@ -83,9 +85,9 @@ module FastRequire
|
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
@@already_loaded[File.expand_path(__FILE__)] = true # this file itself isn't in loaded features, yet, but very soon will be..
|
|
86
|
-
# special case--I hope...
|
|
88
|
+
# a special case--I hope...
|
|
87
89
|
|
|
88
|
-
# disallow re-
|
|
90
|
+
# also disallow re- $0
|
|
89
91
|
@@require_locs[$0] = File.expand_path($0) # so when we run into it on a require, we will skip it...
|
|
90
92
|
@@already_loaded[File.expand_path($0)] = true
|
|
91
93
|
|
|
@@ -125,115 +127,162 @@ module FastRequire
|
|
|
125
127
|
@@require_locs.clear
|
|
126
128
|
setup
|
|
127
129
|
end
|
|
128
|
-
|
|
130
|
+
|
|
131
|
+
private
|
|
132
|
+
def last_caller
|
|
133
|
+
caller[-2]
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
IN_PROCESS = []
|
|
137
|
+
ALL_IN_PROCESS = []
|
|
138
|
+
@@count = 0
|
|
139
|
+
public
|
|
140
|
+
|
|
129
141
|
def require_cached lib
|
|
130
142
|
lib = lib.to_s # might not be zactly 1.9 compat... to_path ??
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if known_loc =~ /\.#{RbConfig::CONFIG['DLEXT']}$/
|
|
139
|
-
puts 'doing original_non_cached_require on .so full path ' + known_loc if $FAST_REQUIRE_DEBUG
|
|
140
|
-
original_non_cached_require known_loc # not much we can do there...too bad...well at least we pass it a full path though :P
|
|
141
|
-
else
|
|
142
|
-
unless $LOADED_FEATURES.include? known_loc
|
|
143
|
-
if known_loc =~ /rubygems.rb$/
|
|
144
|
-
puts 'requiring rubygems ' + known_loc if $FAST_REQUIRE_DEBUG
|
|
145
|
-
original_non_cached_require(known_loc) # normal require so rubygems doesn't freak out when it finds itself already in $LOADED_FEATURES :P
|
|
146
|
-
else
|
|
147
|
-
if $FAST_REQUIRE_DEBUG
|
|
148
|
-
puts 'doing cached loc eval on ' + lib + '=>' + known_loc
|
|
149
|
-
end
|
|
150
|
-
$LOADED_FEATURES << known_loc
|
|
151
|
-
# fakely add the load path, too, so that autoload for the same file will work <sigh> [rspec2]
|
|
152
|
-
no_suffix_full_path = known_loc.gsub(/\.[^.]+$/, '')
|
|
153
|
-
no_suffix_lib = lib.gsub(/\.[^.]+$/, '')
|
|
154
|
-
libs_path = no_suffix_full_path.gsub(no_suffix_lib, '')
|
|
155
|
-
libs_path = File.expand_path(libs_path) # strip off trailing '/'
|
|
156
|
-
$: << libs_path unless $:.index(libs_path)
|
|
157
|
-
# load(known_loc, false) # too slow
|
|
158
|
-
eval(File.open(known_loc, 'rb') {|f| f.read}, TOPLEVEL_BINDING, known_loc) # note the rb here--this means it's reading .rb files as binary, which *typically* works...maybe unnecessary?
|
|
159
|
-
# --if it breaks re-save the offending file in binary mode, or file an issue on the tracker...
|
|
160
|
-
return true
|
|
161
|
-
end
|
|
162
|
-
else
|
|
163
|
-
puts 'ignoring already loaded? ' + known_loc if $FAST_REQUIRE_DEBUG
|
|
143
|
+
ALL_IN_PROCESS << [lib, @@count += 1]
|
|
144
|
+
begin
|
|
145
|
+
p 'doing require ' + lib + ' from ' + caller[-1] if $FAST_REQUIRE_DEBUG
|
|
146
|
+
if known_loc = @@require_locs[lib]
|
|
147
|
+
if @@already_loaded[known_loc]
|
|
148
|
+
p 'already loaded ' + known_loc + ' ' + lib if $FAST_REQUIRE_DEBUG
|
|
149
|
+
return false
|
|
164
150
|
end
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
151
|
+
@@already_loaded[known_loc] = true
|
|
152
|
+
if known_loc =~ /\.#{RbConfig::CONFIG['DLEXT']}$/
|
|
153
|
+
puts 'doing original_non_cached_require on .so full path ' + known_loc if $FAST_REQUIRE_DEBUG
|
|
154
|
+
original_non_cached_require known_loc # not much we can do there...too bad...well at least we pass it a full path though :P
|
|
155
|
+
else
|
|
156
|
+
unless $LOADED_FEATURES.include? known_loc
|
|
157
|
+
if known_loc =~ /rubygems.rb$/
|
|
158
|
+
puts 'requiring rubygems ' + lib if $FAST_REQUIRE_DEBUG
|
|
159
|
+
original_non_cached_require(lib) # revert to normal require so rubygems doesn't freak out when it finds itself already in $LOADED_FEATURES with rubygems > 1.6 :P
|
|
160
|
+
else
|
|
161
|
+
IN_PROCESS << known_loc
|
|
162
|
+
begin
|
|
163
|
+
if $FAST_REQUIRE_DEBUG
|
|
164
|
+
puts 'doing cached loc eval on ' + lib + '=>' + known_loc + " with stack:" + IN_PROCESS.join(' ')
|
|
165
|
+
end
|
|
166
|
+
$LOADED_FEATURES << known_loc
|
|
167
|
+
# fakely add the load path, too, so that autoload for the same file/path in gems will work <sigh> [rspec2]
|
|
168
|
+
no_suffix_full_path = known_loc.gsub(/\.[^.]+$/, '')
|
|
169
|
+
no_suffix_lib = lib.gsub(/\.[^.]+$/, '')
|
|
170
|
+
libs_path = no_suffix_full_path.gsub(no_suffix_lib, '')
|
|
171
|
+
libs_path = File.expand_path(libs_path) # strip off trailing '/'
|
|
172
|
+
$: << libs_path unless $:.index(libs_path)
|
|
173
|
+
# try some more autoload conivings...so that it won't attempt to autoload if it runs into it later...
|
|
174
|
+
relative_full_path = known_loc.sub(libs_path, '')[1..-1]
|
|
175
|
+
# $LOADED_FEATURES << relative_full_path.gsub('.rb', '') # don't think you need this one
|
|
176
|
+
$LOADED_FEATURES << relative_full_path # add in with .rb, too.
|
|
177
|
+
|
|
178
|
+
# load(known_loc, false) # too slow
|
|
179
|
+
eval(File.open(known_loc, 'rb') {|f| f.read}, TOPLEVEL_BINDING, known_loc) # note the 'rb' here--this means it's reading .rb files as binary, which *typically* works...maybe unnecessary though?
|
|
180
|
+
ensure
|
|
181
|
+
raise 'unexpected' unless IN_PROCESS.pop == known_loc
|
|
182
|
+
end
|
|
183
|
+
# --if it breaks re-save the offending file in binary mode, or file an issue on the tracker...
|
|
184
|
+
return true
|
|
185
|
+
end
|
|
186
|
+
else
|
|
187
|
+
puts 'ignoring already loaded [circular require?] ' + known_loc + ' ' + lib if $FAST_REQUIRE_DEBUG
|
|
182
188
|
end
|
|
183
|
-
found = File.expand_path(found);
|
|
184
189
|
end
|
|
185
|
-
puts 'found new loc:' + lib + '=>' + found if $FAST_REQUIRE_DEBUG
|
|
186
|
-
@@require_locs[lib] = found
|
|
187
|
-
@@already_loaded[found] = true
|
|
188
|
-
return true
|
|
189
190
|
else
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
191
|
+
# we don't know the location--let Ruby's original require do the heavy lifting for us here
|
|
192
|
+
old = $LOADED_FEATURES.dup
|
|
193
|
+
if(original_non_cached_require(lib))
|
|
194
|
+
# debugger might land here the first time you run a script and it doesn't have a require
|
|
195
|
+
# cached yet...
|
|
196
|
+
new = $LOADED_FEATURES - old
|
|
197
|
+
found = new.last
|
|
198
|
+
|
|
199
|
+
# incredibly, in 1.8.x, this doesn't always get set to a full path.
|
|
200
|
+
if RUBY_VERSION < '1.9'
|
|
201
|
+
if !File.file?(found)
|
|
202
|
+
# discover the full path.
|
|
203
|
+
dir = $:.find{|path| File.file?(path + '/' + found)}
|
|
204
|
+
return true unless dir # give up, case jruby socket.jar "mysterious"
|
|
205
|
+
found = dir + '/' + found
|
|
206
|
+
end
|
|
207
|
+
found = File.expand_path(found);
|
|
208
|
+
end
|
|
209
|
+
puts 'found new loc:' + lib + '=>' + found if $FAST_REQUIRE_DEBUG
|
|
210
|
+
@@require_locs[lib] = found
|
|
211
|
+
@@already_loaded[found] = true
|
|
212
|
+
return true
|
|
209
213
|
else
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
+
|
|
215
|
+
# this is expected if it's for libraries required before faster_require was [like rbconfig]
|
|
216
|
+
# raise 'actually expected' + lib if RUBY_VERSION >= '1.9.0'
|
|
217
|
+
puts 'already loaded, apparently [require returned false], trying to discover how it was redundant... ' + lib if $FAST_REQUIRE_DEBUG
|
|
218
|
+
# this probably was something like
|
|
219
|
+
# the first pass was require 'regdeferred'
|
|
220
|
+
# now it's a different require 'regdeferred.rb'
|
|
221
|
+
# which fails (or vice versa)
|
|
222
|
+
# so figure out why
|
|
223
|
+
# calc location, expand, map back
|
|
224
|
+
where_found = FastRequire.guess_discover(lib, true)
|
|
225
|
+
if where_found
|
|
226
|
+
puts 'inferred lib loc:' + lib + '=>' + where_found if $FAST_REQUIRE_DEBUG
|
|
227
|
+
@@require_locs[lib] = where_found
|
|
228
|
+
# unfortunately if it's our first pass
|
|
229
|
+
# and we are in the middle of a "real" require
|
|
230
|
+
# that is circular
|
|
231
|
+
# then $LOADED_FEATURES or (AFAIK) nothing will have been set
|
|
232
|
+
# for us to be able to assert that
|
|
233
|
+
# so...I think we'll end up
|
|
234
|
+
# just fudging for a bit
|
|
235
|
+
# raise 'not found' unless @@already_loaded[where_found] # should have already been set...I think...
|
|
236
|
+
else
|
|
237
|
+
if $FAST_REQUIRE_DEBUG
|
|
238
|
+
# happens for enumerator XXXX
|
|
239
|
+
puts 'unable to infer ' + lib + ' location' if $FAST_REQUIRE_DEBUG
|
|
240
|
+
@@already_loaded[found] = true # so hacky...
|
|
241
|
+
end
|
|
214
242
|
end
|
|
243
|
+
return false # XXXX test all these return values
|
|
215
244
|
end
|
|
216
|
-
return false # XXXX test all these return values
|
|
217
245
|
end
|
|
246
|
+
ensure
|
|
247
|
+
raise 'huh' unless ALL_IN_PROCESS.pop[0] == lib
|
|
218
248
|
end
|
|
219
249
|
end
|
|
220
250
|
|
|
221
|
-
def self.resetup!
|
|
222
|
-
eval "module ::Kernel; alias :require :require_cached; end"
|
|
223
|
-
end
|
|
224
251
|
end
|
|
225
252
|
|
|
226
253
|
module Kernel
|
|
227
254
|
|
|
228
255
|
if(defined?(@already_using_faster_require))
|
|
229
|
-
raise 'twice not allowed...'
|
|
230
|
-
|
|
256
|
+
raise 'loading twice not allowed...we should never get here!'
|
|
257
|
+
end
|
|
258
|
+
@already_using_faster_require = true
|
|
259
|
+
# overwrite old require...
|
|
260
|
+
include FastRequire
|
|
261
|
+
if defined?(gem_original_require)
|
|
262
|
+
class << self
|
|
263
|
+
alias :original_remove_method :remove_method
|
|
264
|
+
|
|
265
|
+
def remove_method method # I think this actually might be needed <sigh>
|
|
266
|
+
if method.to_s == 'require'
|
|
267
|
+
#p 'not removing old require, since that\'s ours now'
|
|
268
|
+
else
|
|
269
|
+
original_remove_method method
|
|
270
|
+
end
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
# unused?
|
|
276
|
+
# def remove_method method
|
|
277
|
+
# p 'in mine2'
|
|
278
|
+
# end
|
|
279
|
+
|
|
280
|
+
# similarly overwrite this one...I guess...1.9.x...rubygems uses this as its default...I think...
|
|
281
|
+
alias :original_non_cached_require :gem_original_require
|
|
282
|
+
alias :gem_original_require :require_cached
|
|
231
283
|
else
|
|
232
|
-
@already_using_faster_require = true
|
|
233
|
-
include FastRequire
|
|
234
|
-
# overwrite old require...
|
|
235
284
|
alias :original_non_cached_require :require
|
|
236
|
-
|
|
237
|
-
end
|
|
285
|
+
alias :require :require_cached
|
|
286
|
+
end
|
|
238
287
|
|
|
239
|
-
end
|
|
288
|
+
end
|
data/spec/eval_me1.rb
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
eval(File.read('eval_me2.rb'), binding, File.expand_path('./eval_me2.rb'))
|
data/spec/eval_me2.rb
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require_relative 'eval_me1.rb'
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
$: << '.'
|
|
2
|
+
$: << 'files'
|
|
3
|
+
if true
|
|
4
|
+
require 'gem_after.rb'
|
|
5
|
+
else
|
|
6
|
+
p 'warning not using faster'
|
|
7
|
+
require 'rubygems'
|
|
8
|
+
end
|
|
9
|
+
require 'active_support'
|
|
10
|
+
raise 'poor acctive support' unless ActiveSupport::Inflector::Inflections.instance.plurals.length > 0
|
|
11
|
+
# d:/Ruby192/lib/ruby/gems/1.9.1/gems/diff-lcs-1.1.2/lib/diff/lcs/callbacks.rb:53: warning: already initialized constant SequenceCallbacks
|
|
12
|
+
require 'action_pack'
|
|
13
|
+
require 'action_pack'
|
|
14
|
+
# warning: already initialized constant JS_ESCAPE_MAP
|
|
15
|
+
p 'success'
|
data/spec/files/gem_after.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
$: << '.'
|
|
2
|
+
|
|
2
3
|
require '../lib/faster_require.rb'
|
|
3
4
|
require 'rubygems'
|
|
4
5
|
Gem::Specification
|
|
@@ -6,4 +7,5 @@ Gem::Specification
|
|
|
6
7
|
raise if FastRequire.already_loaded.to_a.flatten.grep(/files\/b.rb/).length > 0
|
|
7
8
|
require 'files/b.rb'
|
|
8
9
|
raise if(require 'files/b.rb')
|
|
9
|
-
raise unless
|
|
10
|
+
raise 'lacking b.rb ' + FastRequire.already_loaded.to_a.join(' ') unless FastRequire.already_loaded.to_a.flatten.grep(/files\/b.rb/).length > 0
|
|
11
|
+
p 'success'
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
$: << '.'
|
|
2
|
+
$: << 'files'
|
|
3
|
+
if true
|
|
4
|
+
require 'gem_after.rb'
|
|
5
|
+
else
|
|
6
|
+
p 'warning not using faster require'
|
|
7
|
+
require 'rubygems'
|
|
8
|
+
end
|
|
9
|
+
require 'ruby-debug'
|
|
10
|
+
require 'rspec'
|
|
11
|
+
# d:/Ruby192/lib/ruby/gems/1.9.1/gems/diff-lcs-1.1.2/lib/diff/lcs/callbacks.rb:53: warning: already initialized constant SequenceCallbacks
|
|
12
|
+
p 'success'
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
$: << '.'
|
|
2
|
+
|
|
3
|
+
require '../lib/faster_require.rb'
|
|
4
|
+
raise if FastRequire.already_loaded.to_a.flatten.grep(/files\/b.rb/).length > 0
|
|
5
|
+
require 'socket'
|
|
6
|
+
TCPSocket
|
|
7
|
+
raise 'lacking socket ' + FastRequire.already_loaded.to_a.join(' ') unless FastRequire.already_loaded.to_a.flatten.grep(/socket/).length > 0
|
|
8
|
+
p 'success'
|
data/spec/spec.fast_require.rb
CHANGED
|
@@ -20,13 +20,11 @@ unless RUBY_PLATFORM =~ /java/
|
|
|
20
20
|
FastRequire.load cached if File.exist? cached
|
|
21
21
|
FastRequire.save cached
|
|
22
22
|
else
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
require_relative '../lib/faster_require'
|
|
26
|
-
|
|
23
|
+
require 'spec/autorun'
|
|
24
|
+
require_relative '../lib/faster_require'
|
|
27
25
|
end
|
|
28
26
|
|
|
29
|
-
describe "requires faster" do
|
|
27
|
+
describe "requires faster!" do
|
|
30
28
|
|
|
31
29
|
before do
|
|
32
30
|
FastRequire.clear_all!
|
|
@@ -134,18 +132,25 @@ describe "requires faster" do
|
|
|
134
132
|
ruby "files/gem_before.rb"
|
|
135
133
|
end
|
|
136
134
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
135
|
+
['gem_after.rb', 'load_various_gems.rb', 'load_various_gems2.rb', 'active_support_no_double_load.rb', 'fast.rb'].each{|filename|
|
|
136
|
+
it "should not double load gems #{filename}" do
|
|
137
|
+
3.times {
|
|
138
|
+
a = `#{@ruby} -v files/#{filename} 2>&1`
|
|
139
|
+
a.should_not match('already initialized')
|
|
140
|
+
a.should_not match('from ') # an error backtrace...
|
|
141
|
+
a.should_not match('discarding old deep_const_get')
|
|
142
|
+
a.length.should be > 0
|
|
143
|
+
}
|
|
144
|
+
end
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
it "should throw if you require itself twice" do
|
|
143
148
|
Dir.chdir('files') do
|
|
144
149
|
assert !system(@ruby + 'attempt_double_load.rb')
|
|
145
150
|
end
|
|
146
151
|
end
|
|
147
152
|
|
|
148
|
-
it "
|
|
153
|
+
it "require 'abc' should not attempt to load file called exactly abc" do
|
|
149
154
|
Dir.chdir('files') do
|
|
150
155
|
ruby 'require_non_dot_rb_fails.rb'
|
|
151
156
|
end
|
|
@@ -174,12 +179,15 @@ describe "requires faster" do
|
|
|
174
179
|
end
|
|
175
180
|
end
|
|
176
181
|
|
|
177
|
-
it "should" do
|
|
182
|
+
it "should do this type loading too" do
|
|
178
183
|
Dir.chdir('files') do
|
|
179
184
|
ruby 'fast2.rb'
|
|
180
185
|
end
|
|
181
186
|
end
|
|
182
|
-
|
|
187
|
+
|
|
188
|
+
it "should be able to infer .so files like socket.so" #do
|
|
189
|
+
# ruby "files/socket_load.rb" # LODO reproduce failure
|
|
190
|
+
# end
|
|
183
191
|
|
|
184
192
|
|
|
185
193
|
end
|
metadata
CHANGED
|
@@ -1,102 +1,92 @@
|
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: faster_require
|
|
3
|
-
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
5
|
-
prerelease:
|
|
6
|
-
segments:
|
|
7
|
-
- 0
|
|
8
|
-
- 6
|
|
9
|
-
- 0
|
|
10
|
-
version: 0.6.0
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.7.0
|
|
5
|
+
prerelease:
|
|
11
6
|
platform: ruby
|
|
12
|
-
authors:
|
|
7
|
+
authors:
|
|
13
8
|
- Roger Pack
|
|
14
9
|
autorequire:
|
|
15
10
|
bindir: bin
|
|
16
11
|
cert_chain: []
|
|
17
|
-
|
|
18
|
-
date: 2011-02-25 00:00:00 -07:00
|
|
12
|
+
date: 2011-03-09 00:00:00.000000000 -07:00
|
|
19
13
|
default_executable: faster_require
|
|
20
|
-
dependencies:
|
|
21
|
-
- !ruby/object:Gem::Dependency
|
|
14
|
+
dependencies:
|
|
15
|
+
- !ruby/object:Gem::Dependency
|
|
22
16
|
name: redparse
|
|
17
|
+
requirement: &18274344 !ruby/object:Gem::Requirement
|
|
18
|
+
none: false
|
|
19
|
+
requirements:
|
|
20
|
+
- - ! '>='
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: '0'
|
|
23
|
+
type: :development
|
|
23
24
|
prerelease: false
|
|
24
|
-
|
|
25
|
+
version_requirements: *18274344
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: active_support
|
|
28
|
+
requirement: &18273984 !ruby/object:Gem::Requirement
|
|
25
29
|
none: false
|
|
26
|
-
requirements:
|
|
27
|
-
- -
|
|
28
|
-
- !ruby/object:Gem::Version
|
|
29
|
-
|
|
30
|
-
segments:
|
|
31
|
-
- 0
|
|
32
|
-
version: "0"
|
|
30
|
+
requirements:
|
|
31
|
+
- - =
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: 2.3.10
|
|
33
34
|
type: :development
|
|
34
|
-
version_requirements: *id001
|
|
35
|
-
- !ruby/object:Gem::Dependency
|
|
36
|
-
name: jeweler
|
|
37
35
|
prerelease: false
|
|
38
|
-
|
|
36
|
+
version_requirements: *18273984
|
|
37
|
+
- !ruby/object:Gem::Dependency
|
|
38
|
+
name: jeweler
|
|
39
|
+
requirement: &18273696 !ruby/object:Gem::Requirement
|
|
39
40
|
none: false
|
|
40
|
-
requirements:
|
|
41
|
-
- -
|
|
42
|
-
- !ruby/object:Gem::Version
|
|
43
|
-
|
|
44
|
-
segments:
|
|
45
|
-
- 0
|
|
46
|
-
version: "0"
|
|
41
|
+
requirements:
|
|
42
|
+
- - ! '>='
|
|
43
|
+
- !ruby/object:Gem::Version
|
|
44
|
+
version: '0'
|
|
47
45
|
type: :development
|
|
48
|
-
version_requirements: *id002
|
|
49
|
-
- !ruby/object:Gem::Dependency
|
|
50
|
-
name: rspec
|
|
51
46
|
prerelease: false
|
|
52
|
-
|
|
47
|
+
version_requirements: *18273696
|
|
48
|
+
- !ruby/object:Gem::Dependency
|
|
49
|
+
name: rspec
|
|
50
|
+
requirement: &18273336 !ruby/object:Gem::Requirement
|
|
53
51
|
none: false
|
|
54
|
-
requirements:
|
|
55
|
-
- -
|
|
56
|
-
- !ruby/object:Gem::Version
|
|
57
|
-
|
|
58
|
-
segments:
|
|
59
|
-
- 2
|
|
60
|
-
version: "2"
|
|
52
|
+
requirements:
|
|
53
|
+
- - ! '>='
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: '2'
|
|
61
56
|
type: :development
|
|
62
|
-
version_requirements: *id003
|
|
63
|
-
- !ruby/object:Gem::Dependency
|
|
64
|
-
name: sane
|
|
65
57
|
prerelease: false
|
|
66
|
-
|
|
58
|
+
version_requirements: *18273336
|
|
59
|
+
- !ruby/object:Gem::Dependency
|
|
60
|
+
name: sane
|
|
61
|
+
requirement: &18272976 !ruby/object:Gem::Requirement
|
|
67
62
|
none: false
|
|
68
|
-
requirements:
|
|
69
|
-
- -
|
|
70
|
-
- !ruby/object:Gem::Version
|
|
71
|
-
|
|
72
|
-
segments:
|
|
73
|
-
- 0
|
|
74
|
-
version: "0"
|
|
63
|
+
requirements:
|
|
64
|
+
- - ! '>='
|
|
65
|
+
- !ruby/object:Gem::Version
|
|
66
|
+
version: '0'
|
|
75
67
|
type: :development
|
|
76
|
-
version_requirements: *id004
|
|
77
|
-
- !ruby/object:Gem::Dependency
|
|
78
|
-
name: ruby-prof
|
|
79
68
|
prerelease: false
|
|
80
|
-
|
|
69
|
+
version_requirements: *18272976
|
|
70
|
+
- !ruby/object:Gem::Dependency
|
|
71
|
+
name: ruby-prof
|
|
72
|
+
requirement: &18272652 !ruby/object:Gem::Requirement
|
|
81
73
|
none: false
|
|
82
|
-
requirements:
|
|
83
|
-
- -
|
|
84
|
-
- !ruby/object:Gem::Version
|
|
85
|
-
|
|
86
|
-
segments:
|
|
87
|
-
- 0
|
|
88
|
-
version: "0"
|
|
74
|
+
requirements:
|
|
75
|
+
- - ! '>='
|
|
76
|
+
- !ruby/object:Gem::Version
|
|
77
|
+
version: '0'
|
|
89
78
|
type: :development
|
|
90
|
-
|
|
91
|
-
|
|
79
|
+
prerelease: false
|
|
80
|
+
version_requirements: *18272652
|
|
81
|
+
description: A tool designed to speedup library loading in Ruby by caching library
|
|
82
|
+
locations
|
|
92
83
|
email: rogerdpack@gmail.com
|
|
93
|
-
executables:
|
|
84
|
+
executables:
|
|
94
85
|
- faster_require
|
|
95
86
|
extensions: []
|
|
96
|
-
|
|
97
|
-
extra_rdoc_files:
|
|
87
|
+
extra_rdoc_files:
|
|
98
88
|
- README
|
|
99
|
-
files:
|
|
89
|
+
files:
|
|
100
90
|
- README
|
|
101
91
|
- Rakefile
|
|
102
92
|
- VERSION
|
|
@@ -117,6 +107,8 @@ files:
|
|
|
117
107
|
- spec/files/gem_after.rb
|
|
118
108
|
- spec/files/gem_before.rb
|
|
119
109
|
- spec/files/large.rb
|
|
110
|
+
- spec/files/load_various_gems.rb
|
|
111
|
+
- spec/files/load_various_gems2.rb
|
|
120
112
|
- spec/files/non_dot_rb.rb
|
|
121
113
|
- spec/files/require_full_path.rb
|
|
122
114
|
- spec/files/require_non_dot_rb_fails.rb
|
|
@@ -125,46 +117,44 @@ files:
|
|
|
125
117
|
- spec/files/should_put_modules_in_right_place.rb
|
|
126
118
|
- spec/files/slow.rb
|
|
127
119
|
- spec/spec.fast_require.rb
|
|
120
|
+
- spec/eval_me1.rb
|
|
121
|
+
- spec/eval_me2.rb
|
|
128
122
|
- spec/files/a.rb
|
|
123
|
+
- spec/files/active_support_no_double_load.rb
|
|
124
|
+
- spec/files/socket_load.rb
|
|
129
125
|
- spec/temp/slow.rb
|
|
130
126
|
- spec/temp/yo.rb
|
|
131
127
|
has_rdoc: true
|
|
132
128
|
homepage: http://github.com/rdp/faster_require
|
|
133
129
|
licenses: []
|
|
134
|
-
|
|
135
130
|
post_install_message:
|
|
136
131
|
rdoc_options: []
|
|
137
|
-
|
|
138
|
-
require_paths:
|
|
132
|
+
require_paths:
|
|
139
133
|
- lib
|
|
140
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
|
134
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
141
135
|
none: false
|
|
142
|
-
requirements:
|
|
143
|
-
- -
|
|
144
|
-
- !ruby/object:Gem::Version
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
- 0
|
|
148
|
-
version: "0"
|
|
149
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
|
+
requirements:
|
|
137
|
+
- - ! '>='
|
|
138
|
+
- !ruby/object:Gem::Version
|
|
139
|
+
version: '0'
|
|
140
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
141
|
none: false
|
|
151
|
-
requirements:
|
|
152
|
-
- -
|
|
153
|
-
- !ruby/object:Gem::Version
|
|
154
|
-
|
|
155
|
-
segments:
|
|
156
|
-
- 0
|
|
157
|
-
version: "0"
|
|
142
|
+
requirements:
|
|
143
|
+
- - ! '>='
|
|
144
|
+
- !ruby/object:Gem::Version
|
|
145
|
+
version: '0'
|
|
158
146
|
requirements: []
|
|
159
|
-
|
|
160
147
|
rubyforge_project:
|
|
161
|
-
rubygems_version: 1.
|
|
148
|
+
rubygems_version: 1.6.0
|
|
162
149
|
signing_key:
|
|
163
150
|
specification_version: 3
|
|
164
151
|
summary: Speed library loading in Ruby
|
|
165
|
-
test_files:
|
|
152
|
+
test_files:
|
|
153
|
+
- spec/eval_me1.rb
|
|
154
|
+
- spec/eval_me2.rb
|
|
166
155
|
- spec/files/a.rb
|
|
167
156
|
- spec/files/a_requires_b.rb
|
|
157
|
+
- spec/files/active_support_no_double_load.rb
|
|
168
158
|
- spec/files/attempt_double_load.rb
|
|
169
159
|
- spec/files/b.rb
|
|
170
160
|
- spec/files/c.rb
|
|
@@ -175,6 +165,8 @@ test_files:
|
|
|
175
165
|
- spec/files/gem_after.rb
|
|
176
166
|
- spec/files/gem_before.rb
|
|
177
167
|
- spec/files/large.rb
|
|
168
|
+
- spec/files/load_various_gems.rb
|
|
169
|
+
- spec/files/load_various_gems2.rb
|
|
178
170
|
- spec/files/non_dot_rb.rb
|
|
179
171
|
- spec/files/require_full_path.rb
|
|
180
172
|
- spec/files/require_non_dot_rb_fails.rb
|
|
@@ -182,6 +174,7 @@ test_files:
|
|
|
182
174
|
- spec/files/requires_itself.rb
|
|
183
175
|
- spec/files/should_put_modules_in_right_place.rb
|
|
184
176
|
- spec/files/slow.rb
|
|
177
|
+
- spec/files/socket_load.rb
|
|
185
178
|
- spec/spec.fast_require.rb
|
|
186
179
|
- spec/temp/slow.rb
|
|
187
180
|
- spec/temp/yo.rb
|