root/trunk/add_license.rb

リビジョン 4, 2.2 KB (コミッタ: kkato, 5 年 前)

A kotodamaOSS

行番号 
1require 'find'
2
3def add_license(filename,txt) 
4  filename2=filename+'_tmp'
5  s = File.readlines(filename)
6  if s[0]=~/BEGIN LICENSE/
7    return false
8  end
9  file2 = File.new(filename2,"w")
10  file2.write(txt)
11  file2.write(s)
12  file2.close
13  File.delete(filename)
14  File.rename(filename2,filename)
15  true
16end
17
18for_cs = <<EOS
19/* ***** BEGIN LICENSE BLOCK *****
20 * Version: MPL 1.1
21 *
22 * The contents of this file are subject to the Mozilla Public License
23 * Version 1.1 (the "License"); you may not use this file except in
24 * compliance with the License. You may obtain a copy of the License at
25 * http://www.mozilla.org/MPL/
26 *
27 * Software distributed under the License is distributed on an "AS IS"
28 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
29 * License for the specific language governing rights and limitations
30 * under the License.
31 *
32 * The Original Code is tyzoh.jp code.
33 *
34 * The Initial Developer of the Original Code is Kazutaka Kurihara.
35 * Portions created by the Initial Developer are Copyright (C) 2007
36 * the Initial Developer. All Rights Reserved.
37 *
38 * Contributor(s):
39 *
40 * ***** END LICENSE BLOCK ***** */
41EOS
42
43for_xml = <<EOS
44<!-- ***** BEGIN LICENSE BLOCK *****
45   - Version: MPL 1.1
46   -
47   - The contents of this file are subject to the Mozilla Public License
48   - Version 1.1 (the "License"); you may not use this file except in
49   - compliance with the License. You may obtain a copy of the License at
50   - http://www.mozilla.org/MPL/
51   -
52   - Software distributed under the License is distributed on an "AS IS"
53   - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
54   - License for the specific language governing rights and limitations
55   - under the License.
56   -
57   - The Original Code is tyzoh.jp code.
58   -
59   - The Initial Developer of the Original Code is Kazutaka Kurihara.
60   - Portions created by the Initial Developer are Copyright (C) 2007
61   - the Initial Developer. All Rights Reserved.
62   -
63   - Contributor(s):
64   -
65   - ***** END LICENSE BLOCK ***** -->
66EOS
67
68Find.find('.') do |path|
69  if path=~/\.cs$/ then
70    if add_license(path,for_cs)
71      puts path
72    end
73  end
74end
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。