licenserec 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf10778baa2d790da8589208710ca311c45c3f1bddedb25eba71d04763378982
4
- data.tar.gz: 78bc30cb7ba9ece5e745ec352c20d7e371d193b46dce040a53d081c53d691b10
3
+ metadata.gz: 7dd6bc9e3158cda9799912b2bb80a8623d0c855fe9e9e408663a7d19f8d4df76
4
+ data.tar.gz: 43178a17b5aec587c9b564693cde717b479178b43f50c8e78935771292f8a219
5
5
  SHA512:
6
- metadata.gz: 8474896f69db3fedb7c32f3b0ac407d4c4dabe4caf284d89dc855f193f9bfc40794dbcdd2131b2d17fbec989784256e3506f74c6ee86abccc79f3ef869364cb0
7
- data.tar.gz: eb56fbc4c8d1bb273a339148eba03a1f949faa8f3d0fc043f647ea958899bd3b19038b9bbb211ce20b4e4ff641ead41a9d23709dbd521226b79e4bd6c834493c
6
+ metadata.gz: 6e92ebd14012275c4a1bbfc83e2c2f91e4fade67f93e0f2867b646abd88035d1ddd4b9f21b8c9e4e1d6f83867daf60a2ec2b0bc784b306c2e8d7b69e9d6a61f7
7
+ data.tar.gz: 4bf74bf16da95590928eb14391c4a8678872506f3d47dbbb5ff6684e1bedf52645c98071a5d824e68f61e413650720ca9344eeace4ce20114f9756e8a4c63b0d
data/README.md CHANGED
@@ -67,7 +67,7 @@ Perl5
67
67
  | 1 | CompatibilityFilter | ninka_process(filepath,ninka_path) | 第三方工具Ninka识别文件许可证,一个文件可能包含多个许可证。输入1为文件的路径(String),输入2为ninka.pl的路径(String);输出为许可证列表(Array)。 |
68
68
  | 2 | | license_detection(repo_path,ninka_path) | 识别项目所包含的许可证,输入1为项目路径(String),输入2为ninka.pl的路径(String);输出1为文件路径及对应许可证信息的哈希表(Hash),输出2为项目包含的许可证集合(Set)。 |
69
69
  | 3 | | compatibility_lookup(licenseA,licenseB) | 兼容性查询,输入1为许可证A(String),通常指项目中第三方组件的许可证,输入2为许可证B(String),通常指项目许可证;输出为(String),其中"0"(不兼容)、"1"(次级兼容)、"2"(组合兼容)、"1,2"(次级兼容或组合兼容)。 |
70
- | 4 | | compatibility_filter(repo_path,ninka_path,recommand_scale) | 兼容许可证筛选,输入1为项目路径(String),输入2为ninka.pl的路径(String),输入3为许可证推荐范围(String),其中“popular”包含MIT等20种常见开源许可证,“all”包含本知识库支持的6种开源许可证;输出1为仅满足次级兼容的许可证列表(Array),输出2为仅满足组合兼容的许可证列表(Array),输出3为既满足次级兼容又满足组合兼容的许可证列表(Array) |
70
+ | 4 | | compatibility_filter(repo_path,ninka_path,recommand_scale) | 兼容许可证筛选,输入1为项目路径(String),输入2为ninka.pl的路径(String),输入3为许可证推荐范围(String),其中“popular”包含MIT等20种常见开源许可证,“all”包含本知识库支持的6种开源许可证;输出1为仅满足次级兼容的许可证列表(Array),输出2为仅满足组合兼容的许可证列表(Array),输出3为既满足次级兼容又满足组合兼容的许可证列表(Array),输出4为项目中已检查过兼容性的许可证列表。 |
71
71
  | 5 | CompatibilityCheck | compatibilitycheck(repo_path,ninka_path) | 兼容性检查,输入1为项目路径(String),输入2为ninka.pl路径(String);输出为“OK”(String),或项目种包含互不兼容许可证的提示信息的集合(Set)和对应文件路径的列表(Array)。 |
72
72
  | 6 | Termschoice | important_terms_instruction() | 开源许可证关键条款及说明。 |
73
73
  | 7 | | license_term_lookup(one_license,one_term) | 查询某个开源许可证的某个条款要素的值。输入1为许可证的SPDX(String),输入2为条款要素名称(String);输出为要素值(String),其中--。 |
@@ -79,7 +79,7 @@ Perl5
79
79
  | 13 | TermsCompare | licenses_term_compare(licenses_list) | 输入为许可证列表,输出列表中的许可证的条款要素值(Hash),key为许可证SPDX(String),value为要素值列表(Array)。 |
