license_finder 0.4.1 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +2 -1
- data/.rspec +1 -0
- data/{MIT-LICENSE → LICENSE} +1 -1
- data/README.markdown +125 -75
- data/Rakefile +9 -0
- data/features/rake_tasks/action_items.feature +13 -0
- data/features/rake_tasks/action_items_ok.feature +20 -0
- data/features/rake_tasks/generate_dependencies.feature +31 -0
- data/features/rake_tasks/init.feature +19 -0
- data/features/step_definitions/steps.rb +131 -0
- data/files/license_finder.yml +3 -2
- data/lib/license_finder.rb +29 -0
- data/lib/license_finder/dependency.rb +13 -14
- data/lib/license_finder/dependency_list.rb +23 -5
- data/lib/license_finder/finder.rb +6 -19
- data/lib/license_finder/gem_spec_details.rb +11 -3
- data/lib/license_finder/license_file.rb +21 -7
- data/lib/templates/ISC-body +2 -0
- data/lib/templates/LGPL-body +165 -0
- data/license_finder.gemspec +11 -16
- data/spec/fixtures/ISC-LICENSE +10 -0
- data/spec/fixtures/isc_licensed_gem/LICENSE +10 -0
- data/spec/fixtures/lgpl_licensed_gem/LICENSE +165 -0
- data/spec/{dependency_list_spec.rb → lib/license_finder/dependency_list_spec.rb} +26 -23
- data/spec/lib/license_finder/dependency_spec.rb +53 -0
- data/spec/{file_parser_spec.rb → lib/license_finder/file_parser_spec.rb} +0 -0
- data/spec/lib/license_finder/finder_spec.rb +36 -0
- data/spec/{gem_spec_details_spec.rb → lib/license_finder/gem_spec_details_spec.rb} +25 -8
- data/spec/{license_file_spec.rb → lib/license_finder/license_file_spec.rb} +38 -22
- data/spec/lib/license_finder_spec.rb +82 -0
- metadata +100 -32
- data/lib/license_finder/version.rb +0 -3
- data/spec/dependency_spec.rb +0 -57
- data/spec/finder_spec.rb +0 -64
data/license_finder.gemspec
CHANGED
@@ -1,24 +1,19 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "license_finder/version"
|
4
|
-
|
5
1
|
Gem::Specification.new do |s|
|
6
2
|
s.name = "license_finder"
|
7
|
-
s.version =
|
8
|
-
s.
|
9
|
-
s.
|
10
|
-
s.
|
11
|
-
|
12
|
-
s.
|
13
|
-
s.
|
3
|
+
s.version = "0.4.5"
|
4
|
+
s.authors = ["Jacob Maine", "Matthew Kane Parker", "Ian Lesperance", "David Edwards"]
|
5
|
+
s.email = ["brent@pivotalabs.com"]
|
6
|
+
s.homepage = "https://github.com/pivotal/LicenseFinder"
|
7
|
+
s.summary = "Know your dependencies - and the licenses they are binding your application to."
|
8
|
+
s.description = "Find and display licenses of a project's gem dependencies, so that you know what your limitations are when distributing your application."
|
9
|
+
s.license = "MIT"
|
14
10
|
|
15
|
-
s.
|
16
|
-
|
17
|
-
|
18
|
-
|
11
|
+
s.add_development_dependency "rails", ">=3"
|
12
|
+
%w(rspec rr rake cucumber rails).each do |gem|
|
13
|
+
s.add_development_dependency gem
|
14
|
+
end
|
19
15
|
|
20
16
|
s.files = `git ls-files`.split("\n")
|
21
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
22
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
23
|
-
s.require_paths = ["lib"]
|
24
19
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Copyright (c) 2012, Pivotal Labs
|
2
|
+
|
3
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted,
|
4
|
+
provided that the above copyright notice and this permission notice appear in all copies.
|
5
|
+
|
6
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
7
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
8
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
9
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
10
|
+
THIS SOFTWARE.
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Copyright (c) 2012, Pivotal Labs
|
2
|
+
|
3
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted,
|
4
|
+
provided that the above copyright notice and this permission notice appear in all copies.
|
5
|
+
|
6
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
7
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
8
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
9
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
10
|
+
THIS SOFTWARE.
|
@@ -0,0 +1,165 @@
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
2
|
+
Version 3, 29 June 2007
|
3
|
+
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
6
|
+
of this license document, but changing it is not allowed.
|
7
|
+
|
8
|
+
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
11
|
+
License, supplemented by the additional permissions listed below.
|
12
|
+
|
13
|
+
0. Additional Definitions.
|
14
|
+
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
17
|
+
General Public License.
|
18
|
+
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
20
|
+
other than an Application or a Combined Work as defined below.
|
21
|
+
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
25
|
+
of using an interface provided by the Library.
|
26
|
+
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
28
|
+
Application with the Library. The particular version of the Library
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
30
|
+
Version".
|
31
|
+
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
35
|
+
based on the Application, and not on the Linked Version.
|
36
|
+
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
38
|
+
object code and/or source code for the Application, including any data
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
41
|
+
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
43
|
+
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
46
|
+
|
47
|
+
2. Conveying Modified Versions.
|
48
|
+
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
51
|
+
that uses the facility (other than as an argument passed when the
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
53
|
+
version:
|
54
|
+
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
56
|
+
ensure that, in the event an Application does not supply the
|
57
|
+
function or data, the facility still operates, and performs
|
58
|
+
whatever part of its purpose remains meaningful, or
|
59
|
+
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
61
|
+
this License applicable to that copy.
|
62
|
+
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
64
|
+
|
65
|
+
The object code form of an Application may incorporate material from
|
66
|
+
a header file that is part of the Library. You may convey such object
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
68
|
+
material is not limited to numerical parameters, data structure
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
71
|
+
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
73
|
+
Library is used in it and that the Library and its use are
|
74
|
+
covered by this License.
|
75
|
+
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
77
|
+
document.
|
78
|
+
|
79
|
+
4. Combined Works.
|
80
|
+
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
82
|
+
taken together, effectively do not restrict modification of the
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
85
|
+
the following:
|
86
|
+
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
88
|
+
the Library is used in it and that the Library and its use are
|
89
|
+
covered by this License.
|
90
|
+
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
92
|
+
document.
|
93
|
+
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
95
|
+
execution, include the copyright notice for the Library among
|
96
|
+
these notices, as well as a reference directing the user to the
|
97
|
+
copies of the GNU GPL and this license document.
|
98
|
+
|
99
|
+
d) Do one of the following:
|
100
|
+
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
102
|
+
License, and the Corresponding Application Code in a form
|
103
|
+
suitable for, and under terms that permit, the user to
|
104
|
+
recombine or relink the Application with a modified version of
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
107
|
+
Corresponding Source.
|
108
|
+
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
111
|
+
a copy of the Library already present on the user's computer
|
112
|
+
system, and (b) will operate properly with a modified version
|
113
|
+
of the Library that is interface-compatible with the Linked
|
114
|
+
Version.
|
115
|
+
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
117
|
+
be required to provide such information under section 6 of the
|
118
|
+
GNU GPL, and only to the extent that such information is
|
119
|
+
necessary to install and execute a modified version of the
|
120
|
+
Combined Work produced by recombining or relinking the
|
121
|
+
Application with a modified version of the Linked Version. (If
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
126
|
+
for conveying Corresponding Source.)
|
127
|
+
|
128
|
+
5. Combined Libraries.
|
129
|
+
|
130
|
+
You may place library facilities that are a work based on the
|
131
|
+
Library side by side in a single library together with other library
|
132
|
+
facilities that are not Applications and are not covered by this
|
133
|
+
License, and convey such a combined library under terms of your
|
134
|
+
choice, if you do both of the following:
|
135
|
+
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
137
|
+
on the Library, uncombined with any other library facilities,
|
138
|
+
conveyed under the terms of this License.
|
139
|
+
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
141
|
+
is a work based on the Library, and explaining where to find the
|
142
|
+
accompanying uncombined form of the same work.
|
143
|
+
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
145
|
+
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
148
|
+
versions will be similar in spirit to the present version, but may
|
149
|
+
differ in detail to address new problems or concerns.
|
150
|
+
|
151
|
+
Each version is given a distinguishing version number. If the
|
152
|
+
Library as you received it specifies that a certain numbered version
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
154
|
+
applies to it, you have the option of following the terms and
|
155
|
+
conditions either of that published version or of any later version
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
160
|
+
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
164
|
+
permanent authorization for you to choose that version for the
|
165
|
+
Library.
|
@@ -2,6 +2,10 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe LicenseFinder::DependencyList do
|
4
4
|
before do
|
5
|
+
config = stub(LicenseFinder).config.stub!
|
6
|
+
config.whitelist { [] }
|
7
|
+
config.ignore_groups { [] }
|
8
|
+
|
5
9
|
@mock_gemspec = Class.new do
|
6
10
|
def initialize(name = nil, version = nil, path = nil)
|
7
11
|
@name = name
|
@@ -25,7 +29,6 @@ describe LicenseFinder::DependencyList do
|
|
25
29
|
nil
|
26
30
|
end
|
27
31
|
end
|
28
|
-
|
29
32
|
end
|
30
33
|
|
31
34
|
describe 'from Bundler' do
|
@@ -79,8 +82,8 @@ describe LicenseFinder::DependencyList do
|
|
79
82
|
describe 'to_yaml' do
|
80
83
|
it "should generate yaml" do
|
81
84
|
list = LicenseFinder::DependencyList.new([
|
82
|
-
LicenseFinder::Dependency.new('b_gem', '0.4.2', 'MIT', false),
|
83
|
-
LicenseFinder::Dependency.new('a_gem', '1.2.3', 'MIT', false)
|
85
|
+
LicenseFinder::Dependency.new('name' => 'b_gem', 'version' => '0.4.2', 'license' => 'MIT', 'approved' => false),
|
86
|
+
LicenseFinder::Dependency.new('name' => 'a_gem', 'version' => '1.2.3', 'license' => 'MIT', 'approved' => false)
|
84
87
|
])
|
85
88
|
|
86
89
|
list.to_yaml.should == "--- \n- name: \"a_gem\"\n version: \"1.2.3\"\n license: \"MIT\"\n approved: false\n license_url: \"\"\n notes: \"\"\n license_files:\n readme_files:\n- name: \"b_gem\"\n version: \"0.4.2\"\n license: \"MIT\"\n approved: false\n license_url: \"\"\n notes: \"\"\n license_files:\n readme_files:\n"
|
@@ -90,8 +93,8 @@ describe LicenseFinder::DependencyList do
|
|
90
93
|
describe 'round trip' do
|
91
94
|
it 'should recreate from to_yaml' do
|
92
95
|
list = LicenseFinder::DependencyList.new([
|
93
|
-
LicenseFinder::Dependency.new('gem1', '1.2.3', 'MIT', false),
|
94
|
-
LicenseFinder::Dependency.new('gem2', '0.4.2', 'MIT', false)
|
96
|
+
LicenseFinder::Dependency.new('name' => 'gem1', 'version' => '1.2.3', 'license' => 'MIT', 'approved' => false),
|
97
|
+
LicenseFinder::Dependency.new('name' => 'gem2', 'version' => '0.4.2', 'license' => 'MIT', 'approved' => false)
|
95
98
|
])
|
96
99
|
|
97
100
|
new_list = LicenseFinder::DependencyList.from_yaml(list.to_yaml)
|
@@ -103,19 +106,19 @@ describe LicenseFinder::DependencyList do
|
|
103
106
|
|
104
107
|
describe 'updating dependency list' do
|
105
108
|
before(:each) do
|
106
|
-
@yml_same = LicenseFinder::Dependency.new('same_gem', '1.2.3', 'MIT', true, 'a', 'b')
|
107
|
-
@yml_updated = LicenseFinder::Dependency.new('updated_gem', '1.0.1', 'MIT', true, 'a', 'b')
|
108
|
-
@yml_new_license = LicenseFinder::Dependency.new('new_license_gem', '1.0.1', 'MIT', true, 'a', 'b')
|
109
|
-
@yml_manual_license = LicenseFinder::Dependency.new('manual_license_gem', '1.0.1', 'Ruby', true, 'a', 'b')
|
110
|
-
@yml_removed_gem = LicenseFinder::Dependency.new('removed_gem', '1.0.1', 'MIT', true, 'a', 'b')
|
111
|
-
@yml_new_whitelist = LicenseFinder::Dependency.new('new_whitelist_gem', '1.0.1', 'MIT', false, 'a', 'b')
|
112
|
-
|
113
|
-
@gemspec_same = LicenseFinder::Dependency.new('same_gem', '1.2.3', 'MIT', false)
|
114
|
-
@gemspec_new = LicenseFinder::Dependency.new('brand_new_gem', '0.9', 'MIT', false)
|
115
|
-
@gemspec_updated = LicenseFinder::Dependency.new('updated_gem', '1.1.2', 'MIT', false)
|
116
|
-
@gemspec_new_license = LicenseFinder::Dependency.new('new_license_gem', '2.0.1', 'Apache 2.0', false)
|
117
|
-
@gemspec_new_whitelist = LicenseFinder::Dependency.new('new_whitelist_gem', '1.0.1', 'MIT', true)
|
118
|
-
@gemspec_manual_license = LicenseFinder::Dependency.new('manual_license_gem', '1.2.1', 'other', false)
|
109
|
+
@yml_same = LicenseFinder::Dependency.new('name' => 'same_gem', 'version' => '1.2.3', 'license' => 'MIT', 'approved' => true, 'license_url' => 'a', 'notes' => 'b')
|
110
|
+
@yml_updated = LicenseFinder::Dependency.new('name' => 'updated_gem', 'version' => '1.0.1', 'license' => 'MIT', 'approved' => true, 'license_url' => 'a', 'notes' => 'b')
|
111
|
+
@yml_new_license = LicenseFinder::Dependency.new('name' => 'new_license_gem', 'version' => '1.0.1', 'license' => 'MIT', 'approved' => true, 'license_url' => 'a', 'notes' => 'b')
|
112
|
+
@yml_manual_license = LicenseFinder::Dependency.new('name' => 'manual_license_gem', 'version' => '1.0.1', 'license' => 'Ruby', 'approved' => true, 'license_url' => 'a', 'notes' => 'b')
|
113
|
+
@yml_removed_gem = LicenseFinder::Dependency.new('name' => 'removed_gem', 'version' => '1.0.1', 'license' => 'MIT', 'approved' => true, 'license_url' => 'a', 'notes' => 'b')
|
114
|
+
@yml_new_whitelist = LicenseFinder::Dependency.new('name' => 'new_whitelist_gem', 'version' => '1.0.1', 'license' => 'MIT', 'approved' => false, 'license_url' => 'a', 'notes' => 'b')
|
115
|
+
|
116
|
+
@gemspec_same = LicenseFinder::Dependency.new('name' => 'same_gem', 'version' => '1.2.3', 'license' => 'MIT', 'approved' => false)
|
117
|
+
@gemspec_new = LicenseFinder::Dependency.new('name' => 'brand_new_gem', 'version' => '0.9', 'license' => 'MIT', 'approved' => false)
|
118
|
+
@gemspec_updated = LicenseFinder::Dependency.new('name' => 'updated_gem', 'version' => '1.1.2', 'license' => 'MIT', 'approved' => false)
|
119
|
+
@gemspec_new_license = LicenseFinder::Dependency.new('name' => 'new_license_gem', 'version' => '2.0.1', 'license' => 'Apache 2.0', 'approved' => false)
|
120
|
+
@gemspec_new_whitelist = LicenseFinder::Dependency.new('name' => 'new_whitelist_gem', 'version' => '1.0.1', 'license' => 'MIT', 'approved' => true)
|
121
|
+
@gemspec_manual_license = LicenseFinder::Dependency.new('name' => 'manual_license_gem', 'version' => '1.2.1', 'license' => 'other', 'approved' => false)
|
119
122
|
|
120
123
|
@list_from_yml = LicenseFinder::DependencyList.new([@yml_same, @yml_updated, @yml_new_license, @yml_removed_gem, @yml_new_whitelist, @yml_manual_license])
|
121
124
|
@list_from_gemspec = LicenseFinder::DependencyList.new([@gemspec_same, @gemspec_new, @gemspec_updated, @gemspec_new_license, @gemspec_new_whitelist, @gemspec_manual_license])
|
@@ -181,8 +184,8 @@ describe LicenseFinder::DependencyList do
|
|
181
184
|
|
182
185
|
describe "#to_s" do
|
183
186
|
it "should return a human readable list of dependencies" do
|
184
|
-
gem1 = LicenseFinder::Dependency.new('b_gem', '1.2.3', 'MIT', true)
|
185
|
-
gem2 = LicenseFinder::Dependency.new('a_gem', '0.9', 'other', false, 'http://foo.com/LICENSE')
|
187
|
+
gem1 = LicenseFinder::Dependency.new('name' => 'b_gem', 'version' => '1.2.3', 'license' => 'MIT', 'approved' => true)
|
188
|
+
gem2 = LicenseFinder::Dependency.new('name' => 'a_gem', 'version' => '0.9', 'license' => 'other', 'approved' => false, 'license_url' => 'http://foo.com/LICENSE')
|
186
189
|
|
187
190
|
list = LicenseFinder::DependencyList.new([gem1, gem2])
|
188
191
|
|
@@ -192,9 +195,9 @@ describe LicenseFinder::DependencyList do
|
|
192
195
|
|
193
196
|
describe '#action_items' do
|
194
197
|
it "should return all unapproved dependencies" do
|
195
|
-
gem1 = LicenseFinder::Dependency.new('b_gem', '1.2.3', 'MIT', true)
|
196
|
-
gem2 = LicenseFinder::Dependency.new('a_gem', '0.9', 'other', false)
|
197
|
-
gem3 = LicenseFinder::Dependency.new('c_gem', '0.2', 'other', false)
|
198
|
+
gem1 = LicenseFinder::Dependency.new('name' => 'b_gem', 'version' => '1.2.3', 'license' => 'MIT', 'approved' => true)
|
199
|
+
gem2 = LicenseFinder::Dependency.new('name' => 'a_gem', 'version' => '0.9', 'license' => 'other', 'approved' => false)
|
200
|
+
gem3 = LicenseFinder::Dependency.new('name' => 'c_gem', 'version' => '0.2', 'license' => 'other', 'approved' => false)
|
198
201
|
|
199
202
|
list = LicenseFinder::DependencyList.new([gem1, gem2, gem3])
|
200
203
|
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LicenseFinder::Dependency do
|
4
|
+
let(:attributes) do
|
5
|
+
{
|
6
|
+
'name' => "spec_name",
|
7
|
+
'version' => "2.1.3",
|
8
|
+
'license' => "GPL",
|
9
|
+
'approved' => false,
|
10
|
+
'license_url' => 'http://www.apache.org/licenses/LICENSE-2.0.html',
|
11
|
+
'notes' => 'some notes',
|
12
|
+
'license_files' => [{'path' => '/Users/pivotal/foo/lic1'}, {'path' => '/Users/pivotal/bar/lic2'}],
|
13
|
+
'readme_files' => [{'path' => '/Users/pivotal/foo/Readme1'}, {'path' => '/Users/pivotal/bar/Readme2'}]
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
before do
|
18
|
+
stub(LicenseFinder).config.stub!.whitelist { %w(MIT) }
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '.new' do
|
22
|
+
it "should mark it as approved when the license is whitelisted" do
|
23
|
+
dependency = LicenseFinder::Dependency.new(attributes.merge('license' => 'MIT', 'approved' => false))
|
24
|
+
dependency.approved.should == true
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should not mark it as approved when the license is not whitelisted" do
|
28
|
+
dependency = LicenseFinder::Dependency.new(attributes.merge('license' => 'GPL', 'approved' => false))
|
29
|
+
dependency.approved.should == false
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should leave it as approved when the license is not whitelisted but it has already been marked as approved" do
|
33
|
+
dependency = LicenseFinder::Dependency.new(attributes.merge('license' => 'GPL', 'approved' => true))
|
34
|
+
dependency.approved.should == true
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '.from_hash' do
|
39
|
+
subject { LicenseFinder::Dependency.from_hash(attributes) }
|
40
|
+
|
41
|
+
its(:name) { should == 'spec_name' }
|
42
|
+
its(:version) { should == '2.1.3' }
|
43
|
+
its(:license) { should == 'GPL' }
|
44
|
+
its(:approved) { should == false }
|
45
|
+
its(:license_url) { should == "http://www.apache.org/licenses/LICENSE-2.0.html" }
|
46
|
+
its(:notes) { should == "some notes" }
|
47
|
+
its(:license_files) { should == ["/Users/pivotal/foo/lic1", "/Users/pivotal/bar/lic2"] }
|
48
|
+
its(:readme_files) { should == ["/Users/pivotal/foo/Readme1", "/Users/pivotal/bar/Readme2"] }
|
49
|
+
its(:to_yaml_entry) { should == "- name: \"spec_name\"\n version: \"2.1.3\"\n license: \"GPL\"\n approved: false\n license_url: \"http://www.apache.org/licenses/LICENSE-2.0.html\"\n notes: \"some notes\"\n license_files:\n - path: \"/Users/pivotal/foo/lic1\"\n - path: \"/Users/pivotal/bar/lic2\"\n readme_files:\n - path: \"/Users/pivotal/foo/Readme1\"\n - path: \"/Users/pivotal/bar/Readme2\"\n" }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
|
File without changes
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LicenseFinder::Finder do
|
4
|
+
before do
|
5
|
+
config = stub(LicenseFinder).config.stub!
|
6
|
+
config.dependencies_yaml { './dependencies.yml' }
|
7
|
+
config.dependencies_text { './dependencies.txt' }
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should generate a yml file and txt file" do
|
11
|
+
stub(File).exists?('./dependencies.yml') {false}
|
12
|
+
|
13
|
+
yml_output = StringIO.new
|
14
|
+
txt_output = StringIO.new
|
15
|
+
stub(File).open('./dependencies.yml', 'w+').yields(yml_output)
|
16
|
+
stub(File).open('./dependencies.txt', 'w+').yields(txt_output)
|
17
|
+
stub(LicenseFinder::DependencyList).from_bundler.stub!.to_yaml {"output"}
|
18
|
+
LicenseFinder::Finder.new.write_files
|
19
|
+
yml_output.string.should == "output\n"
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should update an existing yml file' do
|
23
|
+
stub(File).exists?('./dependencies.yml') {true}
|
24
|
+
|
25
|
+
yml_output = StringIO.new
|
26
|
+
txt_output = StringIO.new
|
27
|
+
stub(File).open('./dependencies.yml').stub!.readlines {['existing yml']}
|
28
|
+
stub(File).open('./dependencies.yml', 'w+').yields(yml_output)
|
29
|
+
stub(File).open('./dependencies.txt', 'w+').yields(txt_output)
|
30
|
+
|
31
|
+
stub(LicenseFinder::DependencyList).from_yaml.stub!.merge.stub!.to_yaml {"output"}
|
32
|
+
stub(LicenseFinder::DependencyList).from_bundler
|
33
|
+
LicenseFinder::Finder.new.write_files
|
34
|
+
yml_output.string.should == "output\n"
|
35
|
+
end
|
36
|
+
end
|
@@ -17,7 +17,7 @@ describe LicenseFinder::GemSpecDetails do
|
|
17
17
|
|
18
18
|
def full_gem_path
|
19
19
|
if @path
|
20
|
-
gem_install_path = File.join(File.dirname(__FILE__), '
|
20
|
+
gem_install_path = File.join(File.dirname(__FILE__), '..', '..', '..', @path)
|
21
21
|
raise Errno::ENOENT, @path unless File.exists?(gem_install_path)
|
22
22
|
gem_install_path
|
23
23
|
else
|
@@ -111,9 +111,13 @@ describe LicenseFinder::GemSpecDetails do
|
|
111
111
|
end
|
112
112
|
|
113
113
|
describe 'to dependency' do
|
114
|
+
before do
|
115
|
+
stub(LicenseFinder).config.stub!.whitelist { ['MIT', 'Apache 2.0', 'LGPL', 'GPLv2'] }
|
116
|
+
end
|
117
|
+
|
114
118
|
describe 'with MIT License' do
|
115
119
|
subject do
|
116
|
-
LicenseFinder::GemSpecDetails.new(@mock_gemspec.new('spec/fixtures/mit_licensed_gem')
|
120
|
+
LicenseFinder::GemSpecDetails.new(@mock_gemspec.new('spec/fixtures/mit_licensed_gem')).dependency
|
117
121
|
end
|
118
122
|
|
119
123
|
its(:name) { should == 'spec_name' }
|
@@ -126,7 +130,7 @@ describe LicenseFinder::GemSpecDetails do
|
|
126
130
|
|
127
131
|
describe 'with MIT License in README' do
|
128
132
|
subject do
|
129
|
-
LicenseFinder::GemSpecDetails.new(@mock_gemspec.new('spec/fixtures/mit_licensed_gem_in_README')
|
133
|
+
LicenseFinder::GemSpecDetails.new(@mock_gemspec.new('spec/fixtures/mit_licensed_gem_in_README')).dependency
|
130
134
|
end
|
131
135
|
|
132
136
|
its(:name) { should == 'spec_name' }
|
@@ -139,7 +143,7 @@ describe LicenseFinder::GemSpecDetails do
|
|
139
143
|
|
140
144
|
describe 'with MIT License in README' do
|
141
145
|
subject do
|
142
|
-
LicenseFinder::GemSpecDetails.new(@mock_gemspec.new('spec/fixtures/mit_licensed_gem_via_url')
|
146
|
+
LicenseFinder::GemSpecDetails.new(@mock_gemspec.new('spec/fixtures/mit_licensed_gem_via_url')).dependency
|
143
147
|
end
|
144
148
|
|
145
149
|
its(:name) { should == 'spec_name' }
|
@@ -150,10 +154,9 @@ describe LicenseFinder::GemSpecDetails do
|
|
150
154
|
its(:notes) { should == '' }
|
151
155
|
end
|
152
156
|
|
153
|
-
|
154
157
|
describe 'with MIT License with hashes' do
|
155
158
|
subject do
|
156
|
-
LicenseFinder::GemSpecDetails.new(@mock_gemspec.new('spec/fixtures/mit_licensed_with_hashes')
|
159
|
+
LicenseFinder::GemSpecDetails.new(@mock_gemspec.new('spec/fixtures/mit_licensed_with_hashes')).dependency
|
157
160
|
end
|
158
161
|
|
159
162
|
its(:name) { should == 'spec_name' }
|
@@ -166,7 +169,7 @@ describe LicenseFinder::GemSpecDetails do
|
|
166
169
|
|
167
170
|
describe 'with Apache License' do
|
168
171
|
subject do
|
169
|
-
LicenseFinder::GemSpecDetails.new(@mock_gemspec.new('spec/fixtures/apache_licensed_gem')
|
172
|
+
LicenseFinder::GemSpecDetails.new(@mock_gemspec.new('spec/fixtures/apache_licensed_gem')).dependency
|
170
173
|
end
|
171
174
|
|
172
175
|
its(:name) { should == 'spec_name' }
|
@@ -179,7 +182,7 @@ describe LicenseFinder::GemSpecDetails do
|
|
179
182
|
|
180
183
|
describe 'with GPLv2 License' do
|
181
184
|
subject do
|
182
|
-
LicenseFinder::GemSpecDetails.new(@mock_gemspec.new('spec/fixtures/gplv2_licensed_gem')
|
185
|
+
LicenseFinder::GemSpecDetails.new(@mock_gemspec.new('spec/fixtures/gplv2_licensed_gem')).dependency
|
183
186
|
end
|
184
187
|
|
185
188
|
its(:name) { should == 'spec_name' }
|
@@ -190,6 +193,20 @@ describe LicenseFinder::GemSpecDetails do
|
|
190
193
|
its(:notes) { should == '' }
|
191
194
|
end
|
192
195
|
|
196
|
+
describe 'with LGPL License' do
|
197
|
+
it "should detect the license as LGPL" do
|
198
|
+
dependency = LicenseFinder::GemSpecDetails.new(@mock_gemspec.new('spec/fixtures/lgpl_licensed_gem')).dependency
|
199
|
+
dependency.license.should == "LGPL"
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
describe 'with ISC License' do
|
204
|
+
it "should detect the license as ISC" do
|
205
|
+
dependency = LicenseFinder::GemSpecDetails.new(@mock_gemspec.new('spec/fixtures/isc_licensed_gem')).dependency
|
206
|
+
dependency.license.should == "ISC"
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
193
210
|
describe 'with unknown license' do
|
194
211
|
subject { LicenseFinder::GemSpecDetails.new(@mock_gemspec.new('spec/fixtures/other_licensed_gem')).dependency }
|
195
212
|
|