Class: DependencyResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/dependence/dependency_resolver.rb

Instance Method Summary collapse

Constructor Details

#initialize(file_list, file_path) ⇒ DependencyResolver

Returns a new instance of DependencyResolver.



5
6
7
8
9
# File 'lib/dependence/dependency_resolver.rb', line 5

def initialize(file_list, file_path)
  @files = file_list
  @file_path = file_path
  @graph = RGL::DirectedAdjacencyGraph.new
end

Instance Method Details

#sorted_filesObject



11
12
13
14
15
16
17
18
# File 'lib/dependence/dependency_resolver.rb', line 11

def sorted_files
  @files.each do |file|
    @graph.add_vertex(file)
    dependencies = get_dependencies_in(file)
    dependencies.each {|dependency| @graph.add_edge(dependency,file) }
  end
  @graph.topsort_iterator.to_a
end