80
80
  | 14 | LicenseSort | csv_to_hash(csv_table,header=true,i=0,j=1) | 将csv转为哈希值。输入1为csv表,输入2为是否包含首行(默认包含),输入3为列数i(转为hash的key),输入4为列数j(转为hash的value);输出为哈希表。 |
81
81
  | 15 | | sortvalue_lookup(one_license,sort_hash) | 从排序哈希表中查询排序值。输入1为许可证SPDX,输入2为参照排序哈希表;输出为该许可证的排序值。 |
82
- | 16 | | license_sort(license_list,desc=true,sort_hash=LicenseSort.csv_to_hash("lib\\license_readability.csv",header=true,i=0,j=4)) | 对指定许可证列表进行排序。输入1为指定的许可证列表,输入2为升降序(默认降序),输入3为参照排序哈希表(key为许可证SPDX,value为参照值,默认按文本复杂度);输出排序后的许可证列表。 |
82
+ | 16 | | license_sort(license_list,desc=true,sort_hash=LicenseSort.csv_to_hash(String(Pathname.new(File.dirname(__FILE__)).realpath)+"\\license_readability.csv",header=true,i=0,j=4)) | 对指定许可证列表进行排序。输入1为指定的许可证列表,输入2为升降序(默认降序),输入3为参照排序哈希表(key为许可证SPDX,value为参照值,默认按文本复杂度);输出排序后的许可证列表。 |
83
83
 
84
84
 
85
85
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  require_relative "licenserec/version"
4
4
  require 'csv'
5
-
5
+ require 'pathname'
6
6
 
7
7
  module Licenserec
8
8
  class TermsCompare
@@ -14,8 +14,9 @@ module Licenserec
14
14
  def self.licenses_term_compare(licenses_list)
15
15
  license_terms_hash = Hash.new
16
16
  license_terms_hash.store("license",["info","preamble","define","copyright patent", "trademark", "copyleft", "interaction", "modification", "retain_attr", "enhance_attr", "acceptance", "patent_term", "vio_term", "disclaimer", "law", "instruction", "compatible_version", "secondary_license", "gpl_combine"])
17
- c_table = CSV.read("lib\\licenses_terms_63.csv",headers:true)
18
- CSV.foreach("lib\\licenses_terms_63.csv") do |row|
17
+ cur_path=String(Pathname.new(File.dirname(__FILE__)).realpath)
18
+ c_table = CSV.read(cur_path+"\\licenses_terms_63.csv",headers:true)
19
+ CSV.foreach(cur_path+"\\licenses_terms_63.csv") do |row|
19
20
  licenses_list.each do |one_license|
20
21
  if row[0] == one_license
21
22
  no_row = $.
@@ -4,7 +4,7 @@ require_relative "licenserec/version"
4
4
  require 'set'
5
5
  require 'open3'
6
6
  require 'csv'
7
-
7
+ require 'pathname'
8
8
  module Licenserec
9
9
  class CompatibilityFilter
10
10
  def initialize()
@@ -94,8 +94,9 @@ module Licenserec
94
94
  # 兼容性查询,输入1为许可证A(通常指项目中第三方组件的许可证),输入2为许可证B(通常指项目许可证),输出为"0"(不兼容)、"1"(次级兼容)、"2"(组合兼容)、"1,2"(次级兼容或组合兼容)。
95
95
  def self.compatibility_lookup(licenseA,licenseB)
96
96
  compatibility_AB = '1,2'
97
- c_table = CSV.read("lib\\compatibility_63.csv",headers:true)
98
- CSV.foreach("lib\\compatibility_63.csv") do |row|
97
+ cur_path=String(Pathname.new(File.dirname(__FILE__)).realpath)
98
+ c_table = CSV.read(cur_path+"\\compatibility_63.csv",headers:true)
99
+ CSV.foreach(cur_path+"\\compatibility_63.csv") do |row|
99
100
  if row[0]==licenseA
100
101
  no_row = $.
101
102
  compatibility_AB = c_table[no_row-2][licenseB]
@@ -107,7 +108,8 @@ module Licenserec
107
108
  # 兼容许可证筛选,输入1为项目路径,输入2为ninka路径,输入3为许可证推荐范围,其中默认值“popular”包含MIT等20种常见开源许可证,“all”包含本知识库支持的6种开源许可证。输出1为仅满足次级兼容的许可证列表,输出2为仅满足组合兼容的许可证列表,输出3为既满足次级兼容又满足组合兼容的许可证列表。
108
109
  def self.compatibility_filter(repo_path,ninka_path,recommand_scale="popular")
109
110
  filelicense_hash,licenseA_set = CompatibilityFilter.license_detection(repo_path,ninka_path)
