Sha256: 8382e74125ef38ad2b384d3cf00ceb32aa1449803d1a5af8061f4903847aca47
Contents?: true
Size: 1.4 KB
Versions: 2
Compression:
Stored size: 1.4 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].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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
license-compatibility-1.3.0 | lib/license/compatibility.rb |
license-compatibility-1.2.0 | lib/license/compatibility.rb |