have copyrights at the bottom of .rdoc and .md files

This commit is contained in:
Philipp Tessenow
2013-09-03 17:07:00 +02:00
parent 5d45ac73c6
commit 8ccc350119
5 changed files with 94 additions and 5 deletions
+15
View File
@@ -98,3 +98,18 @@
* `#778` Integrate ban of former passwords
* `#1209` Fix adding watcher to issue
* `#1034` Create changelog and document format
----------
#### copyright
OpenProject is a project management system.
Copyright (C) 2012-2013 the OpenProject Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 3.
See doc/COPYRIGHT.rdoc for more details.
++
----------
+15
View File
@@ -1,3 +1,18 @@
= Install
The detailed installation instructions are located on the {official website}[https://www.chiliproject.org/projects/chiliproject/wiki/Installation]
----------
==== copyright
OpenProject is a project management system.
Copyright (C) 2012-2013 the OpenProject Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 3.
See doc/COPYRIGHT.rdoc for more details.
++
----------
+15
View File
@@ -83,3 +83,18 @@ You let test unit display test names instead of anonymous dots with the followin
* Sometimes you want to test things manually. Always remember: If you test something more than once, write an automated test for it.
* Assuming you do not have all Internet Explorer version installed on your computer, you can grab a VM with preinstalled IE's directly from Mircrosoft: http://www.modern.ie/en-us/virtualization-tools#downloads
----------
#### copyright
OpenProject is a project management system.
Copyright (C) 2012-2013 the OpenProject Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 3.
See doc/COPYRIGHT.rdoc for more details.
++
----------
+15
View File
@@ -1,3 +1,18 @@
= Upgrade
The detailed upgrade instructions are located on the {official website}[https://www.openproject.org/projects/support/wiki/Upgrade]
----------
==== copyright
OpenProject is a project management system.
Copyright (C) 2012-2013 the OpenProject Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 3.
See doc/COPYRIGHT.rdoc for more details.
++
----------
+34 -5
View File
@@ -19,6 +19,10 @@ namespace :copyright do
short_copyright_line("//")
when :erb
short_copyright_surrounding("<%#", "#%>")
when :rdoc
"----------\n#{short_copyright_line(' ')}\n----------\n".gsub(' -- copyright',"==== copyright\n")
when :md
"----------\n#{short_copyright_line(' ')}\n----------\n".gsub(' -- copyright',"#### copyright\n")
else
raise "Undefined format #{format}"
end
@@ -46,14 +50,18 @@ namespace :copyright do
/^\/\/--\s*copyright.*?\/\/\+\+/m
when :erb
/^<%#--\s*copyright.*?\+\+#%>/m
when :rdoc
/-{10}\n={4} copyright\n\n[\s\S]*?\+\+\n-{10}\n$/
when :md
/-{10}\n\#{4} copyright\n\n[\s\S]*?\+\+\n-{10}\n$/
else
raise "Undefined format #{format}"
end
end
def rewrite_copyright(ending, exclude, format, path)
regexp = copyright_regexp(format)
copyright = short_copyright(format)
def rewrite_copyright(ending, exclude, format, path, options = {})
regexp = options[:regex] || copyright_regexp(format)
copyright = options[:copyright] || short_copyright(format)
path = '.' if path.nil?
raise "Path not found" unless Dir.exists?(path)
@@ -65,7 +73,11 @@ namespace :copyright do
if file_content.match(regexp)
file_content.gsub!(regexp, copyright)
else
file_content = copyright + "\n\n" + file_content # Prepend
if options[:position] == :bottom
file_content = file_content + "\n\n" + copyright # append
else
file_content = copyright + "\n\n" + file_content # prepend
end
end
File.open(file_name, "w") do |file|
@@ -141,6 +153,21 @@ namespace :copyright do
rewrite_copyright("js.erb", excluded, :erb, args[:arg1])
end
desc "Update the copyright on .rdoc source files"
task :update_rdoc, :arg1 do |task, args|
excluded = ["README.rdoc",
"doc/COPYRIGHT.rdoc",
"doc/COPYING.rdoc",
"doc/COPYRIGHT_short.rdoc"]
rewrite_copyright("rdoc", excluded, :rdoc, args[:arg1], :position => :bottom)
end
desc "Update the copyright on .md source files"
task :update_md, :arg1 do |task, args|
rewrite_copyright("md", [], :md, args[:arg1], :position => :bottom)
end
desc "Update the copyright on .html.erb source files"
task :update_html_erb, :arg1 do |task, args|
rewrite_copyright("html.erb", [], :erb, args[:arg1])
@@ -161,7 +188,9 @@ namespace :copyright do
:update_html_erb,
:update_api_rsb,
:update_rake,
:update_feature].each do |t|
:update_feature,
:update_rdoc,
:update_md].each do |t|
Rake::Task['copyright:' + t.to_s].invoke(args[:arg1])
end
end