Created
January 20, 2010 00:06
-
-
Save baroquebobcat/281456 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ irb | |
irb(main):001:0> require 'rubygems' | |
=> true | |
irb(main):002:0> require 'benchmark' | |
=> true | |
irb(main):003:0> Benchmark.bmbm do |x| | |
irb(main):004:1* x.report('Gem.clear_paths') { Gem.clear_paths } | |
irb(main):005:1> x.report("Gem.find_files('rubygems_plugin')") do | |
irb(main):006:2* Gem.clear_paths | |
irb(main):007:2> Gem.find_files 'rubygems_plugin' | |
irb(main):008:2> end | |
irb(main):009:1> x.report("Gem.latest_load_paths.map{...}") do | |
irb(main):010:2* Gem.clear_paths | |
irb(main):011:2> Gem.latest_load_paths.map do |path| | |
irb(main):012:3* path = path+'/rubygems_plugin.rb' | |
irb(main):013:3> path if File.exists? path | |
irb(main):014:3> end.compact | |
irb(main):015:2> | |
irb(main):016:2* end | |
irb(main):017:1> end | |
Rehearsal --------------------------------------------------------------------- | |
Gem.clear_paths 0.000000 0.000000 0.000000 ( 0.000012) | |
Gem.find_files('rubygems_plugin') 0.070000 0.000000 0.070000 ( 0.088658) | |
Gem.latest_load_paths.map{...} 0.070000 0.010000 0.080000 ( 0.079032) | |
------------------------------------------------------------ total: 0.150000sec | |
user system total real | |
Gem.clear_paths 0.000000 0.000000 0.000000 ( 0.000015) | |
Gem.find_files('rubygems_plugin') 0.060000 0.010000 0.070000 ( 0.067844) | |
Gem.latest_load_paths.map{...} 0.070000 0.000000 0.070000 ( 0.067646) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ svn checkout http://rubygems.rubyforge.org/svn | |
... | |
$ cd svn/trunk/lib/ | |
... | |
$ rgrep rubygems_plugin --exclude-dir=\.svn . | |
... | |
./rubygems.rb:plugins = Gem.find_files 'rubygems_plugin' | |
$ rgrep 'self.find_files(' --exclude-dir=\.svn -B 3 . | |
... | |
./rubygems.rb- # Note that find_files will return all files even if they are from different | |
./rubygems.rb- # versions of the same gem. | |
./rubygems.rb- | |
./rubygems.rb: def self.find_files(path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo gem rdoc sinatra --backtrace | |
ERROR: While executing gem ... (SystemStackError) | |
stack level too deep | |
/usr/lib/ruby/gems/1.8/gems/yard-0.5.2/lib/rubygems_plugin.rb:19:in `has_rdoc?' | |
/usr/lib/ruby/gems/1.8/gems/yard-0.4.0/lib/rubygems_plugin.rb:77:in `install_ri_yard_orig' | |
/usr/lib/ruby/gems/1.8/gems/yard-0.4.0/lib/rubygems_plugin.rb:77:in `install_ri_yard_orig' | |
/usr/lib/ruby/gems/1.8/gems/yard-0.5.2/lib/rubygems_plugin.rb:79:in `install_ri' | |
/usr/local/lib/site_ruby/1.8/rubygems/doc_manager.rb:109:in `generate_ri' | |
/usr/local/lib/site_ruby/1.8/rubygems/commands/rdoc_command.rb:61:in `execute' | |
/usr/local/lib/site_ruby/1.8/rubygems/commands/rdoc_command.rb:60:in `each' | |
/usr/local/lib/site_ruby/1.8/rubygems/commands/rdoc_command.rb:60:in `execute' | |
/usr/local/lib/site_ruby/1.8/rubygems/command.rb:257:in `invoke' | |
/usr/local/lib/site_ruby/1.8/rubygems/command_manager.rb:132:in `process_args' | |
/usr/local/lib/site_ruby/1.8/rubygems/command_manager.rb:102:in `run' | |
/usr/local/lib/site_ruby/1.8/rubygems/gem_runner.rb:58:in `run' | |
/usr/bin/gem:21 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plugins = Gem.latest_load_paths.map do |path| | |
path = path+'/rubygems_plugin.rb' | |
path if File.exists? path | |
end.compact | |
plugins.each do |plugin| | |
begin | |
load plugin | |
rescue => e | |
warn "error loading #{plugin.inspect}: #{e.message} (#{e.class})" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plugins = Gem.find_files 'rubygems_plugin' | |
plugins.each do |plugin| | |
begin | |
load plugin | |
rescue => e | |
warn "error loading #{plugin.inspect}: #{e.message} (#{e.class})" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment