Skip to content

Instantly share code, notes, and snippets.

@daviddavis
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daviddavis/c60c5d3601ee63bcd7af to your computer and use it in GitHub Desktop.
Save daviddavis/c60c5d3601ee63bcd7af to your computer and use it in GitHub Desktop.
files = Dir["**/*.rb"]
puts "Checking #{files.length}"
files.each do |filename|
file = File.open(filename, "r")
content = file.read
file.close
if content =~ /^# Copyright 201\d Red Hat, Inc.$/
puts "Editing #{filename}"
content = content.gsub(/\A\s*(^#.*$\n){11,11}\s*/, "")
File.open(filename, 'w') { |file| file.write(content)}
end
end
@ehelms
Copy link

ehelms commented May 6, 2015

#!/usr/bin/env ruby

files = Dir["test/**/*.js"]

puts "Checking #{files.length}"

files.each do |filename|
  file = File.open(filename, "r")
  content = file.read
  file.close

  if content =~ /Copyright 201\d Red Hat, Inc./
    puts "Editing #{filename}"
    content = content.gsub(/\/\*\*\s*Copyright(.*$\s*){10,10}/, "")
    content = content.gsub(/\/\*\*\s*\* Copyright(.*$\s*){11,11}/, "")
    File.open(filename, 'w') { |file| file.write(content)}
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment