bin/licensee in licensee-8.0.0 vs bin/licensee in licensee-8.1.0
- old
+ new
@@ -1,23 +1,34 @@
#!/usr/bin/env ruby
require_relative '../lib/licensee'
path = ARGV[0] || Dir.pwd
-options = { detect_packages: true, detect_readme: true }
-project = Licensee::GitProject.new(path, options)
-file = project.matched_file
+def print_file(license_file)
+ if license_file
+ puts "License file: #{license_file.filename}"
+ puts "Attribution: #{license_file.attribution}" if license_file.attribution
+ end
+end
-if project.license_file
- puts "License file: #{project.license_file.filename}"
- if project.license_file.attribution
- puts "Attribution: #{project.license_file.attribution}"
+def print_evaluation(file)
+ if file
+ puts "License: #{file.license ? file.license.meta['title'] : 'no license'}"
+ puts "Confidence: #{file.confidence}%"
+ puts "Method: #{file.matcher.class}"
+ else
+ puts 'Unknown'
end
end
-if file
- puts "License: #{file.license ? file.license.meta['title'] : 'no license'}"
- puts "Confidence: #{file.confidence}%"
- puts "Method: #{file.matcher.class}"
+if File.file?(path)
+ contents = File.read(path, encoding: 'utf-8')
+ license_file = Licensee::Project::LicenseFile.new(contents, path)
+ print_file(license_file)
+ print_evaluation(license_file)
else
- puts 'Unknown'
+ options = { detect_packages: true, detect_readme: true }
+ project = Licensee::GitProject.new(path, options)
+ file = project.matched_file
+ print_file(project.license_file)
+ print_evaluation(file)
end