Method: CodeNode::SpecHelpers::DotFile#initialize

Defined in:
lib/code_node/spec_helpers/dot_file.rb

#initialize(name) ⇒ DotFile

Returns a new instance of DotFile.

Parameters:

  • name (String)

    name of the dotfile without the .dot extension. The file will be looked for in the lib subdirectory of the active fixture dir.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/code_node/spec_helpers/dot_file.rb', line 10

def initialize(name)
  @filename = generated_file "#{name}.dot"
  @nodes = {} # :node_type => []
  @edges = {} # :edge_type => []
  if File.exists? @filename
    @i = 0
    @lines = File.read(@filename).split "\n"
    read_until '/* Module nodes */'
    read_nodes :module
    read_until '/* Class nodes */'
    read_nodes :class
    read_until '/* A contains B */'
    read_edges :containment
    read_until '/* A inherits from B */'
    read_edges :inheritance
    read_until '/* A includes B */'
    read_edges :inclusion
    read_until '/* A extends B */'
    read_edges :extension
  end
end