18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/gemstash/db/dependency.rb', line 18
def self.fetch(gems)
results = db["
SELECT rubygem.name,
version.number, version.platform,
dependency.rubygem_name, dependency.requirements
FROM rubygems rubygem
JOIN versions version
ON version.rubygem_id = rubygem.id
LEFT JOIN dependencies dependency
ON dependency.version_id = version.id
WHERE rubygem.name IN ?
AND version.indexed = ?", gems.to_a, true].to_a
results.group_by {|r| r[:name] }.each do |gem, rows|
requirements = rows.group_by {|r| [r[:number], r[:platform]] }
value = requirements.map do |version, r|
deps = r.map {|x| [x[:rubygem_name], x[:requirements]] }
deps = [] if deps.size == 1 && deps.first.first.nil?
{
:name => gem,
:number => version.first,
:platform => version.last,
:dependencies => deps
}
end
yield(gem, value)
end
end
|