license_finder 0.9.5.1 → 1.0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +9 -0
- data/CHANGELOG.rdoc +9 -0
- data/MIT.LICENSE +20 -0
- data/db/migrate/201401302113_re_reassociate_license.rb +23 -0
- data/features/gradle_dependencies.feature +9 -0
- data/features/maven_dependencies.feature +9 -0
- data/features/step_definitions/gradle_steps.rb +8 -0
- data/features/step_definitions/maven_steps.rb +8 -0
- data/features/step_definitions/node_steps.rb +1 -1
- data/features/step_definitions/set_license_steps.rb +0 -1
- data/features/step_definitions/shared_steps.rb +26 -13
- data/lib/license_finder.rb +6 -1
- data/lib/license_finder/cli.rb +13 -9
- data/lib/license_finder/configuration.rb +113 -72
- data/lib/license_finder/dependency_manager.rb +12 -7
- data/lib/license_finder/license.rb +39 -65
- data/lib/license_finder/license/any_matcher.rb +13 -0
- data/lib/license_finder/license/definitions.rb +106 -0
- data/lib/license_finder/license/header_matcher.rb +10 -0
- data/lib/license_finder/license/matcher.rb +17 -0
- data/lib/license_finder/license/template.rb +16 -0
- data/lib/license_finder/license/text.rb +19 -0
- data/lib/license_finder/license_url.rb +1 -4
- data/lib/license_finder/package.rb +18 -2
- data/lib/license_finder/package_managers/bower_package.rb +3 -17
- data/lib/license_finder/package_managers/bundler_package.rb +2 -2
- data/lib/license_finder/package_managers/gradle.rb +29 -0
- data/lib/license_finder/package_managers/gradle_package.rb +41 -0
- data/lib/license_finder/package_managers/maven.rb +31 -0
- data/lib/license_finder/package_managers/maven_package.rb +46 -0
- data/lib/license_finder/package_managers/npm_package.rb +2 -16
- data/lib/license_finder/package_managers/pip_package.rb +7 -7
- data/lib/license_finder/package_saver.rb +1 -1
- data/lib/license_finder/possible_license_file.rb +1 -5
- data/lib/license_finder/possible_license_files.rb +4 -2
- data/lib/license_finder/reports/dependency_report.rb +5 -1
- data/lib/license_finder/reports/detailed_text_report.rb +0 -1
- data/lib/license_finder/reports/formatted_report.rb +21 -0
- data/lib/license_finder/reports/html_report.rb +1 -21
- data/lib/license_finder/reports/markdown_report.rb +1 -21
- data/lib/license_finder/reports/reporter.rb +8 -7
- data/lib/license_finder/reports/text_report.rb +0 -2
- data/lib/license_finder/tables.rb +1 -1
- data/lib/license_finder/tables/dependency.rb +12 -12
- data/lib/license_finder/yml_to_sql.rb +4 -4
- data/license_finder.gemspec +3 -2
- data/readme.md +10 -1
- data/release/publish.sh +10 -7
- data/spec/fixtures/build.gradle +24 -0
- data/spec/fixtures/pom.xml +19 -0
- data/spec/lib/license_finder/cli_spec.rb +13 -3
- data/spec/lib/license_finder/configuration_spec.rb +121 -74
- data/spec/lib/license_finder/dependency_manager_spec.rb +34 -16
- data/spec/lib/license_finder/license/{new_bsd_spec.rb → definitions_spec.rb} +93 -7
- data/spec/lib/license_finder/license_spec.rb +72 -26
- data/spec/lib/license_finder/license_url_spec.rb +10 -14
- data/spec/lib/license_finder/package_managers/bower_package_spec.rb +17 -5
- data/spec/lib/license_finder/package_managers/bundler_package_spec.rb +2 -2
- data/spec/lib/license_finder/package_managers/gradle_package_spec.rb +66 -0
- data/spec/lib/license_finder/package_managers/gradle_spec.rb +89 -0
- data/spec/lib/license_finder/package_managers/maven_package_spec.rb +72 -0
- data/spec/lib/license_finder/package_managers/maven_spec.rb +115 -0
- data/spec/lib/license_finder/package_managers/npm_package_spec.rb +17 -3
- data/spec/lib/license_finder/package_managers/pip_package_spec.rb +27 -5
- data/spec/lib/license_finder/possible_license_file_spec.rb +2 -2
- data/spec/lib/license_finder/{detailed_text_report_spec.rb → reports/detailed_text_report_spec.rb} +0 -0
- data/spec/lib/license_finder/{html_report_spec.rb → reports/html_report_spec.rb} +0 -0
- data/spec/lib/license_finder/{markdown_report_spec.rb → reports/markdown_report_spec.rb} +0 -0
- data/spec/lib/license_finder/reports/reporter_spec.rb +33 -0
- data/spec/lib/license_finder/{text_report_spec.rb → reports/text_report_spec.rb} +0 -0
- data/spec/lib/license_finder/tables/dependency_spec.rb +1 -2
- data/spec/lib/license_finder/tables/license_alias_spec.rb +1 -2
- data/spec/lib/license_finder/yml_to_sql_spec.rb +10 -11
- data/spec/lib/license_finder_spec.rb +5 -71
- metadata +64 -53
- data/features/rails_rake.feature +0 -9
- data/features/step_definitions/rails_rake_steps.rb +0 -12
- data/lib/license_finder/license/apache2.rb +0 -8
- data/lib/license_finder/license/bsd.rb +0 -4
- data/lib/license_finder/license/gplv2.rb +0 -4
- data/lib/license_finder/license/isc.rb +0 -3
- data/lib/license_finder/license/lgpl.rb +0 -4
- data/lib/license_finder/license/mit.rb +0 -23
- data/lib/license_finder/license/new_bsd.rb +0 -27
- data/lib/license_finder/license/python.rb +0 -8
- data/lib/license_finder/license/ruby.rb +0 -11
- data/lib/license_finder/license/simplified_bsd.rb +0 -8
- data/lib/license_finder/railtie.rb +0 -7
- data/lib/tasks/license_finder.rake +0 -7
- data/spec/lib/license_finder/license/apache_spec.rb +0 -7
- data/spec/lib/license_finder/license/bsd_spec.rb +0 -41
- data/spec/lib/license_finder/license/gplv2_spec.rb +0 -7
- data/spec/lib/license_finder/license/isc_spec.rb +0 -7
- data/spec/lib/license_finder/license/lgpl_spec.rb +0 -7
- data/spec/lib/license_finder/license/mit_spec.rb +0 -33
- data/spec/lib/license_finder/license/python_spec.rb +0 -7
- data/spec/lib/license_finder/license/ruby_spec.rb +0 -19
- data/spec/lib/license_finder/license/simplified_bsd_spec.rb +0 -7
- data/spec/lib/license_finder/reporter_spec.rb +0 -46
- data/spec/support/license_examples.rb +0 -30
@@ -8,7 +8,7 @@ module LicenseFinder
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def self.load_yml
|
11
|
-
YAML.load
|
11
|
+
YAML.load yml_path.read
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.convert_all(all_legacy_attrs)
|
@@ -20,15 +20,15 @@ module LicenseFinder
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def self.needs_conversion?
|
23
|
-
|
23
|
+
yml_path.exist?
|
24
24
|
end
|
25
25
|
|
26
26
|
def self.remove_yml
|
27
|
-
|
27
|
+
yml_path.delete
|
28
28
|
end
|
29
29
|
|
30
30
|
def self.yml_path
|
31
|
-
LicenseFinder.config.
|
31
|
+
LicenseFinder.config.artifacts.legacy_yaml_file
|
32
32
|
end
|
33
33
|
|
34
34
|
def initialize(attrs)
|
data/license_finder.gemspec
CHANGED
@@ -3,7 +3,7 @@ require './lib/license_finder/platform'
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.required_ruby_version = '>= 1.9.3'
|
5
5
|
s.name = "license_finder"
|
6
|
-
s.version = "0.
|
6
|
+
s.version = "1.0.0.0"
|
7
7
|
s.authors = ["Jacob Maine", "Matthew Kane Parker", "Ian Lesperance", "David Edwards", "Paul Meskers", "Brent Wheeldon", "Trevor John", "David Tengdin", "William Ramsey"]
|
8
8
|
s.email = ["licensefinder@pivotalabs.com"]
|
9
9
|
s.homepage = "https://github.com/pivotal/LicenseFinder"
|
@@ -22,8 +22,8 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.add_dependency "bundler"
|
23
23
|
s.add_dependency "sequel"
|
24
24
|
s.add_dependency "thor"
|
25
|
-
s.add_dependency "rake"
|
26
25
|
s.add_dependency "httparty"
|
26
|
+
s.add_dependency "xml-simple"
|
27
27
|
s.add_dependency LicenseFinder::Platform.sqlite_gem
|
28
28
|
|
29
29
|
%w(rspec xpath cucumber pry).each do |gem|
|
@@ -33,6 +33,7 @@ Gem::Specification.new do |s|
|
|
33
33
|
s.add_development_dependency "capybara", "~> 2.0.0"
|
34
34
|
s.add_development_dependency "rails", "~> 3.2.0"
|
35
35
|
s.add_development_dependency "webmock", "~> 1.13"
|
36
|
+
s.add_development_dependency "rake"
|
36
37
|
|
37
38
|
s.files = `git ls-files`.split("\n")
|
38
39
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
data/readme.md
CHANGED
@@ -16,9 +16,14 @@ Add license_finder to your project's Gemfile and `bundle`:
|
|
16
16
|
gem 'license_finder'
|
17
17
|
```
|
18
18
|
|
19
|
+
#### For gradle projects
|
20
|
+
|
21
|
+
You need to install the license gradle plugin: [https://github.com/hierynomus/license-gradle-plugin](https://github.com/hierynomus/license-gradle-plugin)
|
22
|
+
|
19
23
|
|
20
24
|
## Usage
|
21
25
|
|
26
|
+
|
22
27
|
License finder will generate reports of action items - i.e., dependencies that do not fall within your license "whitelist".
|
23
28
|
|
24
29
|
```sh
|
@@ -246,7 +251,11 @@ And add a `LICENSE` file to your gem that contains your license text.
|
|
246
251
|
* Rebase on top of master
|
247
252
|
* Send a pull request
|
248
253
|
|
249
|
-
To successfully run the test suite, you will need node.js, and
|
254
|
+
To successfully run the test suite, you will need node.js, python and pip installed (pip should not require sudo to work, virtualenv will work for this). If you're running the test suite with jruby, you're probably going to want to set up these environment variables:
|
255
|
+
|
256
|
+
```
|
257
|
+
JAVA_OPTS='-client -XX:+TieredCompilation -XX:TieredStopAtLevel=1' JRUBY_OPTS='-J-Djruby.launch.inproc=true'
|
258
|
+
```
|
250
259
|
|
251
260
|
## License
|
252
261
|
|
data/release/publish.sh
CHANGED
@@ -14,16 +14,19 @@ function perform {
|
|
14
14
|
$1
|
15
15
|
}
|
16
16
|
|
17
|
-
printf "\nBuilding jruby
|
17
|
+
printf "\nBuilding jruby gem"
|
18
18
|
perform "rvm use jruby"
|
19
|
-
perform "
|
19
|
+
perform "gem build *.gemspec"
|
20
20
|
|
21
|
-
printf "\nBuilding ruby
|
21
|
+
printf "\nBuilding ruby gem"
|
22
22
|
perform "rvm use ruby"
|
23
|
-
perform "
|
23
|
+
perform "gem build *.gemspec"
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
perform "gem push
|
25
|
+
for file in *.gem
|
26
|
+
do
|
27
|
+
perform "gem push $file"
|
28
|
+
done
|
29
|
+
|
30
|
+
perform "rm *.gem"
|
28
31
|
|
29
32
|
printf "\nRelease finished."
|
@@ -0,0 +1,24 @@
|
|
1
|
+
apply plugin: 'java'
|
2
|
+
|
3
|
+
sourceCompatibility = 1.5
|
4
|
+
version = '1.0'
|
5
|
+
|
6
|
+
repositories {
|
7
|
+
mavenCentral()
|
8
|
+
}
|
9
|
+
|
10
|
+
dependencies {
|
11
|
+
compile group: 'junit', name: 'junit', version: '4.11'
|
12
|
+
}
|
13
|
+
|
14
|
+
buildscript {
|
15
|
+
repositories {
|
16
|
+
mavenCentral()
|
17
|
+
}
|
18
|
+
|
19
|
+
dependencies {
|
20
|
+
classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.7.0'
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
apply plugin: 'license'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
3
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
4
|
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
5
|
+
<modelVersion>4.0.0</modelVersion>
|
6
|
+
|
7
|
+
<groupId>dummy</groupId>
|
8
|
+
<artifactId>dummy</artifactId>
|
9
|
+
<version>1.0-SNAPSHOT</version>
|
10
|
+
|
11
|
+
<dependencies>
|
12
|
+
<dependency>
|
13
|
+
<groupId>junit</groupId>
|
14
|
+
<artifactId>junit</artifactId>
|
15
|
+
<version>4.11</version>
|
16
|
+
<scope>test</scope>
|
17
|
+
</dependency>
|
18
|
+
</dependencies>
|
19
|
+
</project>
|
@@ -206,6 +206,16 @@ module LicenseFinder
|
|
206
206
|
subject.approve 'foo', 'bar'
|
207
207
|
end
|
208
208
|
end
|
209
|
+
|
210
|
+
it "raises a warning if no gem was specified" do
|
211
|
+
DependencyManager.should_not_receive(:approve!)
|
212
|
+
|
213
|
+
silence_stdout do
|
214
|
+
subject.should_receive(:say).with(/Warning/, :red)
|
215
|
+
subject.should_not_receive(:say).with(/dependency has been approved/, anything)
|
216
|
+
subject.approve
|
217
|
+
end
|
218
|
+
end
|
209
219
|
end
|
210
220
|
|
211
221
|
describe "#action_items" do
|
@@ -213,8 +223,8 @@ module LicenseFinder
|
|
213
223
|
Dependency.stub(:unapproved) { ['one dependency'] }
|
214
224
|
TextReport.stub(:new) { double(:report, to_s: "a report!") }
|
215
225
|
silence_stdout do
|
216
|
-
|
217
|
-
|
226
|
+
subject.stub(:say)
|
227
|
+
subject.should_receive(:say).with(/dependencies/i, :red)
|
218
228
|
expect { subject.action_items }.to raise_error(SystemExit)
|
219
229
|
end
|
220
230
|
end
|
@@ -222,7 +232,7 @@ module LicenseFinder
|
|
222
232
|
it "reports that all dependencies are approved" do
|
223
233
|
Dependency.stub(:unapproved) { [] }
|
224
234
|
silence_stdout do
|
225
|
-
|
235
|
+
subject.should_receive(:say).with(/approved/i, :green)
|
226
236
|
expect { subject.action_items }.to_not raise_error
|
227
237
|
end
|
228
238
|
end
|
@@ -2,123 +2,170 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
module LicenseFinder
|
4
4
|
describe Configuration do
|
5
|
-
|
5
|
+
describe ".ensure_default" do
|
6
|
+
it "should init and use saved config" do
|
7
|
+
Configuration::Persistence.should_receive(:init)
|
8
|
+
Configuration::Persistence.stub(:get).and_return('whitelist' => ['Saved License'])
|
6
9
|
|
7
|
-
|
10
|
+
described_class.ensure_default.whitelist.should == ['Saved License']
|
11
|
+
end
|
12
|
+
end
|
8
13
|
|
9
14
|
describe '.new' do
|
10
|
-
|
11
|
-
{
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
"project_name" => "my_app"
|
16
|
-
}
|
15
|
+
it "should default missing attributes" do
|
16
|
+
subject = described_class.new({})
|
17
|
+
subject.whitelist.should == []
|
18
|
+
subject.ignore_groups.should == []
|
19
|
+
subject.artifacts.dir.should == Pathname('./doc/')
|
17
20
|
end
|
18
21
|
|
19
|
-
|
22
|
+
it "should default missing attributes even if they are saved as nils in the YAML file" do
|
23
|
+
attributes = {
|
24
|
+
"whitelist" => nil,
|
25
|
+
"ignore_groups" => nil,
|
26
|
+
"dependencies_file_dir" => nil,
|
27
|
+
"project_name" => nil
|
28
|
+
}
|
29
|
+
subject = described_class.new(attributes)
|
30
|
+
subject.whitelist.should == []
|
31
|
+
subject.ignore_groups.should == []
|
32
|
+
subject.artifacts.dir.should == Pathname('./doc/')
|
33
|
+
subject.project_name.should_not be_nil
|
34
|
+
end
|
20
35
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
36
|
+
it "should set the all of the attributes on the instance" do
|
37
|
+
attributes = {
|
38
|
+
"whitelist" => %w{a whitelist},
|
39
|
+
"ignore_groups" => %w{test development},
|
40
|
+
"dependencies_file_dir" => "some/path",
|
41
|
+
"project_name" => "my_app"
|
42
|
+
}
|
43
|
+
subject = described_class.new(attributes)
|
44
|
+
subject.whitelist.should == %w{a whitelist}
|
45
|
+
subject.ignore_groups.should == %w{test development}
|
46
|
+
subject.artifacts.dir.should == Pathname("some/path")
|
47
|
+
subject.project_name.should == "my_app"
|
28
48
|
end
|
29
49
|
end
|
30
50
|
|
31
|
-
describe "
|
32
|
-
it "should
|
33
|
-
|
34
|
-
|
51
|
+
describe "file paths" do
|
52
|
+
it "should be relative to artifacts dir" do
|
53
|
+
artifacts = described_class.new('dependencies_file_dir' => './elsewhere').artifacts
|
54
|
+
artifacts.dir.should == Pathname('./elsewhere')
|
55
|
+
artifacts.legacy_yaml_file.should == Pathname('./elsewhere/dependencies.yml')
|
56
|
+
artifacts.text_file.should == Pathname('./elsewhere/dependencies.csv')
|
57
|
+
artifacts.html_file.should == Pathname('./elsewhere/dependencies.html')
|
35
58
|
end
|
36
59
|
end
|
37
60
|
|
38
|
-
describe "#
|
39
|
-
it "should
|
40
|
-
|
61
|
+
describe "#database_uri" do
|
62
|
+
it "should URI escape absolute path to dependencies_file_dir, even with spaces" do
|
63
|
+
artifacts = described_class.new('dependencies_file_dir' => 'test path').artifacts
|
64
|
+
artifacts.database_uri.should =~ %r{test%20path/dependencies\.db$}
|
41
65
|
end
|
42
66
|
end
|
43
67
|
|
44
68
|
describe "#project_name" do
|
45
|
-
let(:directory_name) { "test_dir" }
|
46
|
-
|
47
|
-
before do
|
48
|
-
Configuration.stub(:config_hash).and_return({})
|
49
|
-
Dir.stub(:getwd).and_return("/path/to/#{directory_name}")
|
50
|
-
end
|
51
|
-
|
52
69
|
it "should default to the directory name" do
|
53
|
-
|
70
|
+
Dir.stub(:getwd).and_return("/path/to/a_project")
|
71
|
+
described_class.new({}).project_name.should == "a_project"
|
54
72
|
end
|
55
73
|
end
|
56
74
|
|
57
75
|
describe "whitelisted?" do
|
58
|
-
context "
|
59
|
-
|
76
|
+
context "short name whitelisted" do
|
77
|
+
subject { described_class.new('whitelist' => ["Apache2"]) }
|
60
78
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
config.whitelisted?(name).should be_true, "expected #{name} to be whitelisted, but wasn't."
|
66
|
-
end
|
79
|
+
it "should accept any of the licenses names" do
|
80
|
+
subject.should be_whitelisted "Apache2"
|
81
|
+
subject.should be_whitelisted "Apache 2.0"
|
82
|
+
subject.should be_whitelisted "Apache-2.0"
|
67
83
|
end
|
68
84
|
|
69
85
|
it "should be case-insensitive" do
|
70
|
-
|
71
|
-
|
72
|
-
|
86
|
+
subject.should be_whitelisted "apache2"
|
87
|
+
subject.should be_whitelisted "apache 2.0"
|
88
|
+
subject.should be_whitelisted "apache-2.0"
|
73
89
|
end
|
74
90
|
end
|
75
91
|
end
|
76
92
|
|
77
93
|
describe "#save" do
|
78
|
-
|
79
|
-
|
94
|
+
def attributes # can't be a let... the caching causes polution
|
95
|
+
{
|
96
|
+
'whitelist' => ['my_gem'],
|
97
|
+
'ignore_groups' => ['other_group', 'test'],
|
98
|
+
'project_name' => "New Project Name",
|
99
|
+
'dependencies_file_dir' => "./deps"
|
100
|
+
}
|
101
|
+
end
|
80
102
|
|
81
|
-
|
82
|
-
Configuration.
|
83
|
-
|
84
|
-
config.ignore_groups = ['other_group', 'test']
|
85
|
-
config.project_name = "New Project Name"
|
86
|
-
config.dependencies_dir = "./deps"
|
103
|
+
it "persists the configuration attributes" do
|
104
|
+
Configuration::Persistence.should_receive(:set).with(attributes)
|
105
|
+
described_class.new(attributes).save
|
87
106
|
end
|
88
107
|
|
89
|
-
|
90
|
-
|
108
|
+
it "doesn't persist duplicate entries" do
|
109
|
+
config = described_class.new(attributes)
|
110
|
+
config.whitelist << 'my_gem'
|
111
|
+
config.ignore_groups << 'test'
|
112
|
+
|
113
|
+
Configuration::Persistence.should_receive(:set).with(attributes)
|
114
|
+
config.save
|
91
115
|
end
|
116
|
+
end
|
117
|
+
end
|
92
118
|
|
93
|
-
|
94
|
-
|
119
|
+
describe Configuration::Persistence do
|
120
|
+
describe ".get" do
|
121
|
+
it "should use saved configuration" do
|
122
|
+
file = double(:file,
|
123
|
+
:exist? => true,
|
124
|
+
:read => {'some' => 'config'}.to_yaml)
|
125
|
+
described_class.stub(:file).and_return(file)
|
95
126
|
|
96
|
-
|
97
|
-
|
98
|
-
end
|
127
|
+
described_class.get.should == {'some' => 'config'}
|
128
|
+
end
|
99
129
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
end
|
130
|
+
it "should not mind if config is not saved" do
|
131
|
+
file = double(:file, :exist? => false)
|
132
|
+
described_class.stub(:file).and_return(file)
|
104
133
|
|
105
|
-
|
106
|
-
|
107
|
-
|
134
|
+
file.should_not_receive(:read)
|
135
|
+
described_class.get.should == {}
|
136
|
+
end
|
137
|
+
end
|
108
138
|
|
109
|
-
|
110
|
-
|
111
|
-
|
139
|
+
describe ".set" do
|
140
|
+
let(:tmp_yml) { '.tmp.configuration_spec.yml' }
|
141
|
+
|
142
|
+
after do
|
143
|
+
File.delete(tmp_yml)
|
112
144
|
end
|
113
145
|
|
114
|
-
it "
|
115
|
-
|
116
|
-
config.ignore_groups << 'test'
|
146
|
+
it "writes the configuration attributes to the yaml file" do
|
147
|
+
described_class.stub(:file).and_return(Pathname.new(tmp_yml))
|
117
148
|
|
118
|
-
config
|
149
|
+
described_class.set('some' => 'config')
|
150
|
+
described_class.get.should == {'some' => 'config'}
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
describe ".init" do
|
155
|
+
it "initializes the config file" do
|
156
|
+
file = double(:file, :exist? => false)
|
157
|
+
described_class.stub(:file).and_return(file)
|
158
|
+
|
159
|
+
FileUtils.should_receive(:cp).with(described_class.send(:file_template), file)
|
160
|
+
described_class.init
|
161
|
+
end
|
162
|
+
|
163
|
+
it "does nothing if there is already a config file" do
|
164
|
+
file = double(:file, :exist? => true)
|
165
|
+
described_class.stub(:file).and_return(file)
|
119
166
|
|
120
|
-
|
121
|
-
|
167
|
+
FileUtils.should_not_receive(:cp)
|
168
|
+
described_class.init
|
122
169
|
end
|
123
170
|
end
|
124
171
|
end
|
@@ -2,11 +2,10 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module LicenseFinder
|
4
4
|
describe DependencyManager do
|
5
|
-
let(:config) { Configuration.new }
|
5
|
+
let(:config) { Configuration.new('whitelist' => ['MIT', 'other']) }
|
6
6
|
|
7
7
|
before do
|
8
8
|
LicenseFinder.stub(:config).and_return config
|
9
|
-
config.whitelist = ["MIT", "other"]
|
10
9
|
Reporter.stub(:write_reports)
|
11
10
|
end
|
12
11
|
|
@@ -55,6 +54,13 @@ module LicenseFinder
|
|
55
54
|
expect { described_class.create_manually_managed("GPL", "current dependency 1", "0.0.0") }
|
56
55
|
.to raise_error(LicenseFinder::Error)
|
57
56
|
end
|
57
|
+
|
58
|
+
it "re-uses an existing, unassociated, license alias" do
|
59
|
+
existing_license = LicenseAlias.named("existing license")
|
60
|
+
|
61
|
+
dep = described_class.create_manually_managed("existing license", "js_dep", "0.0.0")
|
62
|
+
dep.license.should == existing_license
|
63
|
+
end
|
58
64
|
end
|
59
65
|
|
60
66
|
describe ".destroy_manually_managed" do
|
@@ -105,8 +111,13 @@ module LicenseFinder
|
|
105
111
|
end
|
106
112
|
|
107
113
|
describe ".modifying" do
|
114
|
+
let(:file_exists) { double(:file, :exist? => true) }
|
115
|
+
let(:file_does_not_exist) { double(:file, :exist? => false) }
|
116
|
+
|
108
117
|
context "when the database doesn't exist" do
|
109
|
-
before
|
118
|
+
before do
|
119
|
+
config.artifacts.stub(:database_file).and_return(file_does_not_exist)
|
120
|
+
end
|
110
121
|
|
111
122
|
it "writes reports" do
|
112
123
|
Reporter.should_receive(:write_reports)
|
@@ -115,7 +126,9 @@ module LicenseFinder
|
|
115
126
|
end
|
116
127
|
|
117
128
|
context "when the database exists" do
|
118
|
-
before
|
129
|
+
before do
|
130
|
+
config.artifacts.stub(:database_file).and_return(file_exists)
|
131
|
+
end
|
119
132
|
|
120
133
|
context "when the database has changed" do
|
121
134
|
before do
|
@@ -134,21 +147,26 @@ module LicenseFinder
|
|
134
147
|
Digest::SHA2.stub_chain(:file, :hexdigest) { 5 }
|
135
148
|
end
|
136
149
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
end
|
150
|
+
context "when the reports exist" do
|
151
|
+
before do
|
152
|
+
config.artifacts.stub(:html_file).and_return(file_exists)
|
153
|
+
end
|
142
154
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
155
|
+
it "does not write reports" do
|
156
|
+
Reporter.should_not_receive(:write_reports)
|
157
|
+
DependencyManager.modifying {}
|
158
|
+
end
|
147
159
|
end
|
148
160
|
|
149
|
-
|
150
|
-
|
151
|
-
|
161
|
+
context "when the reports do not exist" do
|
162
|
+
before do
|
163
|
+
config.artifacts.stub(:html_file).and_return(file_does_not_exist)
|
164
|
+
end
|
165
|
+
|
166
|
+
it "writes reports" do
|
167
|
+
Reporter.should_receive(:write_reports)
|
168
|
+
DependencyManager.modifying {}
|
169
|
+
end
|
152
170
|
end
|
153
171
|
end
|
154
172
|
end
|