license_finder 2.0.0.rc2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -1
  3. data/CHANGELOG.rdoc +16 -9
  4. data/CONTRIBUTING.md +3 -3
  5. data/README.md +4 -1
  6. data/TODO.md +6 -19
  7. data/bin/license_finder_pip.py +2 -2
  8. data/features/features/cli_spec.rb +18 -18
  9. data/features/features/configure/add_dependencies_spec.rb +16 -16
  10. data/features/features/configure/approve_dependencies_spec.rb +10 -9
  11. data/features/features/configure/assign_licenses_spec.rb +8 -8
  12. data/features/features/configure/ignore_dependencies_spec.rb +15 -15
  13. data/features/features/configure/ignore_groups_spec.rb +15 -15
  14. data/features/features/configure/name_project_spec.rb +15 -14
  15. data/features/features/configure/whitelist_licenses_spec.rb +21 -21
  16. data/features/features/package_managers/bower_spec.rb +3 -3
  17. data/features/features/package_managers/cocoapods_spec.rb +4 -4
  18. data/features/features/package_managers/gradle_spec.rb +3 -3
  19. data/features/features/package_managers/maven_spec.rb +3 -3
  20. data/features/features/package_managers/npm_spec.rb +3 -3
  21. data/features/features/package_managers/pip_spec.rb +3 -3
  22. data/features/features/report/csv_spec.rb +9 -8
  23. data/features/features/report/html_spec.rb +13 -12
  24. data/features/support/testing_dsl.rb +1 -1
  25. data/lib/license_finder.rb +1 -16
  26. data/lib/license_finder/cli/approvals.rb +3 -4
  27. data/lib/license_finder/cli/base.rb +40 -3
  28. data/lib/license_finder/cli/dependencies.rb +3 -3
  29. data/lib/license_finder/cli/main.rb +7 -25
  30. data/lib/license_finder/cli/makes_decisions.rb +2 -20
  31. data/lib/license_finder/cli/patched_thor.rb +0 -2
  32. data/lib/license_finder/cli/whitelist.rb +6 -8
  33. data/lib/license_finder/configuration.rb +1 -1
  34. data/lib/license_finder/core.rb +68 -0
  35. data/lib/license_finder/decision_applier.rb +10 -7
  36. data/lib/license_finder/license.rb +10 -10
  37. data/lib/license_finder/license/template.rb +3 -2
  38. data/lib/license_finder/logger.rb +2 -6
  39. data/lib/license_finder/package.rb +25 -44
  40. data/lib/license_finder/package_manager.rb +11 -13
  41. data/lib/license_finder/package_managers/bower.rb +1 -1
  42. data/lib/license_finder/package_managers/bundler.rb +1 -1
  43. data/lib/license_finder/package_managers/cocoa_pods.rb +3 -3
  44. data/lib/license_finder/package_managers/cocoa_pods_package.rb +3 -3
  45. data/lib/license_finder/package_managers/gradle.rb +2 -2
  46. data/lib/license_finder/package_managers/maven.rb +2 -2
  47. data/lib/license_finder/package_managers/npm.rb +1 -1
  48. data/lib/license_finder/package_managers/pip.rb +1 -1
  49. data/lib/license_finder/package_managers/pip_package.rb +6 -4
  50. data/lib/license_finder/packages/activation.rb +54 -0
  51. data/lib/license_finder/{possible_license_files.rb → packages/license_files.rb} +9 -7
  52. data/lib/license_finder/packages/licensing.rb +43 -0
  53. data/lib/license_finder/{package_managers → packages}/manual_package.rb +0 -0
  54. data/lib/license_finder/{possible_license_file.rb → packages/possible_license_file.rb} +0 -2
  55. data/lib/license_finder/version.rb +1 -1
  56. data/spec/fixtures/{license_directory/LICENSE/Apache.txt → all_pms/Gemfile} +0 -0
  57. data/spec/fixtures/all_pms/Podfile +0 -0
  58. data/spec/fixtures/all_pms/bower.json +0 -0
  59. data/spec/fixtures/all_pms/build.gradle +0 -0
  60. data/spec/fixtures/all_pms/package.json +0 -0
  61. data/spec/fixtures/all_pms/pom.xml +0 -0
  62. data/spec/fixtures/all_pms/requirements.txt +0 -0
  63. data/spec/fixtures/license_directory/COPYING +1 -0
  64. data/spec/fixtures/license_directory/LICENSE/MIT.txt +1 -0
  65. data/spec/fixtures/license_names/COPYING.txt +1 -0
  66. data/spec/fixtures/license_names/LICENSE +1 -0
  67. data/spec/fixtures/license_names/Licence.rdoc +1 -0
  68. data/spec/fixtures/license_names/Mit-License +1 -0
  69. data/spec/fixtures/license_names/README.rdoc +1 -0
  70. data/spec/fixtures/nested_gem/vendor/LICENSE +1 -0
  71. data/spec/lib/license_finder/cli/approvals_spec.rb +9 -3
  72. data/spec/lib/license_finder/cli/dependencies_spec.rb +5 -2
  73. data/spec/lib/license_finder/cli/main_spec.rb +20 -27
  74. data/spec/lib/license_finder/configuration_spec.rb +1 -3
  75. data/spec/lib/license_finder/decision_applier_spec.rb +15 -15
  76. data/spec/lib/license_finder/decisions_spec.rb +94 -95
  77. data/spec/lib/license_finder/license_spec.rb +5 -5
  78. data/spec/lib/license_finder/package_managers/bower_package_spec.rb +0 -4
  79. data/spec/lib/license_finder/package_managers/bower_spec.rb +6 -27
  80. data/spec/lib/license_finder/package_managers/bundler_package_spec.rb +0 -2
  81. data/spec/lib/license_finder/package_managers/bundler_spec.rb +0 -15
  82. data/spec/lib/license_finder/package_managers/cocoa_pods_package_spec.rb +5 -2
  83. data/spec/lib/license_finder/package_managers/cocoa_pods_spec.rb +13 -31
  84. data/spec/lib/license_finder/package_managers/gradle_package_spec.rb +0 -2
  85. data/spec/lib/license_finder/package_managers/gradle_spec.rb +11 -35
  86. data/spec/lib/license_finder/package_managers/maven_package_spec.rb +0 -2
  87. data/spec/lib/license_finder/package_managers/maven_spec.rb +18 -56
  88. data/spec/lib/license_finder/package_managers/npm_package_spec.rb +0 -2
  89. data/spec/lib/license_finder/package_managers/npm_spec.rb +0 -17
  90. data/spec/lib/license_finder/package_managers/pip_package_spec.rb +0 -2
  91. data/spec/lib/license_finder/package_managers/pip_spec.rb +8 -25
  92. data/spec/lib/license_finder/package_spec.rb +2 -4
  93. data/spec/lib/license_finder/packages/activation_spec.rb +47 -0
  94. data/spec/lib/license_finder/{possible_license_files_spec.rb → packages/license_files_spec.rb} +2 -6
  95. data/spec/lib/license_finder/packages/licensing_spec.rb +1 -0
  96. data/spec/lib/license_finder/{possible_license_file_spec.rb → packages/possible_license_file_spec.rb} +0 -0
  97. data/spec/spec_helper.rb +2 -0
  98. data/spec/support/shared_examples_for_package_manager.rb +14 -1
  99. data/spec/support/test_fixtures.rb +7 -0
  100. metadata +117 -12
  101. data/spec/support/shared_examples_for_package.rb +0 -35
