Permalink
Browse files

make it lazy-loading, and reduce parallalization

  • Loading branch information...
1 parent 0a8cc8a commit 5020f06897887f2ad140a34e4bd25dc9f0a5b452 @grosser committed Nov 5, 2010
Showing with 28 additions and 7 deletions.
  1. +1 −1 Gemfile
  2. +2 −2 Gemfile.lock
  3. +13 −1 Rakefile
  4. +7 −1 lib/rubygems/commands/dependent_command.rb
  5. +5 −2 lib/rubygems/dependent.rb
View
@@ -3,4 +3,4 @@ source 'http://rubygems.org'
gem 'rake'
gem 'rspec', '~>2'
gem 'jeweler'
-gem 'parallel'
+gem 'parallel', '>= 0.5.1'
View
@@ -9,7 +9,7 @@ GEM
git (>= 1.2.5)
rubyforge (>= 2.0.0)
json_pure (1.4.6)
- parallel (0.5.0)
+ parallel (0.5.1)
rake (0.8.7)
rspec (2.0.1)
rspec-core (~> 2.0.1)
@@ -29,6 +29,6 @@ PLATFORMS
DEPENDENCIES
jeweler
- parallel
+ parallel (>= 0.5.1)
rake
rspec (~> 2)
View
@@ -12,7 +12,19 @@ begin
gem.email = "grosser.michael@gmail.com"
gem.homepage = "http://github.com/grosser/#{gem.name}"
gem.authors = ["Michael Grosser"]
- gem.add_dependency 'parallel', '>= 0.4'
+
+
+ # if parallel was a dependency, every requirement of rubygems would
+ # load parallel, which causes overhead and problems
+ gem.post_install_message = <<-POST_INSTALL_MESSAGE
+#{'*'*50}
+
+Since parallel cannot be a dependency, please install by hand:
+
+gem install parallel
+
+#{'*'*50}
+POST_INSTALL_MESSAGE
end
Jeweler::GemcutterTasks.new
@@ -1,5 +1,4 @@
require 'rubygems/command'
-require 'rubygems/dependent'
class Gem::Commands::DependentCommand < Gem::Command
def initialize
@@ -27,6 +26,10 @@ def usage
end
def execute
+ # only require when it is really needed, otherwise
+ # it would be required every time someone loads rubygems
+ require 'rubygems/dependent'
+
gem = get_all_gem_names.first
gems_and_dependencies = Gem::Dependent.find(gem, options)
gems_and_dependencies.each do |gem, dependencies|
@@ -35,6 +38,9 @@ def execute
end.join(', ')
puts "#{gem} #{requirements}"
end
+ rescue Object => e
+ $stderr.puts e
+ $stderr.puts e.backtrace
end
private
@@ -1,6 +1,9 @@
require 'parallel'
require 'rubygems/spec_fetcher'
+# older parallel versions can produce strange bugs
+puts "update parallel gem" if Parallel::VERSION < '0.5.1'
+
module Gem
class Dependent
VERSION = File.read( File.join(File.dirname(__FILE__),'..','..','VERSION') ).strip
@@ -30,7 +33,7 @@ def self.find(gem, options={})
private
def self.fetch_all_dependencies(specs_and_sources)
- Parallel.map(specs_and_sources, :in_processes => 20) do |spec, source|
+ Parallel.map(specs_and_sources, :in_processes => 15) do |spec, source|
yield if block_given?
name = spec.first
dependencies = fetch_dependencies(spec, source)
@@ -42,7 +45,7 @@ def self.fetch_dependencies(spec, source)
begin
fetcher = Gem::SpecFetcher.fetcher
fetcher.fetch_spec(spec, URI.parse(source)).dependencies
- rescue Gem::RemoteFetcher::FetchError, Zlib::DataError => e
+ rescue Object => e
$stderr.puts e
[]
end

0 comments on commit 5020f06

Please sign in to comment.