Sha256: 3ac6da2427a5a1258e8d99fcdcef5f2ddb97e328b56b8c9adad5220c32f052ca
Contents?: true
Size: 1.92 KB
Versions: 2
Compression:
Stored size: 1.92 KB
Contents
require 'yaml' module Licensed module Command class Verify attr_reader :config def initialize(config) @config = config end def approved?(dependency) @config.whitelisted?(dependency) || @config.reviewed?(dependency) end def dependencies @dependencies ||= @config.sources .map(&:dependencies) .flatten .select { |d| !@config.ignored?(d) } end def run @config.ui.info "Verifying licenses for #{dependencies.size} dependencies" @results = dependencies.map do |dependency| filename = @config.path.join("#{dependency["type"]}/#{dependency["name"]}.txt") warnings = [] if File.exists?(filename) license = License.read(filename) if license["version"] != dependency["version"] warnings << "cached license data out of date" end warnings << "missing license text" if license.text.strip.empty? unless approved?(license) warnings << "license needs reviewed: #{license["license"]}." end else warnings << "missing license data" end if warnings.size > 0 @config.ui.error("F", false) [filename, warnings] else @config.ui.confirm(".", false) nil end end.compact unless success? @config.ui.warn "\n\nWarnings:" @results.each do |filename, warnings| @config.ui.info "\n#{filename}:" warnings.each do |warning| @config.ui.error " - #{warning}" end end end puts "\n#{dependencies.size} dependencies checked, #{@results.size} warnings found." end def success? @results.empty? end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
licensed-0.11.1 | lib/licensed/command/verify.rb |
licensed-0.11.0 | lib/licensed/command/verify.rb |