namespace :housekeeping do desc "Remove all header-comments" task :remove_header_comments do ["Classes", "Tests"].each do |directory| files = Dir["./#{directory}/**/*"].select { |value| File.file?(value) } files.each do |file| lines_array = File.open(file).readlines if lines_array.first.match(/^\/\//) && !lines_array.first.match(/^\/\/ DO NOT EDIT/) text = lines_array.drop_while { |line| line.match(/^\/\/|^\n/) } File.open(file, 'w') do |f| f.puts text end end end end end end