From a9152515c6989b344b402aeb73e211f0eeb0148f Mon Sep 17 00:00:00 2001 From: Adam Sanderson Date: Sun, 15 Aug 2010 21:02:43 -0700 Subject: [PATCH] Smarter repository loading for ruby standard library and gems. --- repositories.rb | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/repositories.rb b/repositories.rb index 5a98983..73fca32 100644 --- a/repositories.rb +++ b/repositories.rb @@ -9,7 +9,20 @@ def add(label, path, repository_type=Qwandry::FlatRepository) @repositories[label] << repository_type.new(label, path) end -if which('ruby') == '/Users/adam/.rvm/rubies/ruby-1.9.1-p378/bin/ruby' - add :gem, '/Users/adam/.rvm/gems/ruby-1.9.1-p378/gems/' - add :ruby, '/Users/adam/.rvm/rubies/ruby-1.9.1-p378/lib/ruby/1.9.1/' +#if which('ruby') == '/Users/adam/.rvm/rubies/ruby-1.9.1-p378/bin/ruby' +# add :gem, '/Users/adam/.rvm/gems/ruby-1.9.1-p378/gems/' +# add :ruby, '/Users/adam/.rvm/rubies/ruby-1.9.1-p378/lib/ruby/1.9.1/' +#end + +# Add gem repositories: +# Using the ruby load paths, determine the common gem root paths, and add those. +# This assumes gem paths look like: +($:).grep(/gems/).map{|p| p[/.+\/gems\//]}.uniq.each do |path| + add :gem, path +end + +# Add ruby standard libraries, ignore the platform specific ones since they +# tend to contain only binaries +($:).grep(/lib\/ruby/).reject{|path| path =~ /#{RUBY_PLATFORM}$/}.each do |path| + add :ruby, path end \ No newline at end of file