lib/rubygems_analyzer.rb in graph-1.2.0 vs lib/rubygems_analyzer.rb in graph-2.0.0
- old
+ new
@@ -1,12 +1,17 @@
require 'dep_analyzer'
+$a ||= false
+
class RubygemsAnalyzer < DepAnalyzer
- def installed
- require 'rubygems'
+ def setup
+ require "rubygems"
ENV['GEM_PATH'] = `gem env home`
Gem.clear_paths
+ end
+
+ def installed
# don't cache so it updates every delete
puts "scanning installed rubygems"
Gem.source_index.gems.values.map { |gem| gem.name }.sort
end
@@ -14,9 +19,25 @@
# don't cache so it updates every delete
puts "scanning outdated rubygems"
Gem.source_index.outdated.sort
end
- def deps port
- Gem.source_index.find_name(port).first.dependencies.map { |dep| dep.name }
+ def deps gem
+ Gem.source_index.find_name(gem).first.dependencies.map { |dep| dep.name }
+ end
+
+ def decorate
+ developer_dependency = g.gray
+
+ installed = self.installed
+
+ installed.each do |gem|
+ deps = Gem.source_index.find_name(gem).first.dependencies
+
+ deps.each do |dep|
+ next if dep.type == :runtime
+ name = dep.name
+ developer_dependency << g[gem][name] if $a or installed.include? name
+ end
+ end
end
end