faster_require 0.8.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +8 -0
- data/README +37 -11
- data/Rakefile +8 -8
- data/VERSION +1 -1
- data/lib/faster_require.rb +61 -43
- data/spec/files/active_support_no_double_load.rb +2 -2
- data/spec/files/fast.rb +1 -2
- data/spec/files/fast2.rb +1 -2
- data/spec/files/file_that_sets_ignore_pwd_flag.rb +2 -0
- data/spec/files/gem_after.rb +0 -1
- data/spec/files/load_various_gems.rb +1 -2
- data/spec/files/load_various_gems2.rb +0 -1
- data/spec/files/regin_gem.rb +6 -0
- data/spec/files/socket_load.rb +0 -1
- data/spec/spec.fast_require.rb +37 -21
- metadata +111 -127
data/ChangeLog
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
0.9.1: work with rails 3.0.7 through a kludgey way...
|
2
|
+
|
3
|
+
0.9.0: refactors, bug fix for poor file, can autoload disregarding dir now
|
4
|
+
|
5
|
+
0.8.1: work with 1.8.6 again
|
6
|
+
|
7
|
+
0.8.0: work with 1.9.x again
|
8
|
+
|
1
9
|
0.7.5: unique hash now, for the cache file [hopefuly]
|
2
10
|
|
3
11
|
0.7.4: allow double loading, for rails apps and gems to load it.
|
data/README
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
A little utility to make
|
1
|
+
A little utility to make load time faster, especially by making
|
2
2
|
|
3
3
|
require 'xxx'
|
4
4
|
|
5
|
-
take much less time. As in much less. Well, on windows at least
|
5
|
+
take much less time. As in much less. Well, on windows at least it's faster.
|
6
|
+
It speeds up how long it takes things to load in windows, like rails apps.
|
6
7
|
|
7
8
|
Well, mostly on windows--on linux it's a speedup of only 0.41 to 0.45s, or so. [1]
|
8
9
|
|
@@ -55,16 +56,25 @@ running "rake -T" somewhere
|
|
55
56
|
|
56
57
|
Note: in reality what we should do is fix core so that it doesn't have such awful load time in windows. There may be some inefficiency in there. For now, this is a work-around that helps.
|
57
58
|
|
58
|
-
Also it helps with SSD's even, on windows, as it avoids some cpu used at require time.
|
59
|
+
Also it helps with SSD's even, on windows, as it avoids some cpu used at require time, at least for 1.9.x
|
60
|
+
|
61
|
+
NB that installing newer versions of rubygems also seems to speedup start time (see below for how you can use them both, however, which is the best way).
|
62
|
+
In fact, 1.8.7 with newer rubygems and only very few requires seems pretty fast, even without faster_require.
|
63
|
+
Once you have any number of requires, though, you'll want faster_require.
|
64
|
+
Rails needs it, and 1.9 still needs it, though, even with a newer rubygems,
|
65
|
+
so you'll get some benefit from this library always--but don't take my word for it,
|
66
|
+
profile it and find out for yourself.
|
59
67
|
|
60
68
|
== How to use ==
|
61
69
|
|
62
|
-
|
70
|
+
The naive we is to use it by installing the gem, then adding
|
71
|
+
|
63
72
|
require 'rubygems'
|
64
73
|
require 'faster_require'
|
65
|
-
to the top of your script.
|
66
74
|
|
67
|
-
|
75
|
+
to the top of some (your initial) script.
|
76
|
+
|
77
|
+
However this doesn't speedup the loading of rubygems itself (XXX is much speedup?), so you can do this to get best performance:
|
68
78
|
|
69
79
|
G:>gem which faster_require
|
70
80
|
C:/installs/Ruby187/lib/ruby/gems/1.8/gems/faster_require-0.7.4/lib/faster_require.rb
|
@@ -73,7 +83,7 @@ now before doing require rubygems in your script, do this:
|
|
73
83
|
|
74
84
|
require 'C:/installs/Ruby187/lib/ruby/gems/1.8/gems/faster_require-0.7.4/lib/faster_require.rb'
|
75
85
|
|
76
|
-
Then rubygems load will be cached too.
|
86
|
+
Then rubygems' load will be cached too. Which is faster. Or see "installing globally" below.
|
77
87
|
|
78
88
|
== How to use in Rails ==
|
79
89
|
|
@@ -107,7 +117,6 @@ If you use bundler to change bundled gems, you'll want to run the command $ fast
|
|
107
117
|
so that it will pick up any new load paths. Also if you moves files around to new directories, you may want to do the same.
|
108
118
|
As you install any new gems, it should clear the paths automatically for you.
|
109
119
|
|
110
|
-
|
111
120
|
== How to use generally/globally ==
|
112
121
|
|
113
122
|
You can install it to be used "always" (well, for anything that loads rubygems, at least, which is most things, via something like the following):
|
@@ -118,14 +127,31 @@ d:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems.rb
|
|
118
127
|
$ gem which faster_require
|
119
128
|
d:/Ruby192/lib/ruby/gems/1.9.1/gems/faster_require-0.6.0/lib/faster_require.rb
|
120
129
|
|
121
|
-
Now edit
|
130
|
+
Now edit the rubygems.rb file, and add a require line to the top of it of the faster_require file, like this:
|
131
|
+
require 'd:/Ruby192/lib/ruby/gems/1.9.1/gems/faster_require-0.6.0/lib/faster_require.rb'
|
122
132
|
|
123
|
-
|
133
|
+
at the top of rubygems.rb file
|
124
134
|
|
125
|
-
update the path
|
135
|
+
update the path to be your own, obviously. You'll also have to change that added line if
|
126
136
|
you ever install a newer version of faster_require gem, or if you update your version of rubygems,
|
127
137
|
as the rubygems.rb file will be wiped clean at that point.
|
128
138
|
|
139
|
+
This will cause everything to load faster.
|
140
|
+
|
141
|
+
== How to ignore PWD for faster_require ==
|
142
|
+
|
143
|
+
Faster_require also takes into consideration your Dir.pwd when you run it, for cacheing sake.
|
144
|
+
This means that if you run a ruby gem install script (like redcar's bin/redcar, for instance) and run it from different directories, it will always
|
145
|
+
be slow the first time you run it in each directory.
|
146
|
+
To make it be fast and basically disregard PWD, you can add global setting $faster_require_ignore_pwd_for_cache = true
|
147
|
+
and set it before requiring faster_require itself.
|
148
|
+
|
149
|
+
So not rubygems.rb at the top would look like
|
150
|
+
$faster_require_ignore_pwd_for_cache = true
|
151
|
+
require 'd:/Ruby192/lib/ruby/gems/1.9.1/gems/faster_require-0.6.0/lib/faster_require.rb'
|
152
|
+
|
153
|
+
And now your gem scripts will run fast regardless of where you run them from.
|
154
|
+
|
129
155
|
== See also ==
|
130
156
|
|
131
157
|
Spork can help speedup rails tests. I "should" work well when used in conjunction with faster_require, as well.
|
data/Rakefile
CHANGED
@@ -1,28 +1,28 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
|
3
|
-
ENV['PATH'] = 'C:\Program Files\Git\bin;' + ENV['PATH']
|
1
|
+
require 'rubygems'
|
4
2
|
|
5
3
|
begin
|
6
4
|
require 'psych' # sigh
|
7
5
|
rescue ::LoadError
|
8
6
|
end
|
9
|
-
|
10
7
|
require 'jeweler'
|
11
8
|
Jeweler::Tasks.new do |s|
|
12
9
|
s.name = "faster_require"
|
13
10
|
s.summary = "Speed library loading in Ruby"
|
14
|
-
s.description = "A tool designed to speedup library loading in Ruby by caching library locations"
|
11
|
+
s.description = "A tool designed to speedup library loading (startup time) in Ruby by caching library locations"
|
15
12
|
s.email = "rogerdpack@gmail.com"
|
16
13
|
s.homepage = "http://github.com/rdp/faster_require"
|
17
|
-
s.authors = ["Roger Pack"]
|
14
|
+
s.authors = ["Roger Pack", "faisal"]
|
18
15
|
s.add_development_dependency 'redparse'
|
19
16
|
s.add_development_dependency 'activesupport', '= 2.3.10'
|
20
17
|
s.add_development_dependency 'actionpack', '= 2.3.10'
|
21
|
-
# s.add_development_dependency 'ruby-debug' too... or ruby-debug19 pick your poison
|
22
18
|
s.add_development_dependency 'jeweler'
|
23
19
|
s.add_development_dependency 'rspec', '>= 2'
|
24
20
|
s.add_development_dependency 'sane'
|
25
21
|
s.add_development_dependency 'facets'
|
26
22
|
s.add_development_dependency 'ruby-prof'
|
27
|
-
|
23
|
+
s.add_development_dependency 'rack-mount', '=0.6.14'
|
24
|
+
s.add_development_dependency 'rack', '=1.2.2'
|
25
|
+
|
26
|
+
# ALSO INSTALL THIS! ->
|
27
|
+
# s.add_development_dependency 'ruby-debug' too... or ruby-debug19 pick your poison
|
28
28
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.9.1
|
data/lib/faster_require.rb
CHANGED
@@ -1,16 +1,15 @@
|
|
1
|
-
|
2
|
-
# check for double load...because we're afraid to load twice, since we override require et al
|
1
|
+
# check for and avoid a double load...because we're afraid to load twice, since we override require et al
|
3
2
|
|
4
3
|
if(defined?($already_using_faster_require))
|
5
4
|
p 'warning: faster_require double load--expected?' if $FAST_REQUIRE_DEBUG
|
6
5
|
local_version = File.read(File.dirname(__FILE__) + "/../VERSION")
|
7
6
|
raise "mismatched faster_require versions! #{local_version} != #{FastRequire::VERSION}" unless local_version == FastRequire::VERSION
|
8
7
|
else
|
8
|
+
|
9
9
|
$already_using_faster_require = true
|
10
10
|
|
11
11
|
|
12
|
-
|
13
|
-
require 'rbconfig' # maybe could cache this one's, too? probably not...
|
12
|
+
require 'rbconfig' # maybe could cache this one's loc, too? probably not...
|
14
13
|
|
15
14
|
module FastRequire
|
16
15
|
|
@@ -65,7 +64,15 @@ module FastRequire
|
|
65
64
|
|
66
65
|
# try to be a unique, but not too long, filename, for restrictions on filename length in doze
|
67
66
|
ruby_bin_name = config['bindir'] + config['ruby_install_name'] # needed if you have two rubies, same box, same ruby description [version, patch number]
|
68
|
-
parts = [File.basename($0),
|
67
|
+
parts = [File.basename($0), RUBY_PATCHLEVEL.to_s, RUBY_PLATFORM, RUBY_VERSION, RUBY_VERSION, File.expand_path(File.dirname($0)), ruby_bin_name]
|
68
|
+
unless defined?($faster_require_ignore_pwd_for_cache)
|
69
|
+
# add in Dir.pwd
|
70
|
+
parts << File.basename(Dir.pwd)
|
71
|
+
parts << Dir.pwd
|
72
|
+
else
|
73
|
+
p 'ignoring dirpwd for cached file location' if $FAST_REQUIRE_DEBUG
|
74
|
+
end
|
75
|
+
|
69
76
|
sanitized_parts = parts.map{|part| sanitize(part)}
|
70
77
|
|
71
78
|
full_parts_hash = string_array_cruddy_hash(parts).to_s
|
@@ -73,22 +80,46 @@ module FastRequire
|
|
73
80
|
loc_name = (sanitized_parts.map{|part| part[0..5] + (part[-5..-1] || '')}).join('-') + '-' + full_parts_hash + '.marsh'
|
74
81
|
|
75
82
|
@@loc = @@dir + '/' + loc_name
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
83
|
+
|
84
|
+
if File.exist?(@@loc)
|
85
|
+
FastRequire.load @@loc
|
86
|
+
else
|
87
|
+
@@require_locs = {}
|
88
|
+
end
|
89
|
+
|
90
|
+
@@already_loaded = {}
|
82
91
|
|
83
|
-
|
92
|
+
$LOADED_FEATURES.each{|already_loaded|
|
93
|
+
# in 1.8 they might be partial paths
|
94
|
+
# in 1.9, they might be non collapsed paths
|
95
|
+
# so we have to sanitize them here...
|
96
|
+
# XXXX File.exist? is a bit too loose, here...
|
97
|
+
if File.exist?(already_loaded)
|
98
|
+
key = File.expand_path(already_loaded)
|
99
|
+
else
|
100
|
+
key = FastRequire.guess_discover(already_loaded) || already_loaded
|
101
|
+
end
|
102
|
+
@@already_loaded[key] = true
|
103
|
+
}
|
84
104
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
105
|
+
@@already_loaded[File.expand_path(__FILE__)] = true # this file itself isn't in loaded features, yet, but very soon will be..
|
106
|
+
# a special case--I hope...
|
107
|
+
|
108
|
+
# also disallow re-loading $0
|
109
|
+
@@require_locs[$0] = File.expand_path($0) # so when we run into $0 on a freak require, we will skip it...
|
110
|
+
@@already_loaded[File.expand_path($0)] = true
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
def self.load filename
|
115
|
+
cached_marshal_data = File.open(filename, 'rb') {|f| f.read}
|
116
|
+
begin
|
117
|
+
@@require_locs = Marshal.restore( cached_marshal_data )
|
118
|
+
rescue ArgumentError
|
119
|
+
@@require_locs= {}
|
120
|
+
end
|
89
121
|
end
|
90
122
|
|
91
|
-
@@already_loaded = {}
|
92
123
|
|
93
124
|
# try to see where this file was loaded from, from $:
|
94
125
|
# partial_name might be abc.rb, or might be abc
|
@@ -128,26 +159,8 @@ module FastRequire
|
|
128
159
|
nil
|
129
160
|
end
|
130
161
|
end
|
131
|
-
|
132
|
-
|
133
|
-
# in 1.8 they might be partial paths
|
134
|
-
# in 1.9, they might be non collapsed paths
|
135
|
-
# so we have to sanitize them here...
|
136
|
-
# XXXX File.exist? is a bit too loose, here...
|
137
|
-
if File.exist?(already_loaded)
|
138
|
-
key = File.expand_path(already_loaded)
|
139
|
-
else
|
140
|
-
key = FastRequire.guess_discover(already_loaded) || already_loaded
|
141
|
-
end
|
142
|
-
@@already_loaded[key] = true
|
143
|
-
}
|
144
|
-
|
145
|
-
@@already_loaded[File.expand_path(__FILE__)] = true # this file itself isn't in loaded features, yet, but very soon will be..
|
146
|
-
# a special case--I hope...
|
147
|
-
|
148
|
-
# also disallow re-loading $0
|
149
|
-
@@require_locs[$0] = File.expand_path($0) # so when we run into $0 on a freak require, we will skip it...
|
150
|
-
@@already_loaded[File.expand_path($0)] = true
|
162
|
+
|
163
|
+
FastRequire.setup
|
151
164
|
|
152
165
|
def self.already_loaded
|
153
166
|
@@already_loaded
|
@@ -177,6 +190,7 @@ module FastRequire
|
|
177
190
|
File.open(to_file, 'wb'){|f| f.write Marshal.dump(@@require_locs)}
|
178
191
|
end
|
179
192
|
|
193
|
+
# for testing use only, basically
|
180
194
|
def self.clear_all!
|
181
195
|
require 'fileutils'
|
182
196
|
success = false
|
@@ -197,6 +211,7 @@ module FastRequire
|
|
197
211
|
IN_PROCESS = []
|
198
212
|
ALL_IN_PROCESS = []
|
199
213
|
@@count = 0
|
214
|
+
|
200
215
|
public
|
201
216
|
|
202
217
|
def require_cached lib
|
@@ -230,24 +245,27 @@ module FastRequire
|
|
230
245
|
no_suffix_lib = lib.gsub(/\.[^.]+$/, '')
|
231
246
|
libs_path = no_suffix_full_path.gsub(no_suffix_lib, '')
|
232
247
|
libs_path = File.expand_path(libs_path) # strip off trailing '/'
|
233
|
-
|
248
|
+
|
249
|
+
$: << libs_path unless $:.index(libs_path) # add in this ones real require path, so that neighboring autoloads will work
|
250
|
+
known_locs_dir = File.dirname(known_loc)
|
251
|
+
$: << known_locs_dir unless $:.index(known_locs_dir) # attempt to avoid the regin loading bug...yipes.
|
234
252
|
|
235
253
|
# try some more autoload conivings...so that it won't attempt to autoload if it runs into it later...
|
236
254
|
relative_full_path = known_loc.sub(libs_path, '')[1..-1]
|
237
255
|
$LOADED_FEATURES << relative_full_path unless $LOADED_FEATURES.index(relative_full_path) # add in with .rb, too, for autoload
|
238
|
-
# $LOADED_FEATURES << relative_full_path.gsub('.rb', '') # don't think you need this one
|
239
256
|
|
240
257
|
# load(known_loc, false) # too slow
|
241
|
-
|
242
|
-
if
|
243
|
-
|
258
|
+
|
259
|
+
# use eval: if this fails to load breaks re-save the offending file in binary mode, or file an issue on the faster_require tracker...
|
260
|
+
contents = File.open(known_loc, 'rb') {|f| f.read} # read only costs 0.34/10.0 s...
|
261
|
+
if contents =~ /require_relative/ # =~ is faster apparently faster than .include?
|
262
|
+
load(known_loc, false) # load is slow, but overcomes a ruby core bug: http://redmine.ruby-lang.org/issues/4487
|
244
263
|
else
|
245
264
|
eval(contents, TOPLEVEL_BINDING, known_loc) # note the 'rb' here--this means it's reading .rb files as binary, which *typically* works...maybe unnecessary though?
|
246
265
|
end
|
247
266
|
ensure
|
248
267
|
raise 'unexpected' unless IN_PROCESS.pop == known_loc
|
249
268
|
end
|
250
|
-
# --if it breaks re-save the offending file in binary mode, or file an issue on the tracker...
|
251
269
|
return true
|
252
270
|
end
|
253
271
|
else
|
@@ -11,5 +11,5 @@ raise 'poor acctive support' unless ActiveSupport::Inflector::Inflections.instan
|
|
11
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
12
|
require 'action_pack'
|
13
13
|
require 'action_pack'
|
14
|
-
|
15
|
-
|
14
|
+
|
15
|
+
# reproduce warning: already initialized constant JS_ESCAPE_MAP
|
data/spec/files/fast.rb
CHANGED
data/spec/files/fast2.rb
CHANGED
data/spec/files/gem_after.rb
CHANGED
@@ -8,4 +8,3 @@ raise if FastRequire.already_loaded.to_a.flatten.grep(/files\/b.rb/).length > 0
|
|
8
8
|
require 'files/b.rb'
|
9
9
|
raise if(require 'files/b.rb')
|
10
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'
|
@@ -8,5 +8,4 @@ else
|
|
8
8
|
end
|
9
9
|
require 'ruby-debug'
|
10
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'
|
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
|
data/spec/files/socket_load.rb
CHANGED
@@ -8,4 +8,3 @@ require 'stringio'
|
|
8
8
|
StringIO
|
9
9
|
raise 'lacking socket ' + FastRequire.already_loaded.to_a.join(' ') unless FastRequire.already_loaded.to_a.flatten.grep(/socket/).length > 0
|
10
10
|
raise 'lacking stringio ' + FastRequire.already_loaded.to_a.join(' ') unless FastRequire.already_loaded.to_a.flatten.grep(/stringio/).length > 0
|
11
|
-
p 'success'
|
data/spec/spec.fast_require.rb
CHANGED
@@ -1,26 +1,21 @@
|
|
1
1
|
# could also set this here if desired: $FAST_REQUIRE_DEBUG = true
|
2
2
|
|
3
|
-
require 'rubygems'
|
3
|
+
require 'rubygems'
|
4
4
|
require 'sane'
|
5
|
-
require 'benchmark'
|
5
|
+
require 'benchmark' # Benchmark.realtime
|
6
6
|
|
7
|
-
raise 'double faster_require' if defined?($already_using_faster_require) # disallowed, since who knows what version the gem one is...
|
7
|
+
raise 'double faster_require' if defined?($already_using_faster_require) # disallowed, since who knows what version the gem one is, and even if it's the same...confusion!
|
8
8
|
|
9
|
-
unless RUBY_PLATFORM =~ /java/
|
10
|
-
require_relative '../lib/faster_require'
|
9
|
+
unless RUBY_PLATFORM =~ /java/ # ??
|
10
|
+
#require_relative '../lib/faster_require'
|
11
11
|
cached = '.cached_spec_locs' + RUBY_VERSION
|
12
12
|
# use it for our own local test specs
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
# rspec 2
|
17
|
-
require 'rspec'
|
18
|
-
end
|
19
|
-
FastRequire.load cached if File.exist? cached
|
20
|
-
FastRequire.save cached
|
13
|
+
require 'rspec'
|
14
|
+
require_relative '../lib/faster_require'
|
15
|
+
# FastRequire.load cached if File.exist? cached
|
21
16
|
else
|
22
|
-
|
23
|
-
|
17
|
+
require 'rspec'
|
18
|
+
require_relative '../lib/faster_require'
|
24
19
|
end
|
25
20
|
|
26
21
|
describe "requires faster!" do
|
@@ -81,10 +76,10 @@ describe "requires faster!" do
|
|
81
76
|
|
82
77
|
it "could cache the file contents, even, too, in theory...oh my"
|
83
78
|
|
84
|
-
it "
|
79
|
+
it "could not re-save the cache file if it hasn't changed [?]"
|
85
80
|
|
86
81
|
it "should load .so files still, and only load them once" do
|
87
|
-
# ruby-prof gem
|
82
|
+
# from the ruby-prof gem
|
88
83
|
3.times { require 'ruby_prof.so'; RubyProf }
|
89
84
|
assert $LOADED_FEATURES.length == (@old_length + 1)
|
90
85
|
end
|
@@ -102,7 +97,7 @@ describe "requires faster!" do
|
|
102
97
|
end
|
103
98
|
|
104
99
|
it "should have different caches based on the file being run, and Dir.pwd" do
|
105
|
-
#
|
100
|
+
# this doesn't use the cache right first time if you, say, profile your script with ruby-prof, but hey.
|
106
101
|
assert Dir[FastRequire.dir + '/*'].length == 0 # all clear
|
107
102
|
Dir.chdir('files') do
|
108
103
|
assert system("ruby -I../../lib d.rb")
|
@@ -113,14 +108,31 @@ describe "requires faster!" do
|
|
113
108
|
assert Dir[FastRequire.dir + '/*d.rb*'].length == 1 # use full path
|
114
109
|
assert Dir[FastRequire.dir + '/*e.rb*'].length == 2 # different Dir.pwd's
|
115
110
|
end
|
111
|
+
|
112
|
+
it "should ignore the pwd setting if you set a certain global variable" do
|
113
|
+
Dir.chdir('files') do
|
114
|
+
assert system("ruby -I../../lib file_that_sets_ignore_pwd_flag.rb")
|
115
|
+
assert system("ruby -C.. -I../lib files/file_that_sets_ignore_pwd_flag.rb")
|
116
|
+
end
|
117
|
+
assert Dir[FastRequire.dir + '/*file_*'].length == 1 # re-use a cache for the file, despite different Dir.pwd's
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should not die if it hits a poor cache file" do
|
121
|
+
FastRequire.clear_all!
|
122
|
+
assert system("ruby -Ilib files/fast.rb")
|
123
|
+
files = Dir[FastRequire.dir + '/*']
|
124
|
+
assert files.length == 1
|
125
|
+
File.open(files[0], 'w') {} # clear it, which is bad marshal data
|
126
|
+
assert system("ruby -Ilib files/fast.rb")
|
127
|
+
end
|
116
128
|
|
117
|
-
it "should work with encoded files too" # most are
|
129
|
+
it "should work with encoded files too" # most are ascii, so...low prio
|
118
130
|
|
119
131
|
private
|
120
132
|
|
121
133
|
def ruby filename
|
122
134
|
command = @ruby + " " + filename
|
123
|
-
3.times { raise command unless system(command) }
|
135
|
+
3.times { |n| raise command + " failed #{n}th time with zero as first" unless system(command) }
|
124
136
|
end
|
125
137
|
|
126
138
|
it "should override rubygems' require if rubygems is loaded after the fact...maybe by hooking to Gem::const_defined or something" do
|
@@ -185,10 +197,14 @@ describe "requires faster!" do
|
|
185
197
|
end
|
186
198
|
end
|
187
199
|
|
200
|
+
it "should work for gems that tweak the load path, from within themselves, for their own autoload [boo]" do
|
201
|
+
ruby 'files/regin_gem.rb'
|
202
|
+
end
|
203
|
+
|
188
204
|
# was there some failure like
|
189
205
|
# stringio or enumerator.so?
|
190
206
|
it "should be able to infer .so files" #do
|
191
|
-
# ruby "files/socket_load.rb" # LODO reproduce failure?
|
207
|
+
# ruby "files/socket_load.rb" # LODO reproduce failure first, from this file?
|
192
208
|
# end
|
193
209
|
|
194
210
|
end
|
metadata
CHANGED
@@ -1,150 +1,139 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: faster_require
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.1
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 8
|
9
|
-
- 0
|
10
|
-
version: 0.8.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Roger Pack
|
9
|
+
- faisal
|
14
10
|
autorequire:
|
15
11
|
bindir: bin
|
16
12
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2011-04-15 00:00:00 -06:00
|
13
|
+
date: 2011-04-25 00:00:00.000000000 -06:00
|
19
14
|
default_executable: faster_require
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
22
17
|
name: redparse
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
18
|
+
requirement: &20927892 !ruby/object:Gem::Requirement
|
25
19
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
version: "0"
|
20
|
+
requirements:
|
21
|
+
- - ! '>='
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '0'
|
33
24
|
type: :development
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: activesupport
|
37
25
|
prerelease: false
|
38
|
-
|
26
|
+
version_requirements: *20927892
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: &20918784 !ruby/object:Gem::Requirement
|
39
30
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
hash: 23
|
44
|
-
segments:
|
45
|
-
- 2
|
46
|
-
- 3
|
47
|
-
- 10
|
31
|
+
requirements:
|
32
|
+
- - =
|
33
|
+
- !ruby/object:Gem::Version
|
48
34
|
version: 2.3.10
|
49
35
|
type: :development
|
50
|
-
version_requirements: *id002
|
51
|
-
- !ruby/object:Gem::Dependency
|
52
|
-
name: actionpack
|
53
36
|
prerelease: false
|
54
|
-
|
37
|
+
version_requirements: *20918784
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: actionpack
|
40
|
+
requirement: &20918016 !ruby/object:Gem::Requirement
|
55
41
|
none: false
|
56
|
-
requirements:
|
57
|
-
- -
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
hash: 23
|
60
|
-
segments:
|
61
|
-
- 2
|
62
|
-
- 3
|
63
|
-
- 10
|
42
|
+
requirements:
|
43
|
+
- - =
|
44
|
+
- !ruby/object:Gem::Version
|
64
45
|
version: 2.3.10
|
65
46
|
type: :development
|
66
|
-
version_requirements: *id003
|
67
|
-
- !ruby/object:Gem::Dependency
|
68
|
-
name: jeweler
|
69
47
|
prerelease: false
|
70
|
-
|
48
|
+
version_requirements: *20918016
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: jeweler
|
51
|
+
requirement: &20916816 !ruby/object:Gem::Requirement
|
71
52
|
none: false
|
72
|
-
requirements:
|
73
|
-
- -
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
|
76
|
-
segments:
|
77
|
-
- 0
|
78
|
-
version: "0"
|
53
|
+
requirements:
|
54
|
+
- - ! '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
79
57
|
type: :development
|
80
|
-
version_requirements: *id004
|
81
|
-
- !ruby/object:Gem::Dependency
|
82
|
-
name: rspec
|
83
58
|
prerelease: false
|
84
|
-
|
59
|
+
version_requirements: *20916816
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: rspec
|
62
|
+
requirement: &20914764 !ruby/object:Gem::Requirement
|
85
63
|
none: false
|
86
|
-
requirements:
|
87
|
-
- -
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
|
90
|
-
segments:
|
91
|
-
- 2
|
92
|
-
version: "2"
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '2'
|
93
68
|
type: :development
|
94
|
-
version_requirements: *id005
|
95
|
-
- !ruby/object:Gem::Dependency
|
96
|
-
name: sane
|
97
69
|
prerelease: false
|
98
|
-
|
70
|
+
version_requirements: *20914764
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: sane
|
73
|
+
requirement: &20913444 !ruby/object:Gem::Requirement
|
99
74
|
none: false
|
100
|
-
requirements:
|
101
|
-
- -
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
|
104
|
-
segments:
|
105
|
-
- 0
|
106
|
-
version: "0"
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
107
79
|
type: :development
|
108
|
-
version_requirements: *id006
|
109
|
-
- !ruby/object:Gem::Dependency
|
110
|
-
name: facets
|
111
80
|
prerelease: false
|
112
|
-
|
81
|
+
version_requirements: *20913444
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: facets
|
84
|
+
requirement: &20911236 !ruby/object:Gem::Requirement
|
113
85
|
none: false
|
114
|
-
requirements:
|
115
|
-
- -
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
|
118
|
-
segments:
|
119
|
-
- 0
|
120
|
-
version: "0"
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
121
90
|
type: :development
|
122
|
-
|
123
|
-
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: *20911236
|
93
|
+
- !ruby/object:Gem::Dependency
|
124
94
|
name: ruby-prof
|
95
|
+
requirement: &20893704 !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ! '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
type: :development
|
125
102
|
prerelease: false
|
126
|
-
|
103
|
+
version_requirements: *20893704
|
104
|
+
- !ruby/object:Gem::Dependency
|
105
|
+
name: rack-mount
|
106
|
+
requirement: &20892192 !ruby/object:Gem::Requirement
|
127
107
|
none: false
|
128
|
-
requirements:
|
129
|
-
- -
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
|
132
|
-
segments:
|
133
|
-
- 0
|
134
|
-
version: "0"
|
108
|
+
requirements:
|
109
|
+
- - =
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: 0.6.14
|
135
112
|
type: :development
|
136
|
-
|
137
|
-
|
113
|
+
prerelease: false
|
114
|
+
version_requirements: *20892192
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: rack
|
117
|
+
requirement: &20891472 !ruby/object:Gem::Requirement
|
118
|
+
none: false
|
119
|
+
requirements:
|
120
|
+
- - =
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 1.2.2
|
123
|
+
type: :development
|
124
|
+
prerelease: false
|
125
|
+
version_requirements: *20891472
|
126
|
+
description: A tool designed to speedup library loading (startup time) in Ruby by
|
127
|
+
caching library locations
|
138
128
|
email: rogerdpack@gmail.com
|
139
|
-
executables:
|
129
|
+
executables:
|
140
130
|
- faster_require
|
141
131
|
extensions: []
|
142
|
-
|
143
|
-
extra_rdoc_files:
|
132
|
+
extra_rdoc_files:
|
144
133
|
- ChangeLog
|
145
134
|
- README
|
146
135
|
- TODO
|
147
|
-
files:
|
136
|
+
files:
|
148
137
|
- ChangeLog
|
149
138
|
- README
|
150
139
|
- Rakefile
|
@@ -165,12 +154,14 @@ files:
|
|
165
154
|
- spec/files/e.rb
|
166
155
|
- spec/files/fast.rb
|
167
156
|
- spec/files/fast2.rb
|
157
|
+
- spec/files/file_that_sets_ignore_pwd_flag.rb
|
168
158
|
- spec/files/gem_after.rb
|
169
159
|
- spec/files/gem_before.rb
|
170
160
|
- spec/files/large.rb
|
171
161
|
- spec/files/load_various_gems.rb
|
172
162
|
- spec/files/load_various_gems2.rb
|
173
163
|
- spec/files/non_dot_rb.rb
|
164
|
+
- spec/files/regin_gem.rb
|
174
165
|
- spec/files/require_facets.rb
|
175
166
|
- spec/files/require_full_path.rb
|
176
167
|
- spec/files/require_non_dot_rb_fails.rb
|
@@ -186,38 +177,29 @@ files:
|
|
186
177
|
has_rdoc: true
|
187
178
|
homepage: http://github.com/rdp/faster_require
|
188
179
|
licenses: []
|
189
|
-
|
190
180
|
post_install_message:
|
191
181
|
rdoc_options: []
|
192
|
-
|
193
|
-
require_paths:
|
182
|
+
require_paths:
|
194
183
|
- lib
|
195
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
184
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
196
185
|
none: false
|
197
|
-
requirements:
|
198
|
-
- -
|
199
|
-
- !ruby/object:Gem::Version
|
200
|
-
|
201
|
-
|
202
|
-
- 0
|
203
|
-
version: "0"
|
204
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
186
|
+
requirements:
|
187
|
+
- - ! '>='
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '0'
|
190
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
205
191
|
none: false
|
206
|
-
requirements:
|
207
|
-
- -
|
208
|
-
- !ruby/object:Gem::Version
|
209
|
-
|
210
|
-
segments:
|
211
|
-
- 0
|
212
|
-
version: "0"
|
192
|
+
requirements:
|
193
|
+
- - ! '>='
|
194
|
+
- !ruby/object:Gem::Version
|
195
|
+
version: '0'
|
213
196
|
requirements: []
|
214
|
-
|
215
197
|
rubyforge_project:
|
216
198
|
rubygems_version: 1.5.2
|
217
199
|
signing_key:
|
218
200
|
specification_version: 3
|
219
201
|
summary: Speed library loading in Ruby
|
220
|
-
test_files:
|
202
|
+
test_files:
|
221
203
|
- spec/files/a_requires_b.rb
|
222
204
|
- spec/files/active_support_no_double_load.rb
|
223
205
|
- spec/files/attempt_double_load.rb
|
@@ -228,12 +210,14 @@ test_files:
|
|
228
210
|
- spec/files/e.rb
|
229
211
|
- spec/files/fast.rb
|
230
212
|
- spec/files/fast2.rb
|
213
|
+
- spec/files/file_that_sets_ignore_pwd_flag.rb
|
231
214
|
- spec/files/gem_after.rb
|
232
215
|
- spec/files/gem_before.rb
|
233
216
|
- spec/files/large.rb
|
234
217
|
- spec/files/load_various_gems.rb
|
235
218
|
- spec/files/load_various_gems2.rb
|
236
219
|
- spec/files/non_dot_rb.rb
|
220
|
+
- spec/files/regin_gem.rb
|
237
221
|
- spec/files/require_facets.rb
|
238
222
|
- spec/files/require_full_path.rb
|
239
223
|
- spec/files/require_non_dot_rb_fails.rb
|