110
- c_table = CSV.read("lib\\compatibility_63.csv",headers:true)
111
+ cur_path=String(Pathname.new(File.dirname(__FILE__)).realpath)
112
+ c_table = CSV.read(cur_path+"\\compatibility_63.csv",headers:true)
111
113
  all_license = c_table['license']
112
114
  if recommand_scale == "popular"
113
115
  licenseB_list = %w[MIT Apache-2.0 GPL-3.0 BSD-3-Clause GPL-2.0 AGPL-3.0 MPL-2.0 LGPL-3.0 BSD-2-Clause Unlicense ISC EPL-1.0 CC0-1.0 LGPL-2.1 WTFPL Zlib EPL-2.0 Artistic-2.0 MulanPSL-2.0 MulanPubL-2.0]
@@ -186,7 +188,8 @@ module Licenserec
186
188
  # 兼容性检查,输入1为项目路径,输入2为ninka路径,输出为“OK”,或项目种包含互不兼容许可证的提示信息的集合、对应文件路径的列表
187
189
  def self.compatibilitycheck(repo_path,ninka_path)
188
190
  file_licenses_hash,licenses_set = CompatibilityFilter.license_detection(repo_path,ninka_path)
189
- c_table = CSV.read("lib\\compatibility_63.csv",headers:true)
191
+ cur_path=String(Pathname.new(File.dirname(__FILE__)).realpath)
192
+ c_table = CSV.read(cur_path+"\\compatibility_63.csv",headers:true)
190
193
  check_license_list = c_table["license"]
191
194
  conflict_copyleft_infoset = Set.new
192
195
  conflict_licenses = Set.new
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Licenserec
4
- VERSION = "1.0.2"
4
+ VERSION = "1.0.3"
5
5
  end
data/lib/licensesort.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  require_relative "licenserec/version"
4
4
  require 'csv'
5
-
5
+ require 'pathname'
6
6
 
7
7
  module Licenserec
8
8
  class LicenseSort
@@ -32,9 +32,8 @@ module Licenserec
32
32
  end
33
33
  return Float(sortvalue[0])
34
34
  end
35
-
36
35
  # 对指定许可证列表进行排序。输入1为指定的许可证列表,输入2为升降序(默认降序),输入3为参照排序哈希表(key为许可证SPDX,value为参照值,默认按文本复杂度);输出排序后的许可证列表。
37
- def self.license_sort(license_list,desc=true,sort_hash=LicenseSort.csv_to_hash("lib\\license_readability.csv",header=true,i=0,j=4))
36
+ def self.license_sort(license_list,desc=true,sort_hash=LicenseSort.csv_to_hash(String(Pathname.new(File.dirname(__FILE__)).realpath)+"\\license_readability.csv",header=true,i=0,j=4))
38
37
  sort_res=[]
39
38
  license_initsort = Hash.new
40
39
  for one_license in license_list do
@@ -4,7 +4,7 @@ require_relative "licenserec/version"
4
4
  require 'set'
5
5
  require 'open3'
6
6
  require 'csv'
7
-
7
+ require 'pathname'
8
8
  module Licenserec
9
9
  class TermsChoice
10
10
  def initialize()
@@ -83,8 +83,9 @@ module Licenserec
83
83
  # 查询某个开源许可证的某个条款要素的值。输入1为许可证的SPDX,输入2为条款要素名称。输出为要素值,其中--。
84
84
  def self.license_term_lookup(one_license,one_term)
85
85
  term_feature = -1
86
- c_table = CSV.read("lib\\licenses_terms_63.csv",headers:true)
87
- CSV.foreach("lib\\licenses_terms_63.csv") do |row|
86
+ cur_path=String(Pathname.new(File.dirname(__FILE__)).realpath)
87
+ c_table = CSV.read(cur_path+"\\licenses_terms_63.csv",headers:true)
88
+ CSV.foreach(cur_path+"\\licenses_terms_63.csv") do |row|
88
89
  if row[0] == one_license
89
90
  no_row = $.
90
91
  term_feature = c_table[no_row-2][one_term]
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: licenserec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - osslab-pku
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-27 00:00:00.000000000 Z
11
+ date: 2022-07-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Licenserec是一个用于开源许可证选择的ruby库,提供许可证兼容性查询、许可证兼容性检查、项目兼容许可证筛选、许可证条款特征查询、许可证条款特征对比、许可证类型选择观点、许可证关键条款解读等功能。
14
14
  email:
@@ -42,6 +42,7 @@ files:
42
42
  - lib/licensetypeguide.rb
43
43
  - licenserec-1.0.0.gem
44
44
  - licenserec-1.0.1.gem
45
+ - licenserec-1.0.2.gem
45
46
  - sig/licenserec.rbs
46
47
  homepage: https://rubygems.org/gems/licenserec
47
48
  licenses: []