license_finder 1.2 → 2.0.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -1
- data/CHANGELOG.rdoc +27 -0
- data/CONTRIBUTING.md +38 -0
- data/README.md +139 -159
- data/Rakefile +17 -13
- data/features/features/cli_spec.rb +43 -0
- data/features/features/configure/add_dependencies_spec.rb +37 -0
- data/features/features/configure/approve_dependencies_spec.rb +30 -0
- data/features/features/configure/assign_licenses_spec.rb +20 -0
- data/features/features/configure/ignore_dependencies_spec.rb +35 -0
- data/features/features/configure/ignore_groups_spec.rb +31 -0
- data/features/features/configure/name_project_spec.rb +32 -0
- data/features/features/configure/whitelist_licenses_spec.rb +40 -0
- data/features/features/package_managers/bower_spec.rb +14 -0
- data/features/features/package_managers/cocoapods_spec.rb +14 -0
- data/features/features/package_managers/gradle_spec.rb +14 -0
- data/features/features/package_managers/maven_spec.rb +14 -0
- data/features/features/package_managers/npm_spec.rb +14 -0
- data/features/features/package_managers/pip_spec.rb +14 -0
- data/features/features/report/csv_spec.rb +17 -0
- data/features/features/report/html_spec.rb +50 -0
- data/{spec → features}/fixtures/Podfile +0 -0
- data/{spec → features}/fixtures/build.gradle +0 -0
- data/{spec → features}/fixtures/pom.xml +0 -0
- data/features/support/testing_dsl.rb +295 -0
- data/lib/license_finder.rb +16 -50
- data/lib/license_finder/cli.rb +13 -253
- data/lib/license_finder/cli/approvals.rb +26 -0
- data/lib/license_finder/cli/base.rb +20 -0
- data/lib/license_finder/cli/dependencies.rb +39 -0
- data/lib/license_finder/cli/ignored_dependencies.rb +30 -0
- data/lib/license_finder/cli/ignored_groups.rb +30 -0
- data/lib/license_finder/cli/licenses.rb +24 -0
- data/lib/license_finder/cli/main.rb +82 -0
- data/lib/license_finder/cli/makes_decisions.rb +48 -0
- data/lib/license_finder/cli/patched_thor.rb +34 -0
- data/lib/license_finder/cli/project_name.rb +31 -0
- data/lib/license_finder/cli/whitelist.rb +32 -0
- data/lib/license_finder/configuration.rb +14 -145
- data/lib/license_finder/decision_applier.rb +46 -0
- data/lib/license_finder/decisions.rb +174 -0
- data/lib/license_finder/license.rb +13 -32
- data/lib/license_finder/license/definitions.rb +15 -13
- data/lib/license_finder/license/template.rb +1 -1
- data/lib/{data/licenses → license_finder/license/templates}/Apache2.txt +0 -0
- data/lib/{data/licenses → license_finder/license/templates}/BSD.txt +0 -0
- data/lib/{data/licenses → license_finder/license/templates}/GPLv2.txt +0 -0
- data/lib/{data/licenses → license_finder/license/templates}/ISC.txt +0 -0
- data/lib/{data/licenses → license_finder/license/templates}/LGPL.txt +0 -0
- data/lib/{data/licenses → license_finder/license/templates}/MIT.txt +0 -0
- data/lib/{data/licenses → license_finder/license/templates}/NewBSD.txt +0 -0
- data/lib/{data/licenses → license_finder/license/templates}/Python.txt +0 -0
- data/lib/{data/licenses → license_finder/license/templates}/Ruby.txt +0 -0
- data/lib/{data/licenses → license_finder/license/templates}/SimplifiedBSD.txt +0 -0
- data/lib/license_finder/package.rb +77 -7
- data/lib/license_finder/package_manager.rb +43 -0
- data/lib/license_finder/package_managers/bower.rb +1 -1
- data/lib/license_finder/package_managers/bower_package.rb +23 -44
- data/lib/license_finder/package_managers/bundler.rb +4 -7
- data/lib/license_finder/package_managers/bundler_package.rb +14 -31
- data/lib/license_finder/package_managers/cocoa_pods.rb +1 -1
- data/lib/license_finder/package_managers/cocoa_pods_package.rb +2 -10
- data/lib/license_finder/package_managers/gradle.rb +6 -2
- data/lib/license_finder/package_managers/gradle_package.rb +6 -30
- data/lib/license_finder/package_managers/manual_package.rb +25 -0
- data/lib/license_finder/package_managers/maven_package.rb +8 -37
- data/lib/license_finder/package_managers/npm.rb +16 -4
- data/lib/license_finder/package_managers/npm_package.rb +12 -43
- data/lib/license_finder/package_managers/pip_package.rb +17 -37
- data/lib/license_finder/platform.rb +0 -16
- data/lib/license_finder/possible_license_file.rb +9 -14
- data/lib/license_finder/possible_license_files.rb +1 -5
- data/lib/license_finder/report.rb +26 -0
- data/lib/license_finder/reports/csv_report.rb +58 -0
- data/lib/license_finder/reports/erb_report.rb +61 -0
- data/lib/license_finder/reports/html_report.rb +10 -1
- data/lib/license_finder/reports/markdown_report.rb +7 -1
- data/lib/license_finder/reports/templates/bootstrap.css +9 -0
- data/lib/license_finder/reports/templates/html_report.erb +105 -0
- data/lib/{templates → license_finder/reports/templates}/markdown_report.erb +7 -7
- data/lib/license_finder/reports/text_report.rb +5 -3
- data/lib/license_finder/version.rb +3 -0
- data/license_finder.gemspec +2 -6
- data/release/instructions.md +8 -0
- data/spec/feature_helper.rb +11 -0
- data/spec/fixtures/config/license_finder.yml +3 -0
- data/spec/fixtures/{nested_readme/vendor/README → license_directory/LICENSE/Apache.txt} +0 -0
- data/spec/lib/license_finder/cli/approvals_spec.rb +63 -0
- data/spec/lib/license_finder/cli/dependencies_spec.rb +59 -0
- data/spec/lib/license_finder/cli/ignored_dependencies_spec.rb +47 -0
- data/spec/lib/license_finder/cli/ignored_groups_spec.rb +40 -0
- data/spec/lib/license_finder/cli/licenses_spec.rb +60 -0
- data/spec/lib/license_finder/cli/main_spec.rb +110 -0
- data/spec/lib/license_finder/cli/project_name_spec.rb +40 -0
- data/spec/lib/license_finder/cli/whitelist_spec.rb +58 -0
- data/spec/lib/license_finder/configuration_spec.rb +46 -191
- data/spec/lib/license_finder/decision_applier_spec.rb +65 -0
- data/spec/lib/license_finder/decisions_spec.rb +347 -0
- data/spec/lib/license_finder/license/definitions_spec.rb +1 -7
- data/spec/lib/license_finder/license_spec.rb +2 -30
- data/spec/lib/license_finder/package_manager_spec.rb +22 -0
- data/spec/lib/license_finder/package_managers/bower_package_spec.rb +33 -66
- data/spec/lib/license_finder/package_managers/bundler_package_spec.rb +7 -71
- data/spec/lib/license_finder/package_managers/cocoa_pods_package_spec.rb +8 -11
- data/spec/lib/license_finder/package_managers/gradle_package_spec.rb +28 -32
- data/spec/lib/license_finder/package_managers/gradle_spec.rb +18 -23
- data/spec/lib/license_finder/package_managers/maven_package_spec.rb +20 -43
- data/spec/lib/license_finder/package_managers/npm_package_spec.rb +22 -73
- data/spec/lib/license_finder/package_managers/npm_spec.rb +18 -21
- data/spec/lib/license_finder/package_managers/pip_package_spec.rb +24 -63
- data/spec/lib/license_finder/package_spec.rb +121 -0
- data/spec/lib/license_finder/possible_license_file_spec.rb +2 -3
- data/spec/lib/license_finder/possible_license_files_spec.rb +18 -22
- data/spec/lib/license_finder/reports/csv_report_spec.rb +26 -0
- data/spec/lib/license_finder/reports/html_report_spec.rb +39 -22
- data/spec/lib/license_finder/reports/markdown_report_spec.rb +8 -16
- data/spec/lib/license_finder/reports/text_report_spec.rb +21 -12
- data/spec/spec_helper.rb +1 -4
- data/spec/support/shared_examples_for_package.rb +0 -11
- data/spec/support/shared_examples_for_package_manager.rb +1 -0
- data/spec/support/stdout_helpers.rb +4 -11
- metadata +73 -158
- data/db/migrate/201303290935_create_dependencies.rb +0 -14
- data/db/migrate/201303291155_create_licenses.rb +0 -13
- data/db/migrate/201303291402_create_approvals.rb +0 -13
- data/db/migrate/201303291456_create_ancestries.rb +0 -9
- data/db/migrate/201303291519_create_bundler_groups.rb +0 -13
- data/db/migrate/201303291720_move_manual_from_approvals_to_licenses.rb +0 -11
- data/db/migrate/201303291753_allow_null_license_names.rb +0 -7
- data/db/migrate/201304011027_allow_null_dependency_version.rb +0 -7
- data/db/migrate/201304020947_change_table_name_licenses_to_license_aliases.rb +0 -5
- data/db/migrate/201304181524_add_manual_to_dependencies.rb +0 -7
- data/db/migrate/201307250917_add_license_manual_to_dependencies.rb +0 -7
- data/db/migrate/201307251004_data_fix_manual_licenses.rb +0 -15
- data/db/migrate/201307251107_reassociate_license.rb +0 -23
- data/db/migrate/201307251340_remove_manual_from_license_aliases.rb +0 -7
- data/db/migrate/201311192002_add_manually_approved_to_dependencies.rb +0 -7
- data/db/migrate/201311192003_reassociate_manual_approval.rb +0 -13
- data/db/migrate/201311192010_drop_approvals.rb +0 -5
- data/db/migrate/201401302113_re_reassociate_license.rb +0 -23
- data/db/migrate/201403181732_rename_manual_fields.rb +0 -10
- data/db/migrate/201403190028_add_manual_approvals.rb +0 -22
- data/db/migrate/201403191419_add_timestamps_to_manual_approvals.rb +0 -15
- data/db/migrate/201403191645_remove_license_aliases.rb +0 -23
- data/db/migrate/201410031451_rename_dependency_license_name.rb +0 -6
- data/features/cli.feature +0 -37
- data/features/cocoapods_dependencies.feature +0 -10
- data/features/configure_bundler_groups.feature +0 -23
- data/features/configure_ignore_dependencies.feature +0 -16
- data/features/configure_project_name.feature +0 -10
- data/features/configure_whitelist.feature +0 -27
- data/features/gradle_dependencies.feature +0 -9
- data/features/manually_added.feature +0 -19
- data/features/manually_approved.feature +0 -10
- data/features/manually_assigned_license.feature +0 -16
- data/features/maven_dependencies.feature +0 -9
- data/features/multiple_licenses.feature +0 -9
- data/features/node_dependencies.feature +0 -9
- data/features/python_dependencies.feature +0 -9
- data/features/report_csv.feature +0 -15
- data/features/report_html.feature +0 -24
- data/features/step_definitions/cli_steps.rb +0 -51
- data/features/step_definitions/cocoapod_steps.rb +0 -8
- data/features/step_definitions/configure_bundler_groups_steps.rb +0 -30
- data/features/step_definitions/configure_ignore_dependencies.rb +0 -35
- data/features/step_definitions/configure_project_name_steps.rb +0 -3
- data/features/step_definitions/configure_whitelist_steps.rb +0 -45
- data/features/step_definitions/gradle_steps.rb +0 -8
- data/features/step_definitions/manually_added_steps.rb +0 -28
- data/features/step_definitions/manually_approved_steps.rb +0 -24
- data/features/step_definitions/manually_assigned_license_steps.rb +0 -34
- data/features/step_definitions/maven_steps.rb +0 -8
- data/features/step_definitions/multiple_licenses_steps.rb +0 -14
- data/features/step_definitions/node_steps.rb +0 -8
- data/features/step_definitions/python_steps.rb +0 -8
- data/features/step_definitions/report_csv_steps.rb +0 -20
- data/features/step_definitions/report_html_steps.rb +0 -60
- data/features/step_definitions/shared_steps.rb +0 -307
- data/lib/data/license_finder.example.yml +0 -12
- data/lib/license_finder/dependency_manager.rb +0 -92
- data/lib/license_finder/package_saver.rb +0 -44
- data/lib/license_finder/reports/dependency_report.rb +0 -34
- data/lib/license_finder/reports/detailed_text_report.rb +0 -19
- data/lib/license_finder/reports/formatted_report.rb +0 -40
- data/lib/license_finder/reports/reporter.rb +0 -27
- data/lib/license_finder/tables.rb +0 -9
- data/lib/license_finder/tables/bundler_group.rb +0 -7
- data/lib/license_finder/tables/dependency.rb +0 -113
- data/lib/license_finder/tables/manual_approval.rb +0 -13
- data/lib/license_finder/yml_to_sql.rb +0 -117
- data/lib/templates/html_report.erb +0 -117
- data/lib/templates/text_report.erb +0 -3
- data/release/gem_version.rb +0 -3
- data/release/manual_instructions.md +0 -29
- data/release/publish.sh +0 -32
- data/spec/fixtures/APACHE-2-LICENSE +0 -202
- data/spec/fixtures/GPLv2 +0 -339
- data/spec/fixtures/ISC-LICENSE +0 -10
- data/spec/fixtures/MIT-LICENSE +0 -22
- data/spec/fixtures/MIT-LICENSE-with-varied-disclaimer +0 -22
- data/spec/fixtures/README-with-MIT-LICENSE +0 -222
- data/spec/fixtures/license_directory/LICENSE/BSD-2-Clause.txt +0 -25
- data/spec/fixtures/license_directory/LICENSE/GPL-2.0.txt +0 -339
- data/spec/fixtures/license_directory/LICENSE/LICENSE +0 -191
- data/spec/fixtures/license_directory/LICENSE/MIT.txt +0 -21
- data/spec/fixtures/license_directory/LICENSE/RUBY.txt +0 -60
- data/spec/fixtures/mit_licensed_gem/LICENSE +0 -22
- data/spec/fixtures/other_licensed_gem/LICENSE +0 -3
- data/spec/fixtures/readme/Project ReadMe b/data/spec/fixtures/readme/Project → ReadMe +0 -0
- data/spec/fixtures/readme/README +0 -0
- data/spec/fixtures/readme/Readme.markdown +0 -0
- data/spec/lib/license_finder/cli_spec.rb +0 -298
- data/spec/lib/license_finder/dependency_manager_spec.rb +0 -198
- data/spec/lib/license_finder/package_saver_spec.rb +0 -82
- data/spec/lib/license_finder/reports/detailed_text_report_spec.rb +0 -33
- data/spec/lib/license_finder/reports/reporter_spec.rb +0 -33
- data/spec/lib/license_finder/tables/dependency_spec.rb +0 -196
- data/spec/lib/license_finder/yml_to_sql_spec.rb +0 -123
- data/spec/lib/license_finder_spec.rb +0 -16
@@ -0,0 +1,46 @@
|
|
1
|
+
module LicenseFinder
|
2
|
+
class DecisionApplier
|
3
|
+
def initialize(options)
|
4
|
+
@decisions = options.fetch(:decisions)
|
5
|
+
@packages = options.fetch(:packages)
|
6
|
+
end
|
7
|
+
|
8
|
+
def unapproved
|
9
|
+
acknowledged.reject(&:approved?)
|
10
|
+
end
|
11
|
+
|
12
|
+
def acknowledged
|
13
|
+
base_packages = decisions.packages + packages
|
14
|
+
base_packages.
|
15
|
+
reject { |package| ignored?(package) }.
|
16
|
+
map { |package| with_decided_licenses(package) }.
|
17
|
+
map { |package| with_approval(package) }
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
attr_reader :packages, :decisions
|
23
|
+
|
24
|
+
def ignored?(package)
|
25
|
+
decisions.ignored?(package.name) ||
|
26
|
+
package.groups.any? { |group| decisions.ignored_group?(group) }
|
27
|
+
end
|
28
|
+
|
29
|
+
def with_decided_licenses(package)
|
30
|
+
decisions.licenses_of(package.name).each do |license|
|
31
|
+
package.decide_on_license license
|
32
|
+
end
|
33
|
+
package
|
34
|
+
end
|
35
|
+
|
36
|
+
def with_approval(package)
|
37
|
+
if decisions.approved?(package.name)
|
38
|
+
package.approved_manually!(decisions.approval_of(package.name))
|
39
|
+
elsif package.licenses.any? { |license| decisions.whitelisted?(license) }
|
40
|
+
package.whitelisted!
|
41
|
+
end
|
42
|
+
package
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
@@ -0,0 +1,174 @@
|
|
1
|
+
module LicenseFinder
|
2
|
+
class Decisions
|
3
|
+
######
|
4
|
+
# READ
|
5
|
+
######
|
6
|
+
|
7
|
+
attr_reader :packages, :whitelisted, :ignored, :ignored_groups, :project_name
|
8
|
+
|
9
|
+
def licenses_of(name)
|
10
|
+
@licenses[name]
|
11
|
+
end
|
12
|
+
|
13
|
+
def approval_of(name)
|
14
|
+
@approvals[name]
|
15
|
+
end
|
16
|
+
|
17
|
+
def approved?(name)
|
18
|
+
@approvals.has_key?(name)
|
19
|
+
end
|
20
|
+
|
21
|
+
def whitelisted?(lic)
|
22
|
+
@whitelisted.include?(lic)
|
23
|
+
end
|
24
|
+
|
25
|
+
def ignored?(name)
|
26
|
+
@ignored.include?(name)
|
27
|
+
end
|
28
|
+
|
29
|
+
def ignored_group?(name)
|
30
|
+
@ignored_groups.include?(name)
|
31
|
+
end
|
32
|
+
|
33
|
+
#######
|
34
|
+
# WRITE
|
35
|
+
#######
|
36
|
+
|
37
|
+
TXN = Struct.new(:who, :why, :safe_when) do
|
38
|
+
def self.from_hash(txn)
|
39
|
+
new(txn[:who], txn[:why], txn[:when])
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def initialize
|
44
|
+
@decisions = []
|
45
|
+
@packages = Set.new
|
46
|
+
@licenses = Hash.new { |h, k| h[k] = Set.new }
|
47
|
+
@approvals = {}
|
48
|
+
@whitelisted = Set.new
|
49
|
+
@ignored = Set.new
|
50
|
+
@ignored_groups = Set.new
|
51
|
+
end
|
52
|
+
|
53
|
+
def add_package(name, version, txn = {})
|
54
|
+
@decisions << [:add_package, name, version, txn]
|
55
|
+
@packages << ManualPackage.new(name, version)
|
56
|
+
self
|
57
|
+
end
|
58
|
+
|
59
|
+
def remove_package(name, txn = {})
|
60
|
+
@decisions << [:remove_package, name, txn]
|
61
|
+
@packages.delete(ManualPackage.new(name))
|
62
|
+
self
|
63
|
+
end
|
64
|
+
|
65
|
+
def license(name, lic, txn = {})
|
66
|
+
@decisions << [:license, name, lic, txn]
|
67
|
+
@licenses[name] << License.find_by_name(lic)
|
68
|
+
self
|
69
|
+
end
|
70
|
+
|
71
|
+
def unlicense(name, lic, txn= {})
|
72
|
+
@decisions << [:unlicense, name, lic, txn]
|
73
|
+
@licenses[name].delete(License.find_by_name(lic))
|
74
|
+
self
|
75
|
+
end
|
76
|
+
|
77
|
+
def approve(name, txn = {})
|
78
|
+
@decisions << [:approve, name, txn]
|
79
|
+
@approvals[name] = TXN.from_hash(txn)
|
80
|
+
self
|
81
|
+
end
|
82
|
+
|
83
|
+
def unapprove(name, txn = {})
|
84
|
+
@decisions << [:unapprove, name, txn]
|
85
|
+
@approvals.delete(name)
|
86
|
+
self
|
87
|
+
end
|
88
|
+
|
89
|
+
def whitelist(lic, txn = {})
|
90
|
+
@decisions << [:whitelist, lic, txn]
|
91
|
+
@whitelisted << License.find_by_name(lic)
|
92
|
+
self
|
93
|
+
end
|
94
|
+
|
95
|
+
def unwhitelist(lic, txn = {})
|
96
|
+
@decisions << [:unwhitelist, lic, txn]
|
97
|
+
@whitelisted.delete(License.find_by_name(lic))
|
98
|
+
self
|
99
|
+
end
|
100
|
+
|
101
|
+
def ignore(name, txn = {})
|
102
|
+
@decisions << [:ignore, name, txn]
|
103
|
+
@ignored << name
|
104
|
+
self
|
105
|
+
end
|
106
|
+
|
107
|
+
def heed(name, txn = {})
|
108
|
+
@decisions << [:heed, name, txn]
|
109
|
+
@ignored.delete(name)
|
110
|
+
self
|
111
|
+
end
|
112
|
+
|
113
|
+
def ignore_group(name, txn = {})
|
114
|
+
@decisions << [:ignore_group, name, txn]
|
115
|
+
@ignored_groups << name
|
116
|
+
self
|
117
|
+
end
|
118
|
+
|
119
|
+
def heed_group(name, txn = {})
|
120
|
+
@decisions << [:heed_group, name, txn]
|
121
|
+
@ignored_groups.delete(name)
|
122
|
+
self
|
123
|
+
end
|
124
|
+
|
125
|
+
def name_project(name, txn = {})
|
126
|
+
@decisions << [:name_project, name, txn]
|
127
|
+
@project_name = name
|
128
|
+
self
|
129
|
+
end
|
130
|
+
|
131
|
+
def unname_project(txn = {})
|
132
|
+
@decisions << [:unname_project, txn]
|
133
|
+
@project_name = nil
|
134
|
+
self
|
135
|
+
end
|
136
|
+
|
137
|
+
#########
|
138
|
+
# PERSIST
|
139
|
+
#########
|
140
|
+
|
141
|
+
def self.saved!(file)
|
142
|
+
restore(read!(file))
|
143
|
+
end
|
144
|
+
|
145
|
+
def save!(file)
|
146
|
+
write!(persist, file)
|
147
|
+
end
|
148
|
+
|
149
|
+
def self.restore(persisted)
|
150
|
+
result = new
|
151
|
+
if persisted
|
152
|
+
YAML.load(persisted).each do |action, *args|
|
153
|
+
result.send(action, *args)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
result
|
157
|
+
end
|
158
|
+
|
159
|
+
def persist
|
160
|
+
YAML.dump(@decisions)
|
161
|
+
end
|
162
|
+
|
163
|
+
def self.read!(file)
|
164
|
+
file.read if file.exist?
|
165
|
+
end
|
166
|
+
|
167
|
+
def write!(value, file)
|
168
|
+
file.dirname.mkpath
|
169
|
+
file.open('w+') do |f|
|
170
|
+
f.print value
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
@@ -2,12 +2,12 @@ module LicenseFinder
|
|
2
2
|
class License
|
3
3
|
class << self
|
4
4
|
def all
|
5
|
-
@all ||= Definitions.all
|
5
|
+
@all ||= Definitions.all
|
6
6
|
end
|
7
7
|
|
8
8
|
def find_by_name(name)
|
9
|
-
name ||= "
|
10
|
-
all.detect { |l| l.matches_name? name } || Definitions.build_unrecognized(name
|
9
|
+
name ||= "unknown"
|
10
|
+
all.detect { |l| l.matches_name? name } || Definitions.build_unrecognized(name)
|
11
11
|
end
|
12
12
|
|
13
13
|
def find_by_text(text)
|
@@ -15,20 +15,11 @@ module LicenseFinder
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
autoload :Definitions, "license_finder/license/definitions"
|
19
|
-
autoload :Text, "license_finder/license/text"
|
20
|
-
autoload :Template, "license_finder/license/template"
|
21
|
-
autoload :Matcher, "license_finder/license/matcher"
|
22
|
-
autoload :HeaderMatcher, "license_finder/license/header_matcher"
|
23
|
-
autoload :AnyMatcher, "license_finder/license/any_matcher"
|
24
|
-
autoload :NoneMatcher, "license_finder/license/none_matcher"
|
25
|
-
|
26
18
|
def initialize(settings)
|
27
19
|
@short_name = settings.fetch(:short_name)
|
28
20
|
@pretty_name = settings.fetch(:pretty_name, short_name)
|
29
21
|
@other_names = settings.fetch(:other_names, [])
|
30
22
|
@url = settings.fetch(:url)
|
31
|
-
@whitelisted = settings.fetch(:whitelisted, false)
|
32
23
|
@matcher = settings.fetch(:matcher) { Matcher.from_template(Template.named(short_name)) }
|
33
24
|
end
|
34
25
|
|
@@ -46,14 +37,6 @@ module LicenseFinder
|
|
46
37
|
matcher.matches_text?(text)
|
47
38
|
end
|
48
39
|
|
49
|
-
def whitelisted?
|
50
|
-
@whitelisted
|
51
|
-
end
|
52
|
-
|
53
|
-
def whitelist
|
54
|
-
copy(whitelisted: true)
|
55
|
-
end
|
56
|
-
|
57
40
|
def eql?(other)
|
58
41
|
name == other.name
|
59
42
|
end
|
@@ -70,17 +53,15 @@ module LicenseFinder
|
|
70
53
|
def names
|
71
54
|
([short_name, pretty_name] + other_names).uniq
|
72
55
|
end
|
73
|
-
|
74
|
-
def copy(overrides)
|
75
|
-
settings = {
|
76
|
-
short_name: short_name,
|
77
|
-
pretty_name: pretty_name,
|
78
|
-
other_names: other_names,
|
79
|
-
url: url,
|
80
|
-
whitelisted: whitelisted?,
|
81
|
-
matcher: matcher
|
82
|
-
}
|
83
|
-
self.class.new(settings.merge(overrides))
|
84
|
-
end
|
85
56
|
end
|
86
57
|
end
|
58
|
+
|
59
|
+
require "license_finder/license/text"
|
60
|
+
require "license_finder/license/template"
|
61
|
+
|
62
|
+
require "license_finder/license/matcher"
|
63
|
+
require "license_finder/license/header_matcher"
|
64
|
+
require "license_finder/license/any_matcher"
|
65
|
+
require "license_finder/license/none_matcher"
|
66
|
+
|
67
|
+
require "license_finder/license/definitions"
|
@@ -3,7 +3,7 @@ module LicenseFinder
|
|
3
3
|
module Definitions
|
4
4
|
extend self
|
5
5
|
|
6
|
-
def all
|
6
|
+
def all
|
7
7
|
[
|
8
8
|
apache2,
|
9
9
|
bsd,
|
@@ -15,32 +15,34 @@ module LicenseFinder
|
|
15
15
|
python,
|
16
16
|
ruby,
|
17
17
|
simplifiedbsd
|
18
|
-
]
|
19
|
-
whitelist_if_necessary(license, whitelist)
|
20
|
-
}
|
18
|
+
]
|
21
19
|
end
|
22
20
|
|
23
|
-
def build_unrecognized(name
|
24
|
-
|
21
|
+
def build_unrecognized(name)
|
22
|
+
License.new(
|
25
23
|
short_name: name,
|
26
24
|
url: nil,
|
27
25
|
matcher: NoneMatcher.new
|
28
26
|
)
|
29
|
-
whitelist_if_necessary(result, whitelist)
|
30
27
|
end
|
31
28
|
|
32
29
|
private
|
33
30
|
|
34
|
-
def whitelist_if_necessary(license, whitelist)
|
35
|
-
whitelisted = whitelist.any? { |name| license.matches_name? name }
|
36
|
-
whitelisted ? license.whitelist : license
|
37
|
-
end
|
38
|
-
|
39
31
|
def apache2
|
40
32
|
License.new(
|
41
33
|
short_name: "Apache2",
|
42
34
|
pretty_name: "Apache 2.0",
|
43
|
-
other_names: [
|
35
|
+
other_names: [
|
36
|
+
"Apache-2.0",
|
37
|
+
"Apache Software License",
|
38
|
+
"Apache License 2.0",
|
39
|
+
"Apache License Version 2.0",
|
40
|
+
"Apache Public License 2.0",
|
41
|
+
"The Apache Software License, Version 2.0",
|
42
|
+
"Apache 2",
|
43
|
+
"Apache License",
|
44
|
+
"Apache License, Version 2.0"
|
45
|
+
],
|
44
46
|
url: "http://www.apache.org/licenses/LICENSE-2.0.txt"
|
45
47
|
)
|
46
48
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -9,8 +9,10 @@ module LicenseFinder
|
|
9
9
|
# Additional guidelines are:
|
10
10
|
#
|
11
11
|
# - if you're going to use Package#licenses ...
|
12
|
-
# -
|
13
|
-
#
|
12
|
+
# - and the package spec will report licenses,
|
13
|
+
# pass :spec_licenses in the constructor options
|
14
|
+
# - and the package's files can be searched for licenses
|
15
|
+
# pass :install_path in the constructor options
|
14
16
|
# - else
|
15
17
|
# - implement #licenses
|
16
18
|
#
|
@@ -29,15 +31,70 @@ module LicenseFinder
|
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
32
|
-
def initialize options={}
|
34
|
+
def initialize(name, version = nil, options={})
|
33
35
|
@logger = options[:logger] || LicenseFinder::Logger::Default.new
|
36
|
+
|
37
|
+
@name = name
|
38
|
+
@version = version
|
39
|
+
@summary = options[:summary] || ""
|
40
|
+
@description = options[:description] || ""
|
41
|
+
@homepage = options[:homepage] || ""
|
42
|
+
@children = options[:children] || []
|
43
|
+
@parents = Set.new # will be figured out later by package manager
|
44
|
+
@groups = options[:groups] || []
|
45
|
+
|
46
|
+
## APPROVAL
|
47
|
+
@whitelisted = false
|
48
|
+
@manual_approval = nil
|
49
|
+
|
50
|
+
## LICENSING
|
51
|
+
@license_names_from_spec = options[:spec_licenses] || []
|
52
|
+
@install_path = options[:install_path]
|
53
|
+
@missing = options[:missing] || false
|
54
|
+
@decided_licenses = Set.new
|
55
|
+
end
|
56
|
+
|
57
|
+
attr_reader :name, :version,
|
58
|
+
:summary, :description, :homepage,
|
59
|
+
:children, :parents, :groups
|
60
|
+
|
61
|
+
## APPROVAL
|
62
|
+
|
63
|
+
def approved_manually!(approval)
|
64
|
+
@manual_approval = approval
|
65
|
+
end
|
66
|
+
|
67
|
+
def whitelisted!
|
68
|
+
@whitelisted = true
|
69
|
+
end
|
70
|
+
|
71
|
+
def approved?
|
72
|
+
approved_manually? || whitelisted?
|
34
73
|
end
|
35
74
|
|
75
|
+
def approved_manually?
|
76
|
+
!@manual_approval.nil?
|
77
|
+
end
|
78
|
+
|
79
|
+
def whitelisted?
|
80
|
+
@whitelisted
|
81
|
+
end
|
82
|
+
|
83
|
+
attr_reader :manual_approval
|
84
|
+
|
85
|
+
## LICENSING
|
86
|
+
|
87
|
+
attr_reader :license_names_from_spec # stubbed in tests, otherwise private
|
88
|
+
attr_reader :install_path # checked in tests, otherwise private
|
89
|
+
|
36
90
|
def licenses
|
37
|
-
@licenses ||=
|
91
|
+
@licenses ||= determine_licenses.to_set
|
38
92
|
end
|
39
93
|
|
40
|
-
def
|
94
|
+
def determine_licenses
|
95
|
+
dl = @decided_licenses
|
96
|
+
return dl if dl.any?
|
97
|
+
|
41
98
|
lfs = licenses_from_spec
|
42
99
|
return lfs if lfs.any?
|
43
100
|
|
@@ -47,6 +104,10 @@ module LicenseFinder
|
|
47
104
|
[default_license].to_set
|
48
105
|
end
|
49
106
|
|
107
|
+
def decide_on_license(license)
|
108
|
+
@decided_licenses << license
|
109
|
+
end
|
110
|
+
|
50
111
|
def licenses_from_spec
|
51
112
|
license_names_from_spec.map do |name|
|
52
113
|
License.find_by_name(name).tap do |license|
|
@@ -71,8 +132,17 @@ module LicenseFinder
|
|
71
132
|
License.find_by_name nil
|
72
133
|
end
|
73
134
|
|
74
|
-
def
|
75
|
-
|
135
|
+
def missing?
|
136
|
+
@missing
|
76
137
|
end
|
77
138
|
end
|
78
139
|
end
|
140
|
+
|
141
|
+
require 'license_finder/package_managers/manual_package'
|
142
|
+
require 'license_finder/package_managers/bower_package'
|
143
|
+
require 'license_finder/package_managers/bundler_package'
|
144
|
+
require 'license_finder/package_managers/pip_package'
|
145
|
+
require 'license_finder/package_managers/npm_package'
|
146
|
+
require 'license_finder/package_managers/maven_package'
|
147
|
+
require 'license_finder/package_managers/gradle_package'
|
148
|
+
require 'license_finder/package_managers/cocoa_pods_package'
|