@@ -36,7 +36,7 @@ module LicenseFinder
36
36
  end
37
37
 
38
38
  def package_path
39
- Pathname.new('package.json')
39
+ project_path.join('package.json')
40
40
  end
41
41
 
42
42
  # node_module can be empty hash if it is included elsewhere
@@ -19,7 +19,7 @@ module LicenseFinder
19
19
  private
20
20
 
21
21
  def package_path
22
- Pathname.new('requirements.txt')
22
+ project_path.join('requirements.txt')
23
23
  end
24
24
 
25
25
  def pypi_def(name, version)
@@ -1,14 +1,16 @@
1
1
  module LicenseFinder
2
2
  class PipPackage < Package
3
+ LICENSE_FORMAT = /^License.*::\s*(.*)$/
4
+
3
5
  def self.license_names_from_spec(spec)
4
6
  license = spec["license"]
5
7
 
6
8
  return [license] if license && license != "UNKNOWN"
7
9
 
8
- spec.
9
- fetch("classifiers", []).
10
- select { |c| c.start_with?("License") }.
11
- map { |c| c.gsub(/^License.*::\s*(.*)$/, '\1') }
10
+ spec
11
+ .fetch("classifiers", [])
12
+ .select { |c| c =~ LICENSE_FORMAT }
13
+ .map { |c| c.gsub(LICENSE_FORMAT, '\1') }
12
14
  end
