Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Will read files and output into one big file with filename headers
- def one_big_file (search_root)
- files = Dir[search_root + '/**/*']
- file_types = [".rb"]
- output_text = ""
- # Read File contents
- for i in 0...file_types.length
- file_type = files.select { |f|
- f.end_with?(file_types[i])
- }
- file_type.each { |f|
- file_text = File.read(Dir.pwd + "/" + f)
- output_text += ("=" * 80) + "\n" + f + "\n" + ("=" * 80) + "\n\n" + file_text + "\n\n"
- }
- end
- # Output to File
- output_file = File.open("./one_big_file.txt", "w")
- output_file.puts output_text
- output_file.close
- end
- search_root = ARGV[0]
- if (search_root != nil)
- one_big_file(search_root)
- else
- puts "Please have a search root as an argument.\nUse: \"FOLDER_NAME\" - with quotation marks\nDo not use \"./\" to begin path.\ni.e. ruby one_big_file.rb \"Tower Defence Game\""
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement