license_finder 3.0.4 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +56 -0
- data/CHANGELOG.md +29 -2
- data/CONTRIBUTING.md +5 -1
- data/Dockerfile +33 -10
- data/Gemfile +2 -2
- data/README.md +27 -5
- data/Rakefile +15 -21
- data/ci/pipelines/pipeline.yml.erb +40 -6
- data/ci/pipelines/release.yml +11 -5
- data/ci/scripts/containerize-tests.sh +16 -0
- data/ci/scripts/run-rubocop.sh +8 -0
- data/ci/scripts/run-tests.sh +22 -0
- data/ci/scripts/test.ps1 +81 -0
- data/ci/tasks/build-windows.yml +6 -0
- data/ci/tasks/build.yml +2 -2
- data/ci/tasks/rubocop.yml +13 -0
- data/features/features/cli/cli_spec.rb +8 -8
- data/features/features/configure/add_dependencies_spec.rb +7 -7
- data/features/features/configure/approve_dependencies_spec.rb +15 -15
- data/features/features/configure/assign_licenses_spec.rb +4 -4
- data/features/features/configure/blacklist_licenses_spec.rb +3 -3
- data/features/features/configure/ignore_dependencies_spec.rb +3 -3
- data/features/features/configure/ignore_groups_spec.rb +4 -4
- data/features/features/configure/name_project_spec.rb +4 -4
- data/features/features/configure/set_project_path_spec.rb +2 -2
- data/features/features/configure/whitelist_licenses_spec.rb +4 -4
- data/features/features/package_managers/bower_spec.rb +3 -3
- data/features/features/package_managers/carthage_spec.rb +14 -0
- data/features/features/package_managers/cocoapods_spec.rb +3 -3
- data/features/features/package_managers/conan_spec.rb +11 -0
- data/features/features/package_managers/dep_spec.rb +15 -0
- data/features/features/package_managers/glide_spec.rb +14 -0
- data/features/features/package_managers/govendor_spec.rb +15 -0
- data/features/features/package_managers/gradle_spec.rb +1 -1
- data/features/features/package_managers/gvt_spec.rb +14 -0
- data/features/features/package_managers/maven_spec.rb +2 -3
- data/features/features/package_managers/mix_spec.rb +16 -0
- data/features/features/package_managers/npm_spec.rb +3 -3
- data/features/features/package_managers/nuget_spec.rb +4 -4
- data/features/features/package_managers/pip_spec.rb +2 -2
- data/features/features/package_managers/rebar_spec.rb +3 -3
- data/features/features/package_managers/yarn_spec.rb +14 -0
- data/features/features/report/composite_spec.rb +1 -1
- data/features/features/report/csv_spec.rb +3 -3
- data/features/features/report/diff_spec.rb +20 -10
- data/features/features/report/html_spec.rb +10 -10
- data/features/features/report/subproject_spec.rb +15 -4
- data/features/fixtures/Cartfile +1 -0
- data/features/fixtures/Podfile +1 -1
- data/features/fixtures/alternate-build-file-gradle/build-alt.gradle +5 -15
- data/features/fixtures/build.gradle +5 -15
- data/features/fixtures/conanfile.txt +11 -0
- data/features/fixtures/file-based-libs-gradle/build.gradle +5 -7
- data/features/fixtures/gopath_dep/src/foo-dep/Gopkg.lock +9 -0
- data/features/fixtures/gopath_dep/src/foo-dep/Gopkg.toml +7 -0
- data/features/fixtures/gopath_dep/src/foo-dep/bar/bar.go +10 -0
- data/features/fixtures/gopath_dep/src/foo-dep/foo.go +7 -0
- data/features/fixtures/gopath_glide/src/glide.lock +9 -0
- data/features/fixtures/gopath_glide/src/glide.yaml +6 -0
- data/features/fixtures/gopath_govendor/src/vendor/vendor.json +19 -0
- data/features/fixtures/gopath_gvt/src/vendor/manifest +22 -0
- data/features/fixtures/gradle-wrapper/build.gradle +5 -15
- data/features/fixtures/gradle-wrapper/gradlew +6 -1
- data/features/fixtures/gradle-wrapper/gradlew.bat +9 -1
- data/features/fixtures/mix.exs +22 -0
- data/features/fixtures/multi-module-gradle/build.gradle +7 -15
- data/features/fixtures/single-module-gradle/build.gradle +5 -15
- data/features/support/testing_dsl.rb +155 -43
- data/lib/license_finder.rb +4 -3
- data/lib/license_finder/cli.rb +0 -3
- data/lib/license_finder/cli/approvals.rb +3 -3
- data/lib/license_finder/cli/base.rb +11 -8
- data/lib/license_finder/cli/blacklist.rb +7 -7
- data/lib/license_finder/cli/dependencies.rb +8 -8
- data/lib/license_finder/cli/ignored_dependencies.rb +4 -4
- data/lib/license_finder/cli/ignored_groups.rb +4 -4
- data/lib/license_finder/cli/licenses.rb +2 -2
- data/lib/license_finder/cli/main.rb +59 -39
- data/lib/license_finder/cli/makes_decisions.rb +2 -2
- data/lib/license_finder/cli/patched_thor.rb +6 -7
- data/lib/license_finder/cli/project_name.rb +5 -6
- data/lib/license_finder/cli/whitelist.rb +7 -7
- data/lib/license_finder/configuration.rb +15 -4
- data/lib/license_finder/core.rb +20 -4
- data/lib/license_finder/decision_applier.rb +0 -1
- data/lib/license_finder/decisions.rb +12 -14
- data/lib/license_finder/diff.rb +33 -31
- data/lib/license_finder/license.rb +13 -9
- data/lib/license_finder/license/definitions.rb +55 -55
- data/lib/license_finder/license/none_matcher.rb +1 -1
- data/lib/license_finder/license/template.rb +1 -1
- data/lib/license_finder/license/text.rb +0 -1
- data/lib/license_finder/license_aggregator.rb +1 -0
- data/lib/license_finder/logger.rb +18 -61
- data/lib/license_finder/package.rb +25 -11
- data/lib/license_finder/package_delta.rb +3 -6
- data/lib/license_finder/package_manager.rb +77 -34
- data/lib/license_finder/package_managers/bower.rb +8 -8
- data/lib/license_finder/package_managers/bower_package.rb +12 -12
- data/lib/license_finder/package_managers/bundler.rb +21 -9
- data/lib/license_finder/package_managers/bundler_package.rb +1 -1
- data/lib/license_finder/package_managers/carthage.rb +66 -0
- data/lib/license_finder/package_managers/carthage_package.rb +16 -0
- data/lib/license_finder/package_managers/cocoa_pods.rb +13 -13
- data/lib/license_finder/package_managers/cocoa_pods_package.rb +1 -1
- data/lib/license_finder/package_managers/conan.rb +26 -0
- data/lib/license_finder/package_managers/conan_info_parser.rb +74 -0
- data/lib/license_finder/package_managers/conan_package.rb +17 -0
- data/lib/license_finder/package_managers/dep.rb +33 -0
- data/lib/license_finder/package_managers/glide.rb +30 -0
- data/lib/license_finder/package_managers/{go_vendor.rb → go_15vendorexperiment.rb} +19 -24
- data/lib/license_finder/package_managers/go_dep.rb +15 -12
- data/lib/license_finder/package_managers/go_package.rb +15 -13
- data/lib/license_finder/package_managers/go_workspace.rb +39 -34
- data/lib/license_finder/package_managers/govendor.rb +32 -0
- data/lib/license_finder/package_managers/gradle.rb +16 -16
- data/lib/license_finder/package_managers/gradle_package.rb +8 -8
- data/lib/license_finder/package_managers/gvt.rb +61 -0
- data/lib/license_finder/package_managers/maven.rb +17 -18
- data/lib/license_finder/package_managers/maven_package.rb +4 -6
- data/lib/license_finder/package_managers/merged_package.rb +25 -2
- data/lib/license_finder/package_managers/mix.rb +51 -0
- data/lib/license_finder/package_managers/mix_package.rb +7 -0
- data/lib/license_finder/package_managers/npm.rb +8 -32
- data/lib/license_finder/package_managers/npm_package.rb +51 -48
- data/lib/license_finder/package_managers/nuget.rb +30 -40
- data/lib/license_finder/package_managers/pip.rb +11 -11
- data/lib/license_finder/package_managers/pip_package.rb +8 -8
- data/lib/license_finder/package_managers/rebar.rb +11 -11
- data/lib/license_finder/package_managers/yarn.rb +62 -0
- data/lib/license_finder/packages/activation.rb +2 -2
- data/lib/license_finder/packages/license_files.rb +6 -6
- data/lib/license_finder/packages/licensing.rb +8 -10
- data/lib/license_finder/packages/manual_package.rb +2 -2
- data/lib/license_finder/project_finder.rb +6 -5
- data/lib/license_finder/report.rb +1 -0
- data/lib/license_finder/reports/csv_report.rb +4 -4
- data/lib/license_finder/reports/diff_report.rb +2 -2
- data/lib/license_finder/reports/erb_report.rb +2 -4
- data/lib/license_finder/reports/html_report.rb +2 -2
- data/lib/license_finder/reports/markdown_report.rb +1 -1
- data/lib/license_finder/reports/merged_report.rb +1 -1
- data/lib/license_finder/reports/text_report.rb +3 -5
- data/lib/license_finder/shared_helpers/cmd.rb +11 -0
- data/lib/license_finder/version.rb +1 -1
- data/license_finder-2.1.2.gem +0 -0
- data/license_finder.gemspec +38 -38
- metadata +84 -118
- data/ci/scripts/test.sh +0 -26
- data/ci/tasks/create-source-archives.yml +0 -23
- data/spec/dummy_app/Gemfile +0 -6
- data/spec/fixtures/all_pms/.envrc +0 -1
- data/spec/fixtures/all_pms/.nuget/.keep +0 -0
- data/spec/fixtures/all_pms/Gemfile +0 -0
- data/spec/fixtures/all_pms/Godeps/Godeps.json +0 -0
- data/spec/fixtures/all_pms/Podfile +0 -0
- data/spec/fixtures/all_pms/bower.json +0 -0
- data/spec/fixtures/all_pms/build.gradle +0 -0
- data/spec/fixtures/all_pms/package.json +0 -0
- data/spec/fixtures/all_pms/pom.xml +0 -0
- data/spec/fixtures/all_pms/rebar.config +0 -0
- data/spec/fixtures/all_pms/requirements.txt +0 -0
- data/spec/fixtures/all_pms/vendor/.gitkeep +0 -0
- data/spec/fixtures/composite/Gemfile +0 -0
- data/spec/fixtures/composite/nested_project/.envrc +0 -8
- data/spec/fixtures/composite/nested_project/src/github.com/pivotal/foo/Godeps/Godeps.json +0 -16
- data/spec/fixtures/composite/nested_project/src/github.com/pivotal/foo/Godeps/Readme +0 -5
- data/spec/fixtures/composite/nested_project/src/github.com/pivotal/foo/foo.go +0 -6
- data/spec/fixtures/composite/not_a_project/DONTREADME.md +0 -0
- data/spec/fixtures/composite/project1/Gemfile +0 -0
- data/spec/fixtures/composite/project2/package.json +0 -0
- data/spec/fixtures/config/license_finder.yml +0 -5
- data/spec/fixtures/license_directory/COPYING +0 -1
- data/spec/fixtures/license_directory/LICENSE/MIT.txt +0 -1
- data/spec/fixtures/license_directory/LICENSE/lib/unrelated.txt +0 -2
- data/spec/fixtures/license_names/COPYING.txt +0 -1
- data/spec/fixtures/license_names/LICENSE +0 -1
- data/spec/fixtures/license_names/Licence.rdoc +0 -1
- data/spec/fixtures/license_names/Mit-License +0 -1
- data/spec/fixtures/license_names/README.rdoc +0 -1
- data/spec/fixtures/nested_gem/vendor/LICENSE +0 -1
- data/spec/fixtures/npm-circular-dependencies/npm-list.json +0 -5339
- data/spec/fixtures/npm-circular-dependencies/package.json +0 -5
- data/spec/fixtures/npm-circular-licenses/npm-list.json +0 -7597
- data/spec/fixtures/npm-circular-licenses/package.json +0 -23
- data/spec/fixtures/npm-licenses-string/npm-list.json +0 -7597
- data/spec/fixtures/npm-licenses-string/package.json +0 -23
- data/spec/fixtures/npm-recursive-dependencies/npm-list.json +0 -5158
- data/spec/fixtures/npm-recursive-dependencies/package.json +0 -15
- data/spec/fixtures/npm-stack-too-deep/npm-list.json +0 -13464
- data/spec/fixtures/npm-stack-too-deep/package.json +0 -5
- data/spec/fixtures/utf8_gem/README +0 -210
- data/spec/lib/license_finder/cli/approvals_spec.rb +0 -71
- data/spec/lib/license_finder/cli/blacklist_spec.rb +0 -58
- data/spec/lib/license_finder/cli/dependencies_spec.rb +0 -73
- data/spec/lib/license_finder/cli/ignored_dependencies_spec.rb +0 -47
- data/spec/lib/license_finder/cli/ignored_groups_spec.rb +0 -40
- data/spec/lib/license_finder/cli/licenses_spec.rb +0 -60
- data/spec/lib/license_finder/cli/main_spec.rb +0 -243
- data/spec/lib/license_finder/cli/project_name_spec.rb +0 -40
- data/spec/lib/license_finder/cli/whitelist_spec.rb +0 -58
- data/spec/lib/license_finder/configuration_spec.rb +0 -115
- data/spec/lib/license_finder/core_spec.rb +0 -54
- data/spec/lib/license_finder/decision_applier_spec.rb +0 -219
- data/spec/lib/license_finder/decisions_spec.rb +0 -408
- data/spec/lib/license_finder/diff_spec.rb +0 -129
- data/spec/lib/license_finder/license/definitions_spec.rb +0 -177
- data/spec/lib/license_finder/license_aggregator_spec.rb +0 -61
- data/spec/lib/license_finder/license_spec.rb +0 -106
- data/spec/lib/license_finder/package_delta_spec.rb +0 -18
- data/spec/lib/license_finder/package_manager_spec.rb +0 -62
- data/spec/lib/license_finder/package_managers/bower_package_spec.rb +0 -71
- data/spec/lib/license_finder/package_managers/bower_spec.rb +0 -39
- data/spec/lib/license_finder/package_managers/bundler_package_spec.rb +0 -35
- data/spec/lib/license_finder/package_managers/bundler_spec.rb +0 -56
- data/spec/lib/license_finder/package_managers/cocoa_pods_package_spec.rb +0 -48
- data/spec/lib/license_finder/package_managers/cocoa_pods_spec.rb +0 -59
- data/spec/lib/license_finder/package_managers/go_dep_spec.rb +0 -126
- data/spec/lib/license_finder/package_managers/go_package_spec.rb +0 -33
- data/spec/lib/license_finder/package_managers/go_vendor_spec.rb +0 -144
- data/spec/lib/license_finder/package_managers/go_workspace_spec.rb +0 -286
- data/spec/lib/license_finder/package_managers/gradle_package_spec.rb +0 -80
- data/spec/lib/license_finder/package_managers/gradle_spec.rb +0 -180
- data/spec/lib/license_finder/package_managers/maven_package_spec.rb +0 -63
- data/spec/lib/license_finder/package_managers/maven_spec.rb +0 -128
- data/spec/lib/license_finder/package_managers/merged_package_spec.rb +0 -60
- data/spec/lib/license_finder/package_managers/npm_package_spec.rb +0 -57
- data/spec/lib/license_finder/package_managers/npm_spec.rb +0 -253
- data/spec/lib/license_finder/package_managers/nuget_package_spec.rb +0 -9
- data/spec/lib/license_finder/package_managers/nuget_spec.rb +0 -157
- data/spec/lib/license_finder/package_managers/pip_package_spec.rb +0 -87
- data/spec/lib/license_finder/package_managers/pip_spec.rb +0 -47
- data/spec/lib/license_finder/package_managers/rebar_package_spec.rb +0 -24
- data/spec/lib/license_finder/package_managers/rebar_spec.rb +0 -50
- data/spec/lib/license_finder/package_spec.rb +0 -179
- data/spec/lib/license_finder/packages/activation_spec.rb +0 -41
- data/spec/lib/license_finder/packages/license_files_spec.rb +0 -46
- data/spec/lib/license_finder/packages/licensing_spec.rb +0 -1
- data/spec/lib/license_finder/packages/possible_license_file_spec.rb +0 -38
- data/spec/lib/license_finder/project_finder_spec.rb +0 -33
- data/spec/lib/license_finder/reports/csv_report_spec.rb +0 -70
- data/spec/lib/license_finder/reports/diff_report_spec.rb +0 -56
- data/spec/lib/license_finder/reports/html_report_spec.rb +0 -101
- data/spec/lib/license_finder/reports/markdown_report_spec.rb +0 -45
- data/spec/lib/license_finder/reports/merged_report_spec.rb +0 -21
- data/spec/lib/license_finder/reports/text_report_spec.rb +0 -43
- data/spec/spec_helper.rb +0 -27
- data/spec/support/shared_examples_for_package_manager.rb +0 -52
- data/spec/support/stdout_helpers.rb +0 -31
- data/spec/support/test_fixtures.rb +0 -7
@@ -1,87 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module LicenseFinder
|
4
|
-
describe PipPackage do
|
5
|
-
subject do
|
6
|
-
make_package({
|
7
|
-
"summary" => "summary",
|
8
|
-
"description" => "description",
|
9
|
-
"home_page" => "homepage"
|
10
|
-
})
|
11
|
-
end
|
12
|
-
|
13
|
-
def make_package(pypi_def)
|
14
|
-
described_class.new('jasmine', '1.3.1', pypi_def, install_path: "jasmine/install/path", children: ["achild"])
|
15
|
-
end
|
16
|
-
|
17
|
-
its(:name) { should == "jasmine" }
|
18
|
-
its(:version) { should == "1.3.1" }
|
19
|
-
its(:authors) { should == "" }
|
20
|
-
its(:summary) { should == "summary" }
|
21
|
-
its(:description) { should == "description" }
|
22
|
-
its(:homepage) { should == "homepage" }
|
23
|
-
its(:groups) { should == [] } # TODO: any way to extract install_requires and tests_require from `pip list` or `pip show`?
|
24
|
-
its(:children) { should == ["achild"] }
|
25
|
-
its(:install_path) { should eq "jasmine/install/path" }
|
26
|
-
its(:package_manager) { should eq 'Pip' }
|
27
|
-
|
28
|
-
|
29
|
-
describe '#license_names_from_spec' do
|
30
|
-
describe "with no pypi info" do
|
31
|
-
it "is empty" do
|
32
|
-
subject = make_package({})
|
33
|
-
|
34
|
-
expect(subject.license_names_from_spec).to be_empty
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe "with valid pypi license" do
|
39
|
-
it "returns the license from 'license' preferentially" do
|
40
|
-
data = { "license" => "MIT", "classifiers" => [ 'License :: OSI Approved :: Apache 2.0 License' ] }
|
41
|
-
|
42
|
-
subject = make_package(data)
|
43
|
-
|
44
|
-
expect(subject.license_names_from_spec).to eq ['MIT']
|
45
|
-
end
|
46
|
-
|
47
|
-
context "when there's no explicit license" do
|
48
|
-
it "returns the license from the 'classifiers' if there is only one" do
|
49
|
-
data = { "classifiers" => [ 'License :: OSI Approved :: Apache 2.0 License' ] }
|
50
|
-
|
51
|
-
subject = make_package(data)
|
52
|
-
|
53
|
-
expect(subject.license_names_from_spec).to eq ['Apache 2.0 License']
|
54
|
-
end
|
55
|
-
|
56
|
-
it "returns multiple licenses if there are many in 'classifiers'" do
|
57
|
-
data = { "classifiers" => [ 'License :: OSI Approved :: Apache 2.0 License', 'License :: OSI Approved :: GPL' ] }
|
58
|
-
|
59
|
-
subject = make_package(data)
|
60
|
-
|
61
|
-
expect(subject.license_names_from_spec).to eq ['Apache 2.0 License', 'GPL']
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
context "with blank license" do
|
66
|
-
it "returns the license from the classifier if it exists" do
|
67
|
-
data = { "license" => "", "classifiers" => [ 'License :: OSI Approved :: Apache 2.0 License' ] }
|
68
|
-
|
69
|
-
subject = make_package(data)
|
70
|
-
|
71
|
-
expect(subject.license_names_from_spec).to eq ['Apache 2.0 License']
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
context "with UNKNOWN license" do
|
76
|
-
it "returns the license from the classifier if it exists" do
|
77
|
-
data = { "license" => "UNKNOWN", "classifiers" => [ 'License :: OSI Approved :: Apache 2.0 License' ] }
|
78
|
-
|
79
|
-
subject = make_package(data)
|
80
|
-
|
81
|
-
expect(subject.license_names_from_spec).to eq ['Apache 2.0 License']
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module LicenseFinder
|
4
|
-
describe Pip do
|
5
|
-
let(:pip) { Pip.new }
|
6
|
-
it_behaves_like "a PackageManager"
|
7
|
-
|
8
|
-
describe '.current_packages' do
|
9
|
-
def stub_pip(stdout)
|
10
|
-
allow(pip).to receive("`").with(/license_finder_pip.py/).and_return(stdout)
|
11
|
-
end
|
12
|
-
|
13
|
-
def stub_pypi(name, version, response)
|
14
|
-
stub_request(:get, "https://pypi.python.org/pypi/#{name}/#{version}/json")
|
15
|
-
.to_return(response)
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'fetches data from pip' do
|
19
|
-
stub_pip [
|
20
|
-
{"name" => "jasmine", "version" => "1.3.1", "location" => "jasmine/path", "dependencies" => ["jasmine-core"]},
|
21
|
-
{"name" => "jasmine-core", "version" => "1.3.1", "location" => "jasmine-core/path"}
|
22
|
-
].to_json
|
23
|
-
stub_pypi("jasmine", "1.3.1", status: 200, body: '{}')
|
24
|
-
stub_pypi("jasmine-core", "1.3.1", status: 200, body: '{}')
|
25
|
-
|
26
|
-
expect(pip.current_packages.map { |p| [p.name, p.version, p.install_path.to_s, p.children] }).to eq [
|
27
|
-
["jasmine", "1.3.1", "jasmine/path/jasmine", ["jasmine-core"]],
|
28
|
-
["jasmine-core", "1.3.1", "jasmine-core/path/jasmine-core", []]
|
29
|
-
]
|
30
|
-
end
|
31
|
-
|
32
|
-
it "fetches data from pypi" do
|
33
|
-
stub_pip [{"name" => "jasmine", "version" => "1.3.1", "location" => "jasmine/path"}].to_json
|
34
|
-
stub_pypi("jasmine", "1.3.1", status: 200, body: JSON.generate(info: {summary: "A summary"}))
|
35
|
-
|
36
|
-
expect(pip.current_packages.first.summary).to eq "A summary"
|
37
|
-
end
|
38
|
-
|
39
|
-
it "ignores pypi if it can't find useful info" do
|
40
|
-
stub_pip [{"name" => "jasmine", "version" => "1.3.1", "location" => "jasmine/path"}].to_json
|
41
|
-
stub_pypi("jasmine", "1.3.1", status: 404, body: '')
|
42
|
-
|
43
|
-
expect(pip.current_packages.first.summary).to eq ""
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module LicenseFinder
|
4
|
-
describe RebarPackage do
|
5
|
-
subject do
|
6
|
-
described_class.new(
|
7
|
-
"uuid",
|
8
|
-
"TAG: v1.3.2",
|
9
|
-
install_path: "deps/uuid",
|
10
|
-
homepage: "git://github.com/okeuday/uuid.git"
|
11
|
-
)
|
12
|
-
end
|
13
|
-
|
14
|
-
its(:name) { should == "uuid" }
|
15
|
-
its(:version) { should == "TAG: v1.3.2" }
|
16
|
-
its(:summary) { should eq "" }
|
17
|
-
its(:description) { should == "" }
|
18
|
-
its(:homepage) { should == "git://github.com/okeuday/uuid.git" }
|
19
|
-
its(:groups) { should == [] }
|
20
|
-
its(:children) { should == [] }
|
21
|
-
its(:install_path) { should eq "deps/uuid" }
|
22
|
-
its(:package_manager) { should eq 'Rebar' }
|
23
|
-
end
|
24
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module LicenseFinder
|
4
|
-
describe Rebar do
|
5
|
-
subject { Rebar.new(project_path: Pathname('/fake/path')) }
|
6
|
-
|
7
|
-
it_behaves_like "a PackageManager"
|
8
|
-
|
9
|
-
output = <<-CMDOUTPUT
|
10
|
-
== Sample comment
|
11
|
-
uuid TAG v1.3.2 git://github.com/okeuday/uuid.git
|
12
|
-
jiffy TAG 0.9.0 https://github.com/davisp/jiffy.git
|
13
|
-
CMDOUTPUT
|
14
|
-
|
15
|
-
describe '.current_packages' do
|
16
|
-
before do
|
17
|
-
allow(Dir).to receive(:chdir).with(Pathname('/fake/path')) { |&block| block.call }
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'lists all the current packages' do
|
21
|
-
allow(subject).to receive(:capture).with('rebar list-deps').and_return([output, true])
|
22
|
-
|
23
|
-
current_packages = subject.current_packages
|
24
|
-
expect(current_packages.map(&:name)).to eq(["uuid", "jiffy"])
|
25
|
-
expect(current_packages.map(&:install_path)).to eq([Pathname("deps/uuid"), Pathname("deps/jiffy")])
|
26
|
-
end
|
27
|
-
|
28
|
-
it "fails when command fails" do
|
29
|
-
allow(subject).to receive(:capture).with(/rebar/).and_return(['Some error', false]).once
|
30
|
-
expect { subject.current_packages }.to raise_error(RuntimeError)
|
31
|
-
end
|
32
|
-
|
33
|
-
it "uses custom rebar command, if provided" do
|
34
|
-
rebar = Rebar.new(rebar_command: "rebarfoo", project_path: Pathname('/fake/path'))
|
35
|
-
allow(rebar).to receive(:capture).with(/rebarfoo/).and_return([output, true])
|
36
|
-
|
37
|
-
current_packages = rebar.current_packages
|
38
|
-
expect(current_packages.map(&:name)).to eq(["uuid", "jiffy"])
|
39
|
-
end
|
40
|
-
|
41
|
-
it "uses custom rebar_deps_dir, if provided" do
|
42
|
-
rebar = Rebar.new(rebar_deps_dir: "foo", project_path: Pathname('/fake/path'))
|
43
|
-
allow(rebar).to receive(:capture).with(/rebar/).and_return([output, true])
|
44
|
-
|
45
|
-
current_packages = rebar.current_packages
|
46
|
-
expect(current_packages.map(&:install_path)).to eq([Pathname("foo/uuid"), Pathname("foo/jiffy")])
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,179 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module LicenseFinder
|
4
|
-
describe Package do
|
5
|
-
subject do
|
6
|
-
described_class.new(
|
7
|
-
"a package",
|
8
|
-
"1.3.1",
|
9
|
-
authors: "the authors",
|
10
|
-
summary: "a summary",
|
11
|
-
description: "a description",
|
12
|
-
homepage: "a homepage",
|
13
|
-
groups: %w[dev test],
|
14
|
-
children: %w[child-1 child2],
|
15
|
-
install_path: "some/package/path",
|
16
|
-
spec_licenses: %w[MIT GPL]
|
17
|
-
)
|
18
|
-
end
|
19
|
-
|
20
|
-
its(:name) { should == "a package" }
|
21
|
-
its(:version) { should == "1.3.1" }
|
22
|
-
its(:authors) { should == 'the authors' }
|
23
|
-
its(:summary) { should == "a summary" }
|
24
|
-
its(:description) { should == "a description" }
|
25
|
-
its(:homepage) { should == "a homepage" }
|
26
|
-
its(:groups) { should == %w[dev test] }
|
27
|
-
its(:children) { should == %w[child-1 child2] }
|
28
|
-
its(:install_path) { should eq "some/package/path" }
|
29
|
-
|
30
|
-
it 'has defaults' do
|
31
|
-
subject = described_class.new(nil, nil)
|
32
|
-
expect(subject.name).to be_nil
|
33
|
-
expect(subject.version).to be_nil
|
34
|
-
expect(subject.authors).to eq ""
|
35
|
-
expect(subject.summary).to eq ""
|
36
|
-
expect(subject.description).to eq ""
|
37
|
-
expect(subject.homepage).to eq ""
|
38
|
-
expect(subject.groups).to eq []
|
39
|
-
expect(subject.children).to eq []
|
40
|
-
expect(subject.install_path).to be_nil
|
41
|
-
expect(subject.license_names_from_spec).to eq []
|
42
|
-
expect(subject.licenses.map(&:name)).to eq ['unknown']
|
43
|
-
end
|
44
|
-
|
45
|
-
describe '#licenses' do
|
46
|
-
def stub_license_files(*license_names)
|
47
|
-
license_files = license_names.map do |license_name|
|
48
|
-
double(:file, license: License.find_by_name(license_name), path: "some/path")
|
49
|
-
end
|
50
|
-
allow(LicenseFiles).to receive(:find).with("some/package/path")
|
51
|
-
.and_return(license_files)
|
52
|
-
end
|
53
|
-
|
54
|
-
it "are not required" do
|
55
|
-
subject = described_class.new(nil, nil)
|
56
|
-
expect(subject.licenses.map(&:name)).to eq ['unknown']
|
57
|
-
end
|
58
|
-
|
59
|
-
describe "decided by user" do
|
60
|
-
it "returns all decided licenses" do
|
61
|
-
subject = described_class.new(nil, nil)
|
62
|
-
subject.decide_on_license(License.find_by_name("MIT"))
|
63
|
-
subject.decide_on_license(License.find_by_name("GPL"))
|
64
|
-
expect(subject.licenses.map(&:name)).to match_array ["MIT", "GPL"]
|
65
|
-
end
|
66
|
-
|
67
|
-
it "de-duplicates across license aliases" do
|
68
|
-
subject = described_class.new(nil, nil)
|
69
|
-
subject.decide_on_license(License.find_by_name("MIT"))
|
70
|
-
subject.decide_on_license(License.find_by_name("Expat"))
|
71
|
-
expect(subject.licenses.map(&:name)).to eq ["MIT"]
|
72
|
-
end
|
73
|
-
|
74
|
-
it "trumps licenses from the spec" do
|
75
|
-
subject = described_class.new(nil, nil, spec_licenses: ["GPL"])
|
76
|
-
subject.decide_on_license(License.find_by_name("MIT"))
|
77
|
-
expect(subject.licenses.map(&:name)).to eq ["MIT"]
|
78
|
-
end
|
79
|
-
|
80
|
-
it "trumps licenses from the install path" do
|
81
|
-
stub_license_files 'Detected License'
|
82
|
-
subject = described_class.new(nil, nil, install_path: "some/package/path")
|
83
|
-
subject.decide_on_license(License.find_by_name("MIT"))
|
84
|
-
expect(subject.licenses.map(&:name)).to eq ["MIT"]
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
describe "from the spec" do
|
89
|
-
it "converts the names to licenses" do
|
90
|
-
subject = described_class.new(nil, nil, spec_licenses: ["MIT", "GPL"])
|
91
|
-
expect(subject.licenses.map(&:name)).to match_array ["MIT", "GPL"]
|
92
|
-
end
|
93
|
-
|
94
|
-
it "de-duplicates across license aliases" do
|
95
|
-
subject = described_class.new(nil, nil, spec_licenses: ["MIT", "Expat"])
|
96
|
-
expect(subject.licenses.map(&:name)).to eq ["MIT"]
|
97
|
-
end
|
98
|
-
|
99
|
-
it "trumps licenses from the install path" do
|
100
|
-
stub_license_files 'Detected License'
|
101
|
-
subject = described_class.new(nil, nil, spec_licenses: ["MIT"], install_path: "some/package/path")
|
102
|
-
expect(subject.licenses.map(&:name)).to eq ["MIT"]
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
describe "from the install path" do
|
107
|
-
it "uses the licenses reported by files in the install path" do
|
108
|
-
stub_license_files 'MIT', 'GPL'
|
109
|
-
subject = described_class.new(nil, nil, install_path: "some/package/path")
|
110
|
-
expect(subject.licenses.map(&:name)).to eq ["MIT", "GPL"]
|
111
|
-
end
|
112
|
-
|
113
|
-
it "de-duplicates across license aliases" do
|
114
|
-
stub_license_files 'MIT', 'Expat'
|
115
|
-
subject = described_class.new(nil, nil, install_path: "some/package/path")
|
116
|
-
expect(subject.licenses.map(&:name)).to eq ["MIT"]
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
describe '#blacklisted?' do
|
122
|
-
it 'defaults to false' do
|
123
|
-
expect(subject.blacklisted?).to eq(false)
|
124
|
-
end
|
125
|
-
|
126
|
-
it 'can be set by blacklisted!' do
|
127
|
-
subject.blacklisted!
|
128
|
-
expect(subject.blacklisted?).to eq(true)
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
describe '#approved?' do
|
133
|
-
it 'returns false by default' do
|
134
|
-
expect(subject.approved?).to eq(false)
|
135
|
-
end
|
136
|
-
|
137
|
-
it 'returns true when approved manually' do
|
138
|
-
subject.approved_manually!('I approve of this dependency')
|
139
|
-
expect(subject.approved?).to eq(true)
|
140
|
-
end
|
141
|
-
|
142
|
-
it 'returns true when whitelisted' do
|
143
|
-
subject.whitelisted!
|
144
|
-
expect(subject.approved?).to eq(true)
|
145
|
-
end
|
146
|
-
|
147
|
-
it 'returns false when blacklisted' do
|
148
|
-
subject.blacklisted!
|
149
|
-
expect(subject.approved?).to eq(false)
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
describe '#eql?' do
|
154
|
-
it 'returns true if package name matches' do
|
155
|
-
p1 = Package.new('package', '0.0.1')
|
156
|
-
p2 = Package.new('package', '0.0.1')
|
157
|
-
p3 = Package.new('foo', 'foo')
|
158
|
-
p4 = Package.new('foo', 'foo2')
|
159
|
-
|
160
|
-
expect(p1.eql?(p2)).to be true
|
161
|
-
expect(p1.eql?(p3)).to be false
|
162
|
-
expect(p3.eql?(p4)).to be false
|
163
|
-
|
164
|
-
expect(p1.hash).to eq p2.hash
|
165
|
-
expect(p3.hash).not_to eq p4.hash
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
describe '#<=>' do
|
170
|
-
it 'sorts by name' do
|
171
|
-
p1 = Package.new('bob')
|
172
|
-
p2 = Package.new('jim')
|
173
|
-
p3 = Package.new('dan')
|
174
|
-
|
175
|
-
expect([p2, p1, p3].sort).to eq([p1, p3, p2])
|
176
|
-
end
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module LicenseFinder
|
4
|
-
describe Activation do
|
5
|
-
let(:package) { Package.new("p", nil) }
|
6
|
-
let(:license) { License.find_by_name("l") }
|
7
|
-
let(:activation) { described_class.new(package, license) }
|
8
|
-
|
9
|
-
it "reports that a license has been activated for a package" do
|
10
|
-
subject = Activation::Basic.new(package, license)
|
11
|
-
expect(subject.package).to eq package
|
12
|
-
expect(subject.license).to eq license
|
13
|
-
end
|
14
|
-
|
15
|
-
describe Activation::FromDecision do
|
16
|
-
it "reports that it came from a decision" do
|
17
|
-
expect(activation.sources).to eq ["from decision"]
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe Activation::FromSpec do
|
22
|
-
it "reports that it came from a spec" do
|
23
|
-
expect(activation.sources).to eq ["from spec"]
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe Activation::FromFiles do
|
28
|
-
it "reports that it came from some files" do
|
29
|
-
files = [double(:file, path: "x"), double(:file, path: "y")]
|
30
|
-
activation = described_class.new(package, license, files)
|
31
|
-
expect(activation.sources).to eq ["from file 'x'", "from file 'y'"]
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe Activation::None do
|
36
|
-
it "reports that has no source" do
|
37
|
-
expect(activation.sources).to eq []
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module LicenseFinder
|
4
|
-
describe LicenseFiles do
|
5
|
-
describe "#find" do
|
6
|
-
def files_in(fixture)
|
7
|
-
root_path = fixture_path(fixture)
|
8
|
-
subject = described_class.find(root_path.to_s)
|
9
|
-
|
10
|
-
subject.map do |f|
|
11
|
-
Pathname(f.path).relative_path_from(root_path).to_s
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
it "is empty if passed a nil install path" do
|
16
|
-
subject = described_class.new nil
|
17
|
-
expect(subject.find).to eq([])
|
18
|
-
end
|
19
|
-
|
20
|
-
it "is empty if there aren't any license files" do
|
21
|
-
expect(files_in('not/a/dir')).to eq([])
|
22
|
-
end
|
23
|
-
|
24
|
-
it "includes files with names like LICENSE, README or COPYING" do
|
25
|
-
expect(files_in('license_names')).to match_array(
|
26
|
-
%w[COPYING.txt LICENSE Mit-License README.rdoc Licence.rdoc]
|
27
|
-
)
|
28
|
-
end
|
29
|
-
|
30
|
-
it "includes files deep in the hierarchy" do
|
31
|
-
expect(files_in('nested_gem')).to eq(['vendor/LICENSE'])
|
32
|
-
end
|
33
|
-
|
34
|
-
it "includes files nested inside LICENSE directory" do
|
35
|
-
expect(files_in('license_directory')).to match_array(%w[
|
36
|
-
COPYING
|
37
|
-
LICENSE/MIT.txt
|
38
|
-
])
|
39
|
-
end
|
40
|
-
|
41
|
-
it "handles non UTF8 encodings" do
|
42
|
-
expect { files_in('utf8_gem') }.not_to raise_error
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|