class Bundler::Dependencies::Graph
Attributes
lockfile[R]
specs[R]
Public Class Methods
new(lockfile: nil, specs: [])
click to toggle source
# File lib/bundler/dependencies/graph.rb, line 6 def initialize(lockfile: nil, specs: []) @lockfile = lockfile if lockfile load_lockfile else @specs = specs.compact end end
Public Instance Methods
counts(min: 0)
click to toggle source
# File lib/bundler/dependencies/graph.rb, line 33 def counts(min: 0) @counts ||= map do |gem| count = gem.dependency_count next if count < min [gem.name, gem.dependency_count] end.compact.sort_by(&:last).reverse.to_h end
delete(*specs)
click to toggle source
# File lib/bundler/dependencies/graph.rb, line 42 def delete(*specs) specs.each do |gem| spec = Spec.new(gem) unless gem.is_a?(Spec) gems.delete(spec) end end
each(&block)
click to toggle source
# File lib/bundler/dependencies/graph.rb, line 25 def each(&block) gems.each(&block) end
empty?()
click to toggle source
# File lib/bundler/dependencies/graph.rb, line 21 def empty? gems.empty? end
find(gem)
click to toggle source
# File lib/bundler/dependencies/graph.rb, line 29 def find(gem) include_dependency?(gem) ? Spec.find(gem) : nil end
include?(gem)
click to toggle source
# File lib/bundler/dependencies/graph.rb, line 49 def include?(gem) gem = Spec.new(gem) unless gem.is_a?(Spec) gems.include?(gem) end
include_dependency?(gem)
click to toggle source
# File lib/bundler/dependencies/graph.rb, line 54 def include_dependency?(gem) gem = Spec.new(gem) unless gem.is_a?(Spec) include?(gem) || any? { |spec| spec.include_dependency?(gem) } end
initialize_copy(source)
click to toggle source
Calls superclass method
# File lib/bundler/dependencies/graph.rb, line 16 def initialize_copy(source) super @gems = source.send(:gems).dup end
walk(&block)
click to toggle source
# File lib/bundler/dependencies/graph.rb, line 65 def walk(&block) Visitor.walk(self, &block) self end
without(*gems)
click to toggle source
# File lib/bundler/dependencies/graph.rb, line 59 def without(*gems) graph = dup graph.delete(*gems) graph.walk { |gem| gem.dependencies.delete(*gems) } end
Private Instance Methods
gems()
click to toggle source
# File lib/bundler/dependencies/graph.rb, line 74 def gems @gems ||= if lockfile lockfile.dependencies.keys.map { |name| Spec.new(name) } else specs end end
load_lockfile()
click to toggle source
# File lib/bundler/dependencies/graph.rb, line 82 def load_lockfile @specs = lockfile.specs.each_with_object([]) do |spec, acc| acc << Spec.new(spec.name, spec.dependencies.map(&:name)) end end