Sha256: 90acbcca6b7893185cc2ac8ef13334b7175ff8e99e5b46d692b1aa733ff2db1d

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

#!/usr/bin/env ruby

require_relative '../lib/licensee'

path = ARGV[0] || Dir.pwd

def format_percent(float)
  "#{format('%.2f', float)}%"
end

project = Licensee.project(path, detect_packages: true, detect_readme: true)
license_file = project.license_file
matched_file = project.matched_file

if license_file
  puts "License file: #{license_file.filename}"
  puts "Attribution: #{license_file.attribution}" if license_file.attribution
end

if matched_file
  if matched_file.license
    puts "License: #{matched_file.license.meta['title']}"
    puts "Confidence: #{format_percent(matched_file.confidence)}" if matched_file.confidence
    puts "Method: #{matched_file.matcher.class}" if matched_file.matcher
  else
    puts 'License: Not detected'
    puts
    puts "Here's the closest licenses:"
    matcher = Licensee::Matchers::Dice.new(matched_file)
    matcher.licenses_by_similiarity[0...3].each do |license, similarity|
      puts "* #{license.meta['spdx-id']} similarity: #{format_percent(similarity)}"
    end
  end
else
  puts 'Unknown'
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
licensee-8.5.0 bin/licensee