Sha256: 8e0613730581e542522e382da56bd1720e8f3a77c9be2e6d36b42404f81821d0
Contents?: true
Size: 1.42 KB
Versions: 1
Compression:
Stored size: 1.42 KB
Contents
require 'json' require "license/compatibility/version" module License module Compatibility def self.forward_compatiblity(source_license, derivative_license) souce_type = license_type(source_license) derivative_type = license_type(derivative_license) case souce_type when :public_domain return true when :permissive, :weak_copyleft [:public_domain, :permissive, :weak_copyleft, :copyleft, :strong_copyleft, :network_copyleft].include? derivative_type when :strong_copyleft [:strong_copyleft, :network_copyleft].include? derivative_type when :network_copyleft [:network_copyleft].include? derivative_type else raise 'Unknown license compatiblity' end end def self.license_data @@license_data ||= JSON.load(File.read(File.expand_path('../licenses.json', __FILE__))) end def self.license_type(license) license = license.gsub('+', '') if license_data['public_domain'].include?(license) :public_domain elsif license_data['permissive'].include?(license) :permissive elsif license_data['weak_copyleft'].include?(license) :weak_copyleft elsif license_data['strong_copyleft'].include?(license) :strong_copyleft elsif license_data['network_copyleft'].include?(license) :network_copyleft else raise 'Unknown license type' end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
license-compatibility-1.3.1 | lib/license/compatibility.rb |