Class: Xumlidot::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/xumlidot/loader.rb

Overview

This is code that was living in bin/xumlidot. We need to leverage it for running integration tests though

Instance Method Summary collapse

Constructor Details

#initialize(directories, options) ⇒ Loader

Returns a new instance of Loader.



7
8
9
10
# File 'lib/xumlidot/loader.rb', line 7

def initialize(directories, options)
  @directories = directories
  @options = options
end

Instance Method Details

#loadObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/xumlidot/loader.rb', line 12

def load
  dt = Xumlidot::DirectoryTree.new(directories, options)

  # This is our tree of klasses/modules etc
  # since we can't assume rails conventions for naming
  # in a Ruby program.
  constants = ::Xumlidot::Parsers::Stack::Constants.new

  # TODO: move into directory tree
  dt.find_all_rb_files do |path|
    warn path if ::Xumlidot::Options.debug == true
    file_contents = File.read(path)

    @parser = Xumlidot::Parsers::File.new(file_contents, constants)
    @parser.parse
  end

  # If a class is inherited from but does not exist in the constants
  # we will create a dummy class.
  #
  # if a class is inherited from, we want to find it using the constant lookup
  # rules defining in the resolver
  #
  # and what ... we want to add a reference too it?
  #
  # This REALLY should be done whenever we add a superklass
  # i.e. yeah, its a hack
  constants.resolve_inheritance

  diagram = ::Xumlidot::Diagram.new(constants, options)
  diagram.draw
end