Class: KComp

Inherits:
Object
  • Object
show all
Defined in:
lib/kcomp.rb,
lib/errors.rb

Defined Under Namespace

Classes: CyclicDependencyError, MissingDependencyError, UndefinedVariableError

Instance Method Summary collapse

Constructor Details

#initialize(src, dest, opts = {}) ⇒ KComp

Returns a new instance of KComp.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/kcomp.rb', line 8

def initialize(src, dest, opts={})
  @options = opts
  @depdg = RGL::DirectedAdjacencyGraph.new
  @texts = {}
  @compiled = []
  @src = src = src =~ /\/$/ ? src : src + "/"
  if @src !~ /^[.\/]/
    @src = "./" + @src
  end
  @dest = dest = dest =~ /\/$/ ? dest : dest + "/"
  if @dest !~ /^[.\/]/
    @dest = "./" + @dest
  end
  build_vertices @src
  @vertices = @depdg.to_a
  build_edges @src
  check_for_cycles
  @tsort = @depdg.topsort_iterator
  @reversedg = @depdg.reverse
  @rtsort = @reversedg.topsort_iterator
end

Instance Method Details

#compile!Object



42
43
44
45
# File 'lib/kcomp.rb', line 42

def compile!
  compile_files(@dest)
  puts "Compilation complete"
end

#dependency_digraphObject



30
31
32
# File 'lib/kcomp.rb', line 30

def dependency_digraph
  @depdg
end

#filesObject



38
39
40
# File 'lib/kcomp.rb', line 38

def files
  @tsort.to_a
end

#reverse_dependency_digraphObject



34
35
36
# File 'lib/kcomp.rb', line 34

def reverse_dependency_digraph
  @reversedg
end