Created
April 17, 2013 15:26
-
-
Save motoishmz/5405237 to your computer and use it in GitHub Desktop.
まとめてライセンス文をつっこむ用(拡張子チェックは適当に)
この例文だとApache 2.0
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
require 'find' | |
your_name = "My Name" | |
project_name = "My Project Name" | |
license_txt = <<EOF | |
// | |
// Copyright 2013 #{your_name} | |
// | |
// Licensed under the Apache License, Version 2.0 (the "License"); | |
// you may not use this file except in compliance with the License. | |
// You may obtain a copy of the License at | |
// | |
// http://www.apache.org/licenses/LICENSE-2.0 | |
// | |
// Unless required by applicable law or agreed to in writing, software | |
// distributed under the License is distributed on an "AS IS" BASIS, | |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
// See the License for the specific language governing permissions and | |
// limitations under the License. | |
EOF | |
Find.find(File.expand_path('.')) do |path| | |
next if File.directory?(path) | |
next unless (File::extname(path) == '.h' || File::extname(path) == '.cpp') | |
basename = File::basename(path) | |
open(path, "r+") do |file| | |
lines = file.readlines | |
lines.unshift("// \n// #{basename} - #{project_name}\n#{license_txt}\n") | |
file.rewind | |
lines.each do |line| | |
file.write line | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment