Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.61 KB | None | 0 0
  1. root    = 'C:/rb_incom-realty.ru/'
  2. @template_tree = {}
  3.  
  4. def parse_directory(path)
  5.   Dir.foreach path do |d|
  6.     if File.file?(f = path + d)
  7.       if d =~ /.\.asp$/
  8.         @template_tree[f] ||= []
  9.         file = File.open(f, "r")       
  10.         while line = file.gets             
  11.           if line =~ /<!--.*#include.*-->/
  12.             @template_tree[f] << path + Regexp.last_match(0)[/".*"/].slice(2..-2)
  13.           end
  14.         end
  15.         file.close
  16.       end
  17.     else
  18.       parse_directory "#{path}#{d}/" if (d != '.' && d != '..')
  19.     end
  20.   end
  21. end
  22.  
  23. parse_directory(root)
  24.  
  25. @template_tree.each do |key,value|
  26.   puts "#{key}: #{value}"
  27. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement