Created
January 28, 2010 16:10
-
-
Save nono/288872 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Author: Bruno Michel <bruno.michel@af83.com> | |
# Copyright 2010 (c) af83 | |
# Licence: MIT http://www.opensource.org/licenses/mit-license.php | |
# Add two comments to each of your Rails view with the name of this file, | |
# one at the beginning and the other at the end. | |
TMPL_BEGIN = "<!-- Start of %s -->\n" | |
TMPL_END = "<!-- End of %s -->\n" | |
Dir['app/views/**/*.erb'].each do |view| | |
name = view.sub('app/views/', '') | |
content = File.read(view) | |
first = TMPL_BEGIN % name | |
last = TMPL_END % name | |
if content =~ /\A#{TMPL_BEGIN.gsub('%s', '.*')}/ | |
puts " * #{name} already commented!" | |
else | |
puts " * #{name}" | |
File.open(view, "w+") { |f| f.write(first + content + last) } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment