Skip to content

Commit

Permalink
Added a ruby script to prepend files with a uniform header.
Browse files Browse the repository at this point in the history
  • Loading branch information
JorenSix committed Nov 14, 2012
1 parent 6f2aab1 commit 207ce09
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
25 changes: 25 additions & 0 deletions 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.
*
*/
20 changes: 20 additions & 0 deletions 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/
*
*/
26 changes: 26 additions & 0 deletions 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

0 comments on commit 207ce09

Please sign in to comment.