Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix crash when gemspec is missing for a named gem #95

Merged
merged 2 commits into from

2 participants

@jfoy

Given a gem that appears in specs or prerelease_specs and has no local gemspec.rz, when I request that gem's dependencies via the API, geminabox will crash. This change suppresses gems without a local gemspec from the dependency report.

@cwninja cwninja merged commit f8860f5 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 25 additions and 15 deletions.
  1. +25 −15 lib/geminabox.rb
View
40 lib/geminabox.rb
@@ -54,21 +54,6 @@ def fixup_bundler_rubygems!
erb :atom, :layout => false
end
- # Return a list of versions of gem 'gem_name' with the dependencies of each version.
- def gem_dependencies(gem_name)
- dependency_cache.marshal_cache(gem_name) do
- load_gems.select {|gem| gem_name == gem.name }.map do |gem|
- spec = spec_for(gem.name, gem.number)
- {
- :name => gem.name,
- :number => gem.number.version,
- :platform => gem.platform,
- :dependencies => spec.dependencies.select {|dep| dep.type == :runtime}.map {|dep| [dep.name, dep.requirement.to_s] }
- }
- end
- end
- end
-
get '/api/v1/dependencies' do
query_gems = params[:gems].split(',')
deps = query_gems.inject([]){|memo, query_gem| memo + gem_dependencies(query_gem) }
@@ -253,5 +238,30 @@ def spec_for(gem_name, version)
spec_file = File.join(settings.data, "quick", "Marshal.#{Gem.marshal_version}", "#{gem_name}-#{version}.gemspec.rz")
Marshal.load(Gem.inflate(File.read(spec_file))) if File.exists? spec_file
end
+
+ # Return a list of versions of gem 'gem_name' with the dependencies of each version.
+ def gem_dependencies(gem_name)
+ dependency_cache.marshal_cache(gem_name) do
+ load_gems.
+ select { |gem| gem_name == gem.name }.
+ map { |gem| [gem, spec_for(gem.name, gem.number)] }.
+ reject { |(_, spec)| spec.nil? }.
+ map do |(gem, spec)|
+ {
+ :name => gem.name,
+ :number => gem.number.version,
+ :platform => gem.platform,
+ :dependencies => runtime_dependencies(spec)
+ }
+ end
+ end
+ end
+
+ def runtime_dependencies(spec)
+ spec.
+ dependencies.
+ select { |dep| dep.type == :runtime }.
+ map { |dep| [dep.name, dep.requirement.to_s] }
+ end
end
end
Something went wrong with that request. Please try again.