Class: Depdump::Tracer

Inherits:
Object
  • Object
show all
Defined in:
lib/depdump/tracer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTracer

Returns a new instance of Tracer.



5
6
7
8
# File 'lib/depdump/tracer.rb', line 5

def initialize
  @registry_tree = Registry::Tree.new
  @context = @registry_tree.root
end

Instance Attribute Details

#classesObject (readonly)

Returns the value of attribute classes.



3
4
5
# File 'lib/depdump/tracer.rb', line 3

def classes
  @classes
end

#registry_treeObject (readonly)

Returns the value of attribute registry_tree.



3
4
5
# File 'lib/depdump/tracer.rb', line 3

def registry_tree
  @registry_tree
end

#relationsObject (readonly)

Returns the value of attribute relations.



3
4
5
# File 'lib/depdump/tracer.rb', line 3

def relations
  @relations
end

Instance Method Details

#trace_node(node, namespaces = []) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/depdump/tracer.rb', line 10

def trace_node(node, namespaces = [])
  return unless node.respond_to?(:type)

  case node.type
  when :class, :module
    trace_class(node, namespaces)
  when :const
    trace_const(node, namespaces)
  else
    node.children.map { |n| trace_node(n, namespaces) }
  end
end