class Object
Public Instance Methods
traverse(start, header, update)
click to toggle source
# File lib/headerutil/util.rb, line 24 def traverse(start, header, update) file_array = [] Dir.foreach(start) do |x| path = File.join(start, x) if x == "." or x == ".." next elsif File.directory?(path) loop_in = 1 $ignore_folders.each() do |exclusion| $ignored_path = $search_folder + exclusion if path == $ignored_path loop_in = 0 break end end if loop_in == 1 inner_files_array = traverse(path, header, update) if inner_files_array.length > 0 file_array = file_array + inner_files_array end end else file_ext = File.extname(x) if $accepted_formats.keys.include? file_ext if File.readlines(path).grep(/#{header}/).size <= 0 if update `echo "#{$accepted_formats[file_ext][:prefix]} #{header} #{$accepted_formats[file_ext][:suffix]} \n" | cat - #{path} > #{path}.new.temp && mv #{path}.new.temp #{path}` end file_array.push(path) end end end end return file_array end