3 # Source Code License Guesser.
4 # Copyright, 2017 Alexander von Gluck IV. All Rights Reserved
5 # Released under the terms of the MIT license.
7 # Give a file, and I guess the license.
11 # haiku $ find src -name "*.cpp" -exec ./3rdparty/kallisti5/licenseReport.rb {} \;
16 {"MIT" => ["MIT License", "MIT Licence", "Haiku License", "X11 license"]},
17 {"BSD" => ["express or implied warranties", "provided by the author ``AS IS''", "the software is provided \"AS IS\"", "BSD license", "provided by the author \"as is\""]},
18 {"BeOS Sample Code" => ["be sample code license"]},
19 {"GPL" => ["terms of the GNU General Public License", "GNU L-GPL license", "GPL license", "Free Software Foundation"]},
22 def check_license(filename)
24 lines = File.foreach(filename).first(30).join("\n")
25 return "empty file" if lines == nil
26 @licenses.each do |entry|
27 entry.values.first.each do |pattern|
28 if lines.downcase.include?(pattern.downcase)
29 license = entry.keys.first
33 break if license != "unknown"
38 puts "#{@file}: #{check_license(@file)}"