rails-boot-reporting 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/bundler-1.2/runtime.rb +270 -0
- data/lib/rails-boot-reporting.rb +3 -2
- data/rails-boot-reporting.gemspec +4 -3
- metadata +33 -12
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
@@ -0,0 +1,270 @@
|
|
1
|
+
require "digest/sha1"
|
2
|
+
require "benchmark"
|
3
|
+
|
4
|
+
module Bundler
|
5
|
+
class Runtime < Environment
|
6
|
+
include SharedHelpers
|
7
|
+
|
8
|
+
def setup(*groups)
|
9
|
+
# Has to happen first
|
10
|
+
clean_load_path
|
11
|
+
|
12
|
+
specs = groups.any? ? @definition.specs_for(groups) : requested_specs
|
13
|
+
|
14
|
+
setup_environment
|
15
|
+
Bundler.rubygems.replace_entrypoints(specs)
|
16
|
+
|
17
|
+
# Activate the specs
|
18
|
+
specs.each do |spec|
|
19
|
+
unless spec.loaded_from
|
20
|
+
raise GemNotFound, "#{spec.full_name} is missing. Run `bundle` to get it."
|
21
|
+
end
|
22
|
+
|
23
|
+
if activated_spec = Bundler.rubygems.loaded_specs(spec.name) and activated_spec.version != spec.version
|
24
|
+
e = Gem::LoadError.new "You have already activated #{activated_spec.name} #{activated_spec.version}, " \
|
25
|
+
"but your Gemfile requires #{spec.name} #{spec.version}. Using bundle exec may solve this."
|
26
|
+
e.name = spec.name
|
27
|
+
if e.respond_to?(:requirement=)
|
28
|
+
e.requirement = Gem::Requirement.new(spec.version.to_s)
|
29
|
+
else
|
30
|
+
e.version_requirement = Gem::Requirement.new(spec.version.to_s)
|
31
|
+
end
|
32
|
+
raise e
|
33
|
+
end
|
34
|
+
|
35
|
+
Bundler.rubygems.mark_loaded(spec)
|
36
|
+
load_paths = spec.load_paths.reject {|path| $LOAD_PATH.include?(path)}
|
37
|
+
$LOAD_PATH.unshift(*load_paths)
|
38
|
+
end
|
39
|
+
|
40
|
+
lock
|
41
|
+
|
42
|
+
self
|
43
|
+
end
|
44
|
+
|
45
|
+
REGEXPS = [
|
46
|
+
/^no such file to load -- (.+)$/i,
|
47
|
+
/^Missing \w+ (?:file\s*)?([^\s]+.rb)$/i,
|
48
|
+
/^Missing API definition file in (.+)$/i,
|
49
|
+
/^cannot load such file -- (.+)$/i,
|
50
|
+
]
|
51
|
+
|
52
|
+
def require(*groups)
|
53
|
+
groups.map! { |g| g.to_sym }
|
54
|
+
groups = [:default] if groups.empty?
|
55
|
+
|
56
|
+
@definition.dependencies.each do |dep|
|
57
|
+
# Skip the dependency if it is not in any of the requested
|
58
|
+
# groups
|
59
|
+
next unless ((dep.groups & groups).any? && dep.current_platform?)
|
60
|
+
|
61
|
+
required_file = nil
|
62
|
+
|
63
|
+
begin
|
64
|
+
# Loop through all the specified autorequires for the
|
65
|
+
# dependency. If there are none, use the dependency's name
|
66
|
+
# as the autorequire.
|
67
|
+
Array(dep.autorequire || dep.name).each do |file|
|
68
|
+
required_file = file
|
69
|
+
total = Benchmark.realtime {
|
70
|
+
Kernel.require file
|
71
|
+
}
|
72
|
+
puts "Bundler.require #{file}\t#{total}"
|
73
|
+
end
|
74
|
+
rescue LoadError => e
|
75
|
+
if dep.autorequire.nil? && dep.name.include?('-')
|
76
|
+
begin
|
77
|
+
namespaced_file = dep.name.gsub('-', '/')
|
78
|
+
total = Benchmark.realtime {
|
79
|
+
Kernel.require namespaced_file
|
80
|
+
}
|
81
|
+
puts "Bundler.require #{namespaced_file}\t#{total}"
|
82
|
+
rescue LoadError
|
83
|
+
REGEXPS.find { |r| r =~ e.message }
|
84
|
+
regex_name = $1
|
85
|
+
raise if dep.autorequire || (regex_name && regex_name.gsub('-', '/') != namespaced_file)
|
86
|
+
raise e if regex_name.nil?
|
87
|
+
end
|
88
|
+
else
|
89
|
+
REGEXPS.find { |r| r =~ e.message }
|
90
|
+
raise if dep.autorequire || $1 != required_file
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def dependencies_for(*groups)
|
97
|
+
if groups.empty?
|
98
|
+
dependencies
|
99
|
+
else
|
100
|
+
dependencies.select { |d| (groups & d.groups).any? }
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
alias gems specs
|
105
|
+
|
106
|
+
def cache
|
107
|
+
FileUtils.mkdir_p(cache_path) unless File.exists?(cache_path)
|
108
|
+
|
109
|
+
Bundler.ui.info "Updating files in vendor/cache"
|
110
|
+
specs.each do |spec|
|
111
|
+
next if spec.name == 'bundler'
|
112
|
+
spec.source.cache(spec) if spec.source.respond_to?(:cache)
|
113
|
+
end
|
114
|
+
prune_cache unless Bundler.settings[:no_prune]
|
115
|
+
end
|
116
|
+
|
117
|
+
def prune_cache
|
118
|
+
FileUtils.mkdir_p(cache_path) unless File.exists?(cache_path)
|
119
|
+
resolve = @definition.resolve
|
120
|
+
prune_gem_cache(resolve)
|
121
|
+
prune_git_and_path_cache(resolve)
|
122
|
+
end
|
123
|
+
|
124
|
+
def clean
|
125
|
+
gem_bins = Dir["#{Gem.dir}/bin/*"]
|
126
|
+
git_dirs = Dir["#{Gem.dir}/bundler/gems/*"]
|
127
|
+
git_cache_dirs = Dir["#{Gem.dir}/cache/bundler/git/*"]
|
128
|
+
gem_dirs = Dir["#{Gem.dir}/gems/*"]
|
129
|
+
gem_files = Dir["#{Gem.dir}/cache/*.gem"]
|
130
|
+
gemspec_files = Dir["#{Gem.dir}/specifications/*.gemspec"]
|
131
|
+
spec_gem_paths = []
|
132
|
+
# need to keep git sources around
|
133
|
+
spec_git_paths = @definition.sources.select {|s| s.is_a?(Bundler::Source::Git) }.map {|s| s.path.to_s }
|
134
|
+
spec_git_cache_dirs = []
|
135
|
+
spec_gem_executables = []
|
136
|
+
spec_cache_paths = []
|
137
|
+
spec_gemspec_paths = []
|
138
|
+
specs.each do |spec|
|
139
|
+
spec_gem_paths << spec.full_gem_path
|
140
|
+
# need to check here in case gems are nested like for the rails git repo
|
141
|
+
md = %r{(.+bundler/gems/.+-[a-f0-9]{7,12})}.match(spec.full_gem_path)
|
142
|
+
spec_git_paths << md[1] if md
|
143
|
+
spec_gem_executables << spec.executables.collect do |executable|
|
144
|
+
"#{Bundler.rubygems.gem_bindir}/#{executable}"
|
145
|
+
end
|
146
|
+
spec_cache_paths << spec.cache_file
|
147
|
+
spec_gemspec_paths << spec.spec_file
|
148
|
+
spec_git_cache_dirs << spec.source.cache_path.to_s if spec.source.is_a?(Bundler::Source::Git)
|
149
|
+
end
|
150
|
+
spec_gem_paths.uniq!
|
151
|
+
spec_gem_executables.flatten!
|
152
|
+
|
153
|
+
stale_gem_bins = gem_bins - spec_gem_executables
|
154
|
+
stale_git_dirs = git_dirs - spec_git_paths
|
155
|
+
stale_git_cache_dirs = git_cache_dirs - spec_git_cache_dirs
|
156
|
+
stale_gem_dirs = gem_dirs - spec_gem_paths
|
157
|
+
stale_gem_files = gem_files - spec_cache_paths
|
158
|
+
stale_gemspec_files = gemspec_files - spec_gemspec_paths
|
159
|
+
|
160
|
+
stale_gem_bins.each {|bin| FileUtils.rm(bin) }
|
161
|
+
output = stale_gem_dirs.collect do |gem_dir|
|
162
|
+
full_name = Pathname.new(gem_dir).basename.to_s
|
163
|
+
|
164
|
+
FileUtils.rm_rf(gem_dir)
|
165
|
+
|
166
|
+
parts = full_name.split('-')
|
167
|
+
name = parts[0..-2].join('-')
|
168
|
+
version = parts.last
|
169
|
+
output = "#{name} (#{version})"
|
170
|
+
|
171
|
+
Bundler.ui.info "Removing #{output}"
|
172
|
+
|
173
|
+
output
|
174
|
+
end + stale_git_dirs.collect do |gem_dir|
|
175
|
+
full_name = Pathname.new(gem_dir).basename.to_s
|
176
|
+
|
177
|
+
FileUtils.rm_rf(gem_dir)
|
178
|
+
|
179
|
+
parts = full_name.split('-')
|
180
|
+
name = parts[0..-2].join('-')
|
181
|
+
revision = parts[-1]
|
182
|
+
output = "#{name} (#{revision})"
|
183
|
+
|
184
|
+
Bundler.ui.info "Removing #{output}"
|
185
|
+
|
186
|
+
output
|
187
|
+
end
|
188
|
+
|
189
|
+
stale_gem_files.each {|file| FileUtils.rm(file) if File.exists?(file) }
|
190
|
+
stale_gemspec_files.each {|file| FileUtils.rm(file) if File.exists?(file) }
|
191
|
+
stale_git_cache_dirs.each {|dir| FileUtils.rm_rf(dir) if File.exists?(dir) }
|
192
|
+
|
193
|
+
output
|
194
|
+
end
|
195
|
+
|
196
|
+
def setup_environment
|
197
|
+
begin
|
198
|
+
ENV["BUNDLE_BIN_PATH"] = Bundler.rubygems.bin_path("bundler", "bundle", VERSION)
|
199
|
+
rescue Gem::GemNotFoundException
|
200
|
+
ENV["BUNDLE_BIN_PATH"] = File.expand_path("../../../bin/bundle", __FILE__)
|
201
|
+
end
|
202
|
+
|
203
|
+
# Set PATH
|
204
|
+
paths = (ENV["PATH"] || "").split(File::PATH_SEPARATOR)
|
205
|
+
paths.unshift "#{Bundler.bundle_path}/bin"
|
206
|
+
ENV["PATH"] = paths.uniq.join(File::PATH_SEPARATOR)
|
207
|
+
|
208
|
+
# Set BUNDLE_GEMFILE
|
209
|
+
ENV["BUNDLE_GEMFILE"] = default_gemfile.to_s
|
210
|
+
|
211
|
+
# Set RUBYOPT
|
212
|
+
rubyopt = [ENV["RUBYOPT"]].compact
|
213
|
+
if rubyopt.empty? || rubyopt.first !~ /-rbundler\/setup/
|
214
|
+
rubyopt.unshift "-rbundler/setup"
|
215
|
+
rubyopt.unshift "-I#{File.expand_path('../..', __FILE__)}"
|
216
|
+
ENV["RUBYOPT"] = rubyopt.join(' ')
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
private
|
221
|
+
|
222
|
+
def prune_gem_cache(resolve)
|
223
|
+
cached = Dir["#{cache_path}/*.gem"]
|
224
|
+
|
225
|
+
cached = cached.delete_if do |path|
|
226
|
+
spec = Bundler.rubygems.spec_from_gem path
|
227
|
+
|
228
|
+
resolve.any? do |s|
|
229
|
+
s.name == spec.name && s.version == spec.version && !s.source.is_a?(Bundler::Source::Git)
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
if cached.any?
|
234
|
+
Bundler.ui.info "Removing outdated .gem files from vendor/cache"
|
235
|
+
|
236
|
+
cached.each do |path|
|
237
|
+
Bundler.ui.info " * #{File.basename(path)}"
|
238
|
+
File.delete(path)
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
def prune_git_and_path_cache(resolve)
|
244
|
+
cached = Dir["#{cache_path}/*/.bundlecache"]
|
245
|
+
|
246
|
+
cached = cached.delete_if do |path|
|
247
|
+
name = File.basename(File.dirname(path))
|
248
|
+
|
249
|
+
resolve.any? do |s|
|
250
|
+
source = s.source
|
251
|
+
source.respond_to?(:app_cache_dirname) && source.app_cache_dirname == name
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
if cached.any?
|
256
|
+
Bundler.ui.info "Removing outdated .git/path repos from vendor/cache"
|
257
|
+
|
258
|
+
cached.each do |path|
|
259
|
+
path = File.dirname(path)
|
260
|
+
Bundler.ui.info " * #{File.basename(path)}"
|
261
|
+
FileUtils.rm_rf(path)
|
262
|
+
end
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
def cache_path
|
267
|
+
root.join("vendor/cache")
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|
data/lib/rails-boot-reporting.rb
CHANGED
@@ -17,11 +17,12 @@ module RailsBootReporting
|
|
17
17
|
def install_bundler
|
18
18
|
puts "-- Installing Bundler patches"
|
19
19
|
bundler_version = Bundler::VERSION
|
20
|
-
|
20
|
+
short_version = bundler_version.split('.', 3)[0..1].join('.')
|
21
|
+
install_file("bundler-#{short_version}/runtime.rb", gem_path('bundler', bundler_version, 'bundler/runtime.rb'))
|
21
22
|
end
|
22
23
|
|
23
24
|
def gem_path(gem, version, file)
|
24
|
-
install_path = File.join(ENV['GEM_HOME'], 'gems', "#{gem}-#{version}", 'lib', file)
|
25
|
+
install_path = File.join(ENV['BUNDLE_DIR'] || ENV['GEM_HOME'], 'gems', "#{gem}-#{version}", 'lib', file)
|
25
26
|
end
|
26
27
|
|
27
28
|
def install_file(local_path, install_path)
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "rails-boot-reporting"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Aaron Quint"]
|
12
|
-
s.date = "
|
12
|
+
s.date = "2012-10-22"
|
13
13
|
s.description = "Patches, specifically for rails 2 (now) that print out require and boot times for different parts of the initialization process"
|
14
14
|
s.email = "aaron@quirkey.com"
|
15
15
|
s.executables = ["install-boot-reporting"]
|
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
"VERSION",
|
28
28
|
"bin/install-boot-reporting",
|
29
29
|
"lib/bundler-1.0/runtime.rb",
|
30
|
+
"lib/bundler-1.2/runtime.rb",
|
30
31
|
"lib/rails-2.3.14/initializer.rb",
|
31
32
|
"lib/rails-boot-reporting.rb",
|
32
33
|
"rails-boot-reporting.gemspec",
|
@@ -36,7 +37,7 @@ Gem::Specification.new do |s|
|
|
36
37
|
s.homepage = "http://github.com/quirkey/rails-boot-reporting"
|
37
38
|
s.licenses = ["MIT"]
|
38
39
|
s.require_paths = ["lib"]
|
39
|
-
s.rubygems_version = "1.8.
|
40
|
+
s.rubygems_version = "1.8.23"
|
40
41
|
s.summary = "A set of monkey patches for rails and bundler to print require/boot times"
|
41
42
|
|
42
43
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-boot-reporting
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-10-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: shoulda
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: bundler
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ~>
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: 1.0.0
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.0.0
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: jeweler
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ~>
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: 1.6.3
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.6.3
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: rcov
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ! '>='
|
@@ -54,7 +69,12 @@ dependencies:
|
|
54
69
|
version: '0'
|
55
70
|
type: :development
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
58
78
|
description: Patches, specifically for rails 2 (now) that print out require and boot
|
59
79
|
times for different parts of the initialization process
|
60
80
|
email: aaron@quirkey.com
|
@@ -74,6 +94,7 @@ files:
|
|
74
94
|
- VERSION
|
75
95
|
- bin/install-boot-reporting
|
76
96
|
- lib/bundler-1.0/runtime.rb
|
97
|
+
- lib/bundler-1.2/runtime.rb
|
77
98
|
- lib/rails-2.3.14/initializer.rb
|
78
99
|
- lib/rails-boot-reporting.rb
|
79
100
|
- rails-boot-reporting.gemspec
|
@@ -94,7 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
94
115
|
version: '0'
|
95
116
|
segments:
|
96
117
|
- 0
|
97
|
-
hash:
|
118
|
+
hash: 1522760917668265469
|
98
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
120
|
none: false
|
100
121
|
requirements:
|
@@ -103,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
124
|
version: '0'
|
104
125
|
requirements: []
|
105
126
|
rubyforge_project:
|
106
|
-
rubygems_version: 1.8.
|
127
|
+
rubygems_version: 1.8.23
|
107
128
|
signing_key:
|
108
129
|
specification_version: 3
|
109
130
|
summary: A set of monkey patches for rails and bundler to print require/boot times
|