13
15
 
14
16
  def initialize(name, version, install_path, spec, options={})
@@ -0,0 +1,54 @@
1
+ module LicenseFinder
2
+ module Activation
3
+ # An Activation reports that a license has been activated for a package, and
4
+ # tracks the source of that information
5
+ Basic = Struct.new(:package, :license) do
6
+ def log(logger)
7
+ sources.each do |source|
8
+ log_package(logger, "found license '#{license.name}' #{source}")
9
+ end
10
+ end
11
+
12
+ private
13
+
14
+ def log_package(logger, text)
15
+ logger.log(package.class, "package #{package.name}: #{text}")
16
+ end
17
+ end
18
+
19
+ class FromDecision < Basic
20
+ def sources
21
+ ["from decision"]
22
+ end
23
+ end
24
+
25
+ class FromSpec < Basic
26
+ def sources
27
+ ["from spec"]
28
+ end
29
+ end
30
+
31
+ class FromFiles < Basic
32
+ def initialize(package, license, files)
33
+ super(package, license)
34
+ @files = files
35
+ end
36
+
37
+ attr_reader :files
38
+
39
+ def sources
40
+ files.map { |file| "from file '#{file.path}'" }
41
+ end
42
+ end
43
+
44
+ class None < Basic
45
+ def sources
46
+ []
47
+ end
48
+
49
+ def log(logger)
50
+ log_package(logger, "no licenses found")
51
+ end
52
+ end
53
+ end
54
+ end
@@ -1,5 +1,7 @@
1
+ require 'license_finder/packages/possible_license_file'
2
+
1
3
  module LicenseFinder
2
- class PossibleLicenseFiles
4
+ class LicenseFiles
3
5
  CANDIDATE_FILE_NAMES = %w(LICENSE License Licence COPYING README Readme ReadMe)
4
6
  CANDIDATE_PATH_WILDCARD = "*{#{CANDIDATE_FILE_NAMES.join(',')}}*"
5
7
 
@@ -12,9 +14,9 @@ module LicenseFinder
12
14
  end
13
15
 
14
16
  def find
15
- paths_of_candidate_files.map do |path|
16
- PossibleLicenseFile.new(path)
17
- end
17
+ paths_of_candidate_files
18
+ .map { |path| PossibleLicenseFile.new(path) }
19
+ .reject { |file| file.license.nil? }
18
20
  end
19
21
 
20
22
  private
@@ -22,9 +24,9 @@ module LicenseFinder
22
24
  attr_reader :install_path
23
25
 
24
26
  def paths_of_candidate_files
25
- candidate_files_and_dirs.map do |path|
26
- path.directory? ? path.children : path
27
- end.flatten.uniq
27
+ candidate_files_and_dirs
28
+ .flat_map { |path| path.directory? ? path.children : path }
29
+ .uniq
28
30
  end
29
31
 
30
32
  def candidate_files_and_dirs
@@ -0,0 +1,43 @@
1
+ require 'license_finder/packages/activation'
2
+
3
+ module LicenseFinder
4
+ Licensing = Struct.new(:package, :decided_licenses, :licenses_from_spec, :license_files) do
5
+
6
+ # Implements the algorithm for choosing the right set of licenses from
7
+ # among the various sources of licenses we know about. In order of
8
+ # priority, licenses come from decisions, package specs, or package files.
9
+ def activations
10
+ afd = activations_from_decisions
11
+ return afd if afd.any?
12
+
13
+ afs = activations_from_spec
14
+ return afs if afs.any?
15
+
16
+ aff = activations_from_files
17
+ return aff if aff.any?
18
+
19
+ [default_activation]
20
+ end
21
+
22
+ def activations_from_decisions
23
+ decided_licenses
24
+ .map { |license| Activation::FromDecision.new(package, license) }
25
+ end
26
+
27
+ def activations_from_spec
28
+ licenses_from_spec
29
+ .map { |license| Activation::FromSpec.new(package, license) }
30
+ end
31
+
32
+ def activations_from_files
33
+ license_files
34
+ .group_by(&:license)
35
+ .map { |license, files| Activation::FromFiles.new(package, license, files) }
36
+ end
37
+
38
+ def default_activation
39
+ default_license = License.find_by_name nil
40
+ Activation::None.new(package, default_license)
41
+ end
42
+ end
43
+ end
@@ -12,8 +12,6 @@ module LicenseFinder
12
12
  License.find_by_text(text)
