Sha256: 4eb8f522d54568ea376a8c0c2ac1644ea0bacc5905caf920545bd67f38334990
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 KB
Contents
require 'rgl/adjacency' require 'rgl/topsort' require "dependence/dependency_list" module Dependence class DependencyResolver def initialize(file_list, file_path, file_type) @files = file_list @file_type = file_type @file_path = file_path @graph = RGL::DirectedAdjacencyGraph.new end 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 private def get_dependencies_in(file) dependency_list = DependencyList.new(@file_path, @file_type) File.foreach(file) { |s| add_dependency_if_imported(dependency_list, s) } dependency_list.get() end def add_dependency_if_imported(dep_list, file_content) return unless file_content.include?("@import") path = file_content.match(/@import (.*)/)[1].strip dep_list.add_dependency File.join(@file_path, path) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dependence-0.0.92 | lib/dependence/dependency_resolver.rb |