How easy would it be to build include graphs in ruby? Here's my first attempt: PLAIN TEXT RUBY: $list_of_files = Hash.new $list_of_files.each {|node| node = Array.new } def store_includes(pathname) lines = IO.readlines(pathname) lines.each {|line| if line.include? "#include" include_file = line[line.index("#include")+"#include".size,line.size] fidx = 0 sidx = 0 if include_file.include?("\"") fidx = include_file.index("\"") + 1 sidx [...]
Is there a more efficient way to extract the file extensions in ruby? I currently do the following. PLAIN TEXT RUBY: ext = File.basename(filepath).reverse.split('.')[0].reverse