13
13
  end
14
14
 
15
- private
16
-
17
15
  def text
18
16
  @text ||= (@path.respond_to?(:binread) ? @path.binread : @path.read)
19
17
  end
@@ -1,3 +1,3 @@
1
1
  module LicenseFinder
2
- VERSION = "2.0.0.rc2"
2
+ VERSION = "2.0.0"
3
3
  end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1 @@
1
+ The MIT License
@@ -0,0 +1 @@
1
+ The MIT License
@@ -0,0 +1 @@
1
+ The MIT License
@@ -0,0 +1 @@
1
+ The MIT License
@@ -0,0 +1 @@
1
+ The MIT License
@@ -0,0 +1 @@
1
+ The MIT License
@@ -0,0 +1 @@
1
+ The MIT License
@@ -0,0 +1 @@
1
+ The MIT License
@@ -32,11 +32,17 @@ module LicenseFinder
32
32
  end
33
33
 
34
34
  it "sets approver and approval message" do
35
- expect(decisions).to receive(:approve).with("foo", hash_including(who: "Julian", why: "We really need this"))
36
-
35
+ subject.options = {
36
+ who: "Julian",
37
+ why: "We really need this"
38
+ }
37
39
  silence_stdout do
38
- Main.start(["approval", "add", "--who", "Julian", "--why", "We really need this", "foo"])
40
+ subject.add("foo")
39
41
  end
42
+
43
+ approval = subject.decisions.approval_of("foo")
44
+ expect(approval.who).to eq "Julian"
45
+ expect(approval.why).to eq "We really need this"
40
46
  end
41
47
  end
42
48
 
@@ -31,10 +31,13 @@ module LicenseFinder
31
31
  end
32
32
 
33
33
  it "has an --approve option to approve the added dependency" do
34
- expect(decisions).to receive(:approve).with("js_dep", hash_including(who: "Julian", why: "We really need this"))
34
+ subject.options = { approve: true, who: "Julian", why: "We really need this" }
35
35
  silence_stdout do
36
- Main.start(["dependencies", "add", "--approve", "--who", "Julian", "--why", "We really need this", "js_dep", "MIT", "1.2.3"])
36
+ subject.add("js_dep", "MIT")
37
37
  end
38
+ approval = subject.decisions.approval_of("js_dep")
39
+ expect(approval.who).to eq "Julian"
40
+ expect(approval.why).to eq "We really need this"
38
41
  end
39
42
  end
40
43
 
@@ -30,44 +30,36 @@ module LicenseFinder
30
30
  describe "#report" do
31
31
  let(:packages) { [Package.new('one dependency', "1.1")] }
32
32
 
33
+ def report
34
+ capture_stdout { subject.report }
35
+ end
36
+
33
37
  it "reports acknowleged dependencies" do
34
- result = capture_stdout do
35
- Main.start(["report"])
36
- end
37
- expect(result).to eq "\"one dependency\", 1.1, unknown\n"
38
+ expect(report).to eq "\"one dependency\", 1.1, unknown\n"
38
39
  end
39
40
 
40
41
  it "will output a specific format" do
41
- result = capture_stdout do
42
- Main.start(%w[report --format markdown])
43
- end
42
+ subject.options = { format: 'markdown' }
44
43
 
45
- expect(result).to include "## Action"
44
+ expect(report).to include "## Action"
46
45
  end
47
46
 
48
47
  it "will output a custom csv" do
49
- result = capture_stdout do
50
- Main.start(%w[report --format csv --columns name version])
51
- end
48
+ subject.options = { format: 'csv', columns: ['name', 'version'] }
52
49
 
53
- expect(result).to eq "one dependency,1.1\n"
50
+ expect(report).to eq "one dependency,1.1\n"
54
51
  end
55
52
 
