From 207ce0926f8b276194f5be143284d72eb3a9db52 Mon Sep 17 00:00:00 2001 From: JorenSix Date: Wed, 14 Nov 2012 11:11:34 +0100 Subject: [PATCH] Added a ruby script to prepend files with a uniform header. --- new_prefix.txt | 25 +++++++++++++++++++++++++ old_prefix.txt | 20 ++++++++++++++++++++ prepender.rb | 26 ++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 new_prefix.txt create mode 100644 old_prefix.txt create mode 100644 prepender.rb diff --git a/new_prefix.txt b/new_prefix.txt new file mode 100644 index 00000000..cf6a3cc6 --- /dev/null +++ b/new_prefix.txt @@ -0,0 +1,25 @@ +/* +* _______ _____ _____ _____ +* |__ __| | __ \ / ____| __ \ +* | | __ _ _ __ ___ ___ ___| | | | (___ | |__) | +* | |/ _` | '__/ __|/ _ \/ __| | | |\___ \| ___/ +* | | (_| | | \__ \ (_) \__ \ |__| |____) | | +* |_|\__,_|_| |___/\___/|___/_____/|_____/|_| +* +* ----------------------------------------------------------- +* +* TarsosDSP is developed by Joren Six at +* The School of Arts, +* University College Ghent, +* Hoogpoort 64, 9000 Ghent - Belgium +* +* ----------------------------------------------------------- +* +* Info: http://tarsos.0110.be/tag/TarsosDSP +* Github: https://github.com/JorenSix/TarsosDSP +* Releases: http://tarsos.0110.be/releases/TarsosDSP/ +* +* TarsosDSP includes modified source code by various authors, +* for credits and info, see README. +* +*/ \ No newline at end of file diff --git a/old_prefix.txt b/old_prefix.txt new file mode 100644 index 00000000..164ec074 --- /dev/null +++ b/old_prefix.txt @@ -0,0 +1,20 @@ +/* +* _______ _____ _____ _____ +* |__ __| | __ \ / ____| __ \ +* | | __ _ _ __ ___ ___ ___| | | | (___ | |__) | +* | |/ _` | '__/ __|/ _ \/ __| | | |\___ \| ___/ +* | | (_| | | \__ \ (_) \__ \ |__| |____) | | +* |_|\__,_|_| |___/\___/|___/_____/|_____/|_| +* +* ----------------------------------------------------------- +* +* TarsosDSP is developed by Joren Six at +* The Royal Academy of Fine Arts & Royal Conservatory, +* University College Ghent, +* Hoogpoort 64, 9000 Ghent - Belgium +* +* http://tarsos.0110.be/tag/TarsosDSP +* https://github.com/JorenSix/TarsosDSP +* http://tarsos.0110.be/releases/TarsosDSP/ +* +*/ diff --git a/prepender.rb b/prepender.rb new file mode 100644 index 00000000..f7b65059 --- /dev/null +++ b/prepender.rb @@ -0,0 +1,26 @@ +require 'rubygems' + +source_files = Dir.glob(File.join("**", "*.java")) +new_prefix = File.open("new_prefix.txt", "r").read +old_prefix = File.open("old_prefix.txt", "r").read + + +def starts_with?(string, prefix) + prefix = prefix.to_s + string[0, prefix.length] == prefix +end + + +source_files.each do |source_file| + source_file_contents = File.open(source_file, "r").read + if source_file_contents.start_with? old_prefix + source_file_contents = source_file_contents.gsub(old_prefix,"") + end + unless source_file_contents.start_with? new_prefix + source_file_contents = new_prefix + "\n" + source_file_contents + File.open( source_file, 'w' ) { | file | file.puts source_file_contents } + end +end + +puts source_files +puts new_prefix