Changed copyright rake task to allow adding copyright

notices to any paths
pull/284/head
Sebastian Schuster 11 years ago
parent ee6c9f792e
commit 2dcdf9c7ea
  1. 64
      lib/tasks/copyright.rake

@ -51,11 +51,13 @@ namespace :copyright do
end
end
def rewrite_copyright(ending, exclude, format)
def rewrite_copyright(ending, exclude, format, path)
regexp = copyright_regexp(format)
copyright = short_copyright(format)
Dir["**/**{.#{ending}}"].each do |file_name|
path = '.' if path.nil?
raise "Path not found" unless Dir.exists?(path)
Dir[File.absolute_path(path) + "/**/*.#{ending}"].each do |file_name|
# Skip 3rd party code
next if exclude.any? {|e| file_name.include?(e) }
@ -73,7 +75,7 @@ namespace :copyright do
end
desc "Update the copyright on .rb source files"
task :update_rb do
task :update_rb, :arg1 do |task, args|
excluded = (["diff",
"ruby-net-ldap-0.0.4",
"acts_as_tree",
@ -85,37 +87,37 @@ namespace :copyright do
(["SVG",
"redcloth"].map{ |dir| "lib/#{dir}" })
rewrite_copyright("rb", excluded, :rb)
rewrite_copyright("rb", excluded, :rb, args[:arg1])
end
desc "Update the copyright on .rake source files"
task :update_rake do
rewrite_copyright("rake", [], :rb)
task :update_rake, :arg1 do |task, args|
rewrite_copyright("rake", [], :rb, args[:arg1])
end
desc "Update the copyright on .feature source files"
task :update_feature do
rewrite_copyright("feature", [], :rb)
task :update_feature, :arg1 do |task, args|
rewrite_copyright("feature", [], :rb, args[:arg1])
end
desc "Update the copyright on .css source files"
task :update_css do
task :update_css, :arg1 do |task, args|
excluded = ["app/assets/stylesheets/reset.css",
"lib/assets",
"app/assets/javascripts/tinymce"]
rewrite_copyright("css", excluded, :css)
rewrite_copyright("css", excluded, :css, args[:arg1])
end
desc "Update the copyright on .css.erb source files"
task :update_css_erb do
task :update_css_erb, :arg1 do |task, args|
excluded = ["lib/assets/stylesheets/select2.css.erb"]
rewrite_copyright("css.erb", excluded, :css)
rewrite_copyright("css.erb", excluded, :css, args[:arg1])
end
desc "Update the copyright on .js source files"
task :update_js do
task :update_js, :arg1 do |task, args|
excluded = ["lib/assets",
"app/assets/javascripts/Bitstream_Vera_Sans_400.font.js",
"app/assets/javascripts/date-de-DE.js",
@ -126,37 +128,41 @@ namespace :copyright do
"app/assets/javascripts/calendar",
"app/assets/javascripts/jstoolbar"]
rewrite_copyright("js", excluded, :js)
rewrite_copyright("js", excluded, :js, args[:arg1])
end
desc "Update the copyright on .js.erb source files"
task :update_js_erb do
task :update_js_erb, :arg1 do |task, args|
excluded = ["lib/assets",
"app/assets/javascripts/tinymce",
"app/assets/javascripts/calendar",
"app/assets/javascripts/jstoolbar"]
rewrite_copyright("js.erb", excluded, :erb)
rewrite_copyright("js.erb", excluded, :erb, args[:arg1])
end
desc "Update the copyright on .html.erb source files"
task :update_html_erb do
rewrite_copyright("html.erb", [], :erb)
task :update_html_erb, :arg1 do |task, args|
rewrite_copyright("html.erb", [], :erb, args[:arg1])
end
desc "Update the copyright on .api.rsb source files"
task :update_api_rsb do
rewrite_copyright("api.rsb", [], :rb)
task :update_api_rsb, :arg1 do |task, args|
rewrite_copyright("api.rsb", [], :rb, args[:arg1])
end
desc "Update the copyright on all source files"
task :update => [:update_css,
:update_rb,
:update_js,
:update_js_erb,
:update_css_erb,
:update_html_erb,
:update_api_rsb,
:update_rake,
:update_feature]
task :update, :arg1 do |task, args|
[:update_css,
:update_rb,
:update_js,
:update_js_erb,
:update_css_erb,
:update_html_erb,
:update_api_rsb,
:update_rake,
:update_feature].each do |t|
Rake::Task['copyright:' + t.to_s].invoke(args[:arg1])
end
end
end

Loading…
Cancel
Save