OSDN Git Service

added a primitive value binding test
[xerial/xerial-core.git] / script / apply_license.rb
1 \r
2 require 'tempfile'\r
3 require 'fileutils'\r
4 require 'nkf'\r
5 \r
6 Dir["src/**/*.java"].each { |file|\r
7   lines = open(file) { |f| f.readlines }\r
8   next if lines[1].include?("Copyright")\r
9 \r
10   out = Tempfile.new("tempfile")\r
11   puts "apply license to #{file}"\r
12   license = <<LICENSE\r
13 /*--------------------------------------------------------------------------\r
14  *  Copyright 2007 Taro L. Saito\r
15  *\r
16  *  Licensed under the Apache License, Version 2.0 (the "License");\r
17  *  you may not use this file except in compliance with the License.\r
18  *  You may obtain a copy of the License at\r
19  *\r
20  *     http://www.apache.org/licenses/LICENSE-2.0\r
21  *\r
22  *  Unless required by applicable law or agreed to in writing, software\r
23  *  distributed under the License is distributed on an "AS IS" BASIS,\r
24  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
25  *  See the License for the specific language governing permissions and\r
26  *  limitations under the License.\r
27  *--------------------------------------------------------------------------*/\r
28 LICENSE\r
29   out.puts NKF.nkf('-Lw', license) \r
30   lines.each { |l| out.print(NKF.nkf('-Lw', l)) }\r
31   out.close\r
32   \r
33   FileUtils.mv(out.path, file)\r
34   \r
35 }\r
36 \r
37 \r
38 \r
39 \r