Class: DependenciesGraph

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-binary-cache/dependencies_graph/dependencies_graph.rb

Overview

Using RGL graph because GraphViz doesn’t store adjacent of a node/vertex but we need to traverse a substree from any node github.com/monora/rgl/blob/master/lib/rgl/adjacency.rb

Instance Method Summary collapse

Constructor Details

#initialize(lockfile) ⇒ DependenciesGraph

Returns a new instance of DependenciesGraph.



12
13
14
15
# File 'lib/cocoapods-binary-cache/dependencies_graph/dependencies_graph.rb', line 12

def initialize(lockfile)
  @lockfile = lockfile
  @invert_edge = true # A normal edge is an edge (one direction) from library A to library B which is a dependency of A.
end

Instance Method Details

#get_clients(libnames) ⇒ Object

Input : a list of library names. Output: a set of library names which are clients (directly and indirectly) of those input libraries.



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/cocoapods-binary-cache/dependencies_graph/dependencies_graph.rb', line 19

def get_clients(libnames)
  result = Set.new()
  libnames.each do |lib|
    if graph.has_vertex?(lib)
      result.merge(traverse_sub_tree(graph, lib))
    else
      puts "Warning: cannot find lib: #{lib}"
    end
  end
  result
end

#write_graphic_file(output_graphic_fmt, filename = 'graph', highlight_nodes = Set[]) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/cocoapods-binary-cache/dependencies_graph/dependencies_graph.rb', line 31

def write_graphic_file(output_graphic_fmt, filename='graph', highlight_nodes=Set[])
  if !output_graphic_fmt
    puts 'Error: Need graphic format.'
    return
  end
  graph.write_to_graphic_file(output_graphic_fmt, dotfile=filename, options={}, highlight_nodes)
end