56
53
  context "in html reports" do
57
- subject do
58
- result = capture_stdout do
59
- Main.start(%w[report --format html])
60
- end
61
-
62
- html = Capybara.string(result)
63
- html.find "h1"
54
+ before do
55
+ subject.options = { format: 'html' }
64
56
  end
65
57
 
66
58
  context "when the project has a name" do
67
59
  before { decisions.name_project("given project name") }
68
60
 
69
61
  it "should show the project name" do
70
- is_expected.to have_text "given project name"
62
+ expect(report).to include "given project name"
71
63
  end
72
64
  end
73
65
 
@@ -75,21 +67,24 @@ module LicenseFinder
75
67
  before { allow(Dir).to receive(:getwd).and_return("/path/to/a_project") }
76
68
 
77
69
  it "should default to the directory name" do
78
- is_expected.to have_text "a_project"
70
+ expect(report).to include "a_project"
79
71
  end
80
72
  end
81
73
  end
82
74
  end
83
75
 
84
76
  describe "#action_items" do
77
+ def action_items
78
+ subject.options = { quiet: true, format: 'text' }
79
+ subject.action_items
80
+ end
81
+
85
82
  context "with unapproved dependencies" do
86
83
  let(:packages) { [Package.new('one dependency')] }
87
84
 
88
85
  it "reports unapproved dependencies" do
89
86
  result = capture_stdout do
90
- expect do
91
- Main.start(%w[action_items --quiet])
92
- end.to raise_error(SystemExit)
87
+ expect { action_items }.to raise_error(SystemExit)
93
88
  end
94
89
  expect(result).to match /dependencies/i
95
90
  expect(result).to match /one dependency/
@@ -98,9 +93,7 @@ module LicenseFinder
98
93
 
99
94
  it "reports that all dependencies are approved" do
100
95
  result = capture_stdout do
101
- expect do
102
- Main.start(%w[action_items --quiet])
103
- end.not_to raise_error
96
+ expect { action_items }.not_to raise_error
104
97
  end
105
98
  expect(result).to match /approved/i
106
99
  end
@@ -4,9 +4,7 @@ module LicenseFinder
4
4
  describe Configuration do
5
5
  describe ".with_optional_saved_config" do
6
6
  it "should init and use saved config" do
7
- fake_project_dir = Pathname.new(__FILE__).dirname.join('..', '..', 'fixtures')
8
-
9
- subject = described_class.with_optional_saved_config({}, fake_project_dir)
7
+ subject = described_class.with_optional_saved_config({}, fixture_path("."))
10
8
  expect(subject.gradle_command).to eq('gradlew')
11
9
  end
12
10
  end
@@ -12,24 +12,24 @@ module LicenseFinder
12
12
  end
13
13
 
14
14
  it "applies decided licenses" do
15
- decisions = Decisions.new.
16
- add_package("manual", nil).
17
- license("manual", "MIT")
15
+ decisions = Decisions.new
16
+ .add_package("manual", nil)
17
+ .license("manual", "MIT")
18
18
  decision_applier = described_class.new(decisions: decisions, packages: [])
19
19
  expect(decision_applier.acknowledged.last.licenses).to eq Set.new([License.find_by_name("MIT")])
20
20
  end
21
21
 
22
22
  it "ignores specific packages" do
23
- decisions = Decisions.new.
24
- add_package("manual", nil).
25
- ignore("manual")
23
+ decisions = Decisions.new
24
+ .add_package("manual", nil)
25
+ .ignore("manual")
26
26
  decision_applier = described_class.new(decisions: decisions, packages: [])
27
27
  expect(decision_applier.acknowledged).to be_empty
28
28
  end
29
29
 
30
30
  it "ignores packages in certain groups" do
31
- decisions = Decisions.new.
32
- ignore_group("development")
31
+ decisions = Decisions.new
32
+ .ignore_group("development")
33
33
  dev_dep = Package.new("dep", nil, groups: ["development"])
34
34
  decision_applier = described_class.new(
35
35
  decisions: decisions,
@@ -39,9 +39,9 @@ module LicenseFinder
39
39
  end
40
40
 
41
41
  it "adds manual approvals to packages" do
42
- decisions = Decisions.new.
43
- add_package("manual", nil).
44
- approve("manual", who: "Approver", why: "Because")
42
+ decisions = Decisions.new
43
+ .add_package("manual", nil)
44
+ .approve("manual", who: "Approver", why: "Because")
45
45
  decision_applier = described_class.new(decisions: decisions, packages: [])
46
46
  dep = decision_applier.acknowledged.last
47
47
  expect(dep).to be_approved
@@ -51,10 +51,10 @@ module LicenseFinder
51
51
  end
52
52
 
53
53
  it "adds whitelist approvals to packages" do
54
- decisions = Decisions.new.
55
- add_package("manual", nil).
56
- license("manual", "MIT").
57
- whitelist("MIT")
54
+ decisions = Decisions.new
55
+ .add_package("manual", nil)
56
+ .license("manual", "MIT")
57
+ .whitelist("MIT")
58
58
  decision_applier = described_class.new(decisions: decisions, packages: [])
59
59
  dep = decision_applier.acknowledged.last
60
60
  expect(dep).to be_approved
@@ -16,34 +16,35 @@ module LicenseFinder
16
16
 
17
17
  describe ".remove_package" do
18
18
  it "drops a package" do
19
- packages = subject.
20
- add_package("dep", nil).
21
- remove_package("dep").
22
- packages
19
+ packages = subject
20
+ .add_package("dep", nil)
21
+ .remove_package("dep")
22
+ .packages
23
23
  expect(packages.size).to eq 0
24
24
  end
25
25
 
26
26
  it "does nothing if package was never added" do
27
- packages = subject.
28
- remove_package("dep").
29
- packages
27
+ packages = subject
28
+ .remove_package("dep")
29
+ .packages
30
30
  expect(packages.size).to eq 0
31
31
  end
32
32
  end
33
33
 
34
34
  describe ".license" do
35
35
  it "will report license for a dependency" do
36
- license = subject.
37
- license("dep", "MIT").
38
- licenses_of("dep").first
36
+ license = subject
37
+ .license("dep", "MIT")
38
+ .licenses_of("dep")
39
+ .first
39
40
  expect(license).to eq License.find_by_name("MIT")
40
41
  end
41
42
 
42
43
  it "will report multiple licenses" do
43
- licenses = subject.
44
- license("dep", "MIT").
45
- license("dep", "GPL").
46
- licenses_of("dep")
44
+ licenses = subject
45
+ .license("dep", "MIT")
46
+ .license("dep", "GPL")
47
+ .licenses_of("dep")
47
48
  expect(licenses).to eq [
48
49
  License.find_by_name("MIT"),
49
50
  License.find_by_name("GPL"),
@@ -51,37 +52,39 @@ module LicenseFinder
51
52
  end
52
53
 
53
54
  it "adapts names" do
54
- license = subject.
55
- license("dep", "Expat").
56
- licenses_of("dep").first
55
+ license = subject
56
+ .license("dep", "Expat")
57
+ .licenses_of("dep")
58
+ .first
57
59
  expect(license).to eq License.find_by_name("MIT")
58
60
  end
59
61
  end
60
62
 
61
63
  describe ".unlicense" do
62
64
  it "will not report the given dependency as licensed" do
63
- licenses = subject.
64
- license("dep", "MIT").
65
- unlicense("dep", "MIT").
66
- licenses_of("dep")
65
+ licenses = subject
66
+ .license("dep", "MIT")
67
+ .unlicense("dep", "MIT")
68
+ .licenses_of("dep")
67
69
  expect(licenses).to be_empty
68
70
  end
69
71
 
70
72
  it "will only remove the specified license" do
71
- licenses = subject.
72
- license("dep", "MIT").
73
- license("dep", "GPL").
74
- unlicense("dep", "MIT").
75
- licenses_of("dep")
73
+ licenses = subject
74
+ .license("dep", "MIT")
75
+ .license("dep", "GPL")
76
+ .unlicense("dep", "MIT")
77
+ .licenses_of("dep")
76
78
  expect(licenses).to eq [License.find_by_name("GPL")].to_set
77
79
  end
78
80
 
79
81
  it "is cumulative" do
80
- license = subject.
81
- license("dep", "MIT").
82
- unlicense("dep", "MIT").
83
- license("dep", "MIT").
84
- licenses_of("dep").first
82
+ license = subject
83
+ .license("dep", "MIT")
84
+ .unlicense("dep", "MIT")
85
+ .license("dep", "MIT")
86
+ .licenses_of("dep")
87
+ .first
85
88
  expect(license).to eq License.find_by_name("MIT")
86
89
  end
87
90
  end
@@ -99,17 +102,17 @@ module LicenseFinder
99
102
 
100
103
  describe ".unapprove" do
101
104
  it "will not report the given dependency as approved" do
102
- decisions = subject.
103
- approve("dep").
104
- unapprove("dep")
105
+ decisions = subject
106
+ .approve("dep")
107
+ .unapprove("dep")
105
108
  expect(subject).not_to be_approved("dep")
106
109
  end
107
110
 
108
111
  it "is cumulative" do
109
- decisions = subject.
110
- approve("dep").
111
- unapprove("dep").
112
- approve("dep")
112
+ decisions = subject
113
+ .approve("dep")
114
+ .unapprove("dep")
115
+ .approve("dep")
113
116
  expect(subject).to be_approved("dep")
114
117
  end
115
118
  end
@@ -133,24 +136,24 @@ module LicenseFinder
133
136
 
134
137
  describe ".unwhitelist" do
135
138
  it "will not report the given license as approved" do
136
- decisions = subject.
137
- whitelist("MIT").
138
- unwhitelist("MIT")
139
+ decisions = subject
140
+ .whitelist("MIT")
141
+ .unwhitelist("MIT")
139
142
  expect(decisions).not_to be_whitelisted(License.find_by_name("MIT"))
140
143
  end
141
144
 
142
145
  it "is cumulative" do
143
- decisions = subject.
144
- whitelist("MIT").
145
- unwhitelist("MIT").
146
- whitelist("MIT")
146
+ decisions = subject
147
+ .whitelist("MIT")
148
+ .unwhitelist("MIT")
149
+ .whitelist("MIT")
147
150
  expect(decisions).to be_whitelisted(License.find_by_name("MIT"))
148
151
  end
149
152
 
150
153
  it "adapts names" do
151
- decisions = subject.
152
- whitelist("MIT").
153
- unwhitelist("Expat")
154
+ decisions = subject
155
+ .whitelist("MIT")
156
+ .unwhitelist("Expat")
154
157
  expect(decisions).not_to be_whitelisted(License.find_by_name("MIT"))
155
158
  end
156
159
  end
@@ -164,42 +167,41 @@ module LicenseFinder
164
167
 
165
168
  describe ".heed" do
166
169
  it "will not report heeded dependencies" do
167
- decisions = subject.
168
- ignore("dep").
169
- heed("dep")
170
+ decisions = subject
171
+ .ignore("dep")
172
+ .heed("dep")
170
173
  expect(decisions).not_to be_ignored("dep")
171
174
  end
172
175
 
173
176
  it "is cumulative" do
174
- decisions = subject.
175
- ignore("dep").
176
- heed("dep").
177
- ignore("dep")
177
+ decisions = subject
178
+ .ignore("dep")
179
+ .heed("dep")
180
+ .ignore("dep")
178
181
  expect(decisions).to be_ignored("dep")
179
182
  end
180
183
  end
181
184
 
182
185
  describe ".ignore_group" do
183
186
  it "will report ignored groups" do
184
- decisions = subject.
185
- ignore_group("development")
187
+ decisions = subject.ignore_group("development")
186
188
  expect(decisions).to be_ignored_group("development")
187
189
  end
188
190
  end
189
191
 
190
192
  describe ".heed_group" do
191
193
  it "will not report heeded groups" do
192
- decisions = subject.
193
- ignore_group("development").
194
- heed_group("development")
194
+ decisions = subject
195
+ .ignore_group("development")
196
+ .heed_group("development")
195
197
  expect(decisions).not_to be_ignored_group("development")
196
198
  end
197
199
 
198
200
  it "is cumulative" do
199
- decisions = subject.
200
- ignore_group("development").
201
- heed_group("development").
202
- ignore_group("development")
201
+ decisions = subject
202
+ .ignore_group("development")
203
+ .heed_group("development")
204
+ .ignore_group("development")
203
205
  expect(decisions).to be_ignored_group("development")
204
206
  end
205
207
  end
@@ -213,9 +215,9 @@ module LicenseFinder
213
215
 
214
216
  describe ".unname_project" do
215
217
  it "reports project name" do
216
- decisions = subject.
217
- name_project("proj").
218
- unname_project
218
+ decisions = subject
219
+ .name_project("proj")
220
+ .unname_project
219
221
  expect(decisions.project_name).to be_nil
220
222
  end
221
223
  end
@@ -227,8 +229,7 @@ module LicenseFinder
227
229
 
228
230
  it "can restore added packages" do
229
231
  decisions = roundtrip(
230
- subject.
231
- add_package("dep", "0.2.0")
232
+ subject.add_package("dep", "0.2.0")
232
233
  )
233
234
  packages = decisions.packages
234
235
  expect(packages.map(&:name)).to eq ["dep"]
@@ -236,9 +237,9 @@ module LicenseFinder
236
237
 
237
238
  it "can restore removed packages" do
238
239
  decisions = roundtrip(
239
- subject.
240
- add_package("dep", nil).
241
- remove_package("dep")
240
+ subject
241
+ .add_package("dep", nil)
242
+ .remove_package("dep")
242
243
  )
243
244
  expect(decisions.packages.size).to eq 0
244
245
  end
@@ -252,10 +253,10 @@ module LicenseFinder
252
253
 
253
254
  it "can restore unlicenses" do
254
255
  licenses = roundtrip(
255
- subject.
256
- license("dep", "MIT").
257
- license("dep", "GPL").
258
- unlicense("dep", "MIT")
256
+ subject
257
+ .license("dep", "MIT")
258
+ .license("dep", "GPL")
259
+ .unlicense("dep", "MIT")
259
260
  ).licenses_of("dep")
260
261
  expect(licenses).to eq [License.find_by_name("GPL")].to_set
261
262
  end
@@ -272,9 +273,9 @@ module LicenseFinder
272
273
 
273
274
  it "can restore unapprovals" do
274
275
  decisions = roundtrip(
275
- subject.
276
- approve("dep").
277
- unapprove("dep")
276
+ subject
277
+ .approve("dep")
278
+ .unapprove("dep")
278
279
  )
279
280
  expect(decisions).not_to be_approved("dep")
280
281
  end
@@ -288,9 +289,9 @@ module LicenseFinder
288
289
 
289
290
  it "can restore un-whitelists" do
290
291
  decisions = roundtrip(
291
- subject.
292
- whitelist("MIT").
293
- unwhitelist("MIT")
292
+ subject
293
+ .whitelist("MIT")
294
+ .unwhitelist("MIT")
294
295
  )
295
296
  expect(decisions).not_to be_whitelisted(License.find_by_name("MIT"))
296
297
  end
@@ -302,43 +303,41 @@ module LicenseFinder
302
303
 
303
304
  it "can restore heeds" do
304
305
  decisions = roundtrip(
305
- subject.
306
- ignore("dep").
307
- heed("dep")
306
+ subject
307
+ .ignore("dep")
308
+ .heed("dep")
308
309
  )
309
310
  expect(decisions).not_to be_ignored("dep")
310
311
  end
311
312
 
312
313
  it "can restore ignored groups" do
313
314
  decisions = roundtrip(
314
- subject.
315
- ignore_group("development")
315
+ subject.ignore_group("development")
316
316
  )
317
317
  expect(decisions).to be_ignored_group("development")
318
318
  end
319
319
 
320
320
  it "can restore heeded groups" do
321
321
  decisions = roundtrip(
322
- subject.
323
- ignore_group("development").
324
- heed_group("development")
322
+ subject
323
+ .ignore_group("development")
324
+ .heed_group("development")
325
325
  )
326
326
  expect(decisions).not_to be_ignored_group("development")
327
327
  end
328
328
 
329
329
  it "can restore project names" do
330
330
  decisions = roundtrip(
331
- subject.
332
- name_project("an-app")
331
+ subject.name_project("an-app")
333
332
  )
334
333
  expect(decisions.project_name).to eq "an-app"
335
334
  end
336
335
 
337
336
  it "can restore project unnames" do
338
337
  decisions = roundtrip(
339
- subject.
340
- name_project("an-app").
341
- unname_project
338
+ subject
339
+ .name_project("an-app")
340
+ .unname_project
342
341
  )
343
342
  expect(decisions.project_name).to be_nil
344
343
  end