license_finder 0.9.1 → 0.9.2

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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.rdoc +11 -1
  3. data/features/node_dependencies.feature +9 -0
  4. data/features/python_dependencies.feature +9 -0
  5. data/features/step_definitions/html_report_steps.rb +3 -1
  6. data/features/step_definitions/node_steps.rb +8 -0
  7. data/features/step_definitions/python_steps.rb +8 -0
  8. data/features/step_definitions/shared_steps.rb +48 -0
  9. data/lib/data/licenses/Python.txt +47 -0
  10. data/lib/license_finder.rb +4 -2
  11. data/lib/license_finder/bundle.rb +15 -9
  12. data/lib/license_finder/dependency_manager.rb +14 -1
  13. data/lib/license_finder/license/apache2.rb +1 -1
  14. data/lib/license_finder/license/bsd.rb +1 -1
  15. data/lib/license_finder/license/mit.rb +1 -1
  16. data/lib/license_finder/license/python.rb +8 -0
  17. data/lib/license_finder/npm.rb +56 -0
  18. data/lib/license_finder/{bundled_gem.rb → package.rb} +45 -3
  19. data/lib/license_finder/{bundled_gem_saver.rb → package_saver.rb} +15 -13
  20. data/lib/license_finder/pip.rb +59 -0
  21. data/lib/license_finder/reports/html_report.rb +10 -1
  22. data/lib/templates/html_report.erb +14 -12
  23. data/license_finder.gemspec +3 -1
  24. data/readme.md +10 -4
  25. data/release/manual_instructions.md +7 -6
  26. data/spec/lib/license_finder/bundle_spec.rb +24 -0
  27. data/spec/lib/license_finder/dependency_manager_spec.rb +4 -4
  28. data/spec/lib/license_finder/license/python_spec.rb +7 -0
  29. data/spec/lib/license_finder/npm_spec.rb +79 -0
  30. data/spec/lib/license_finder/{bundled_gem_saver_spec.rb → package_saver_spec.rb} +17 -17
  31. data/spec/lib/license_finder/{bundled_gem_spec.rb → package_spec.rb} +20 -2
  32. data/spec/lib/license_finder/pip_spec.rb +89 -0
  33. data/spec/spec_helper.rb +1 -0
  34. data/spec/support/license_examples.rb +1 -1
  35. metadata +55 -9
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module LicenseFinder
4
- describe BundledGem do
4
+ describe Package do
5
5
  subject { described_class.new(gemspec) }
6
6
 
7
7
  let(:gemspec) do
@@ -26,7 +26,7 @@ module LicenseFinder
26
26
 
27
27
  describe "#license" do
28
28
  subject do
29
- details = BundledGem.new(gemspec)
29
+ details = Package.new(gemspec)
30
30
  details.stub(:license_files).and_return([license_file])
31
31
  details
32
32
  end
@@ -77,4 +77,22 @@ module LicenseFinder
77
77
  end
78
78
  end
79
79
  end
80
+
81
+ describe PythonPackage do
82
+ it "calls out to Pip if no license is found using conventional means" do
83
+ allow(Pip).to receive(:license_for).and_return("PSF")
84
+
85
+ package = PythonPackage.new(OpenStruct.new(name: 'jasmine', version: '1.3.1', full_gem_path: '/foo/bar'))
86
+
87
+ expect(package.determine_license).to eq("PSF")
88
+ end
89
+
90
+ it "returns other if no license could be found" do
91
+ allow(Pip).to receive(:license_for).and_return("other")
92
+
93
+ package = PythonPackage.new(OpenStruct.new(name: 'jasmine', version: '1.3.1', full_gem_path: '/foo/bar'))
94
+
95
+ expect(package.determine_license).to eq("other")
96
+ end
97
+ end
80
98
  end
@@ -0,0 +1,89 @@
1
+ require 'spec_helper'
2
+
3
+ module LicenseFinder
4
+ describe Pip do
5
+ describe '.current_dists' do
6
+ it 'lists all the current dists' do
7
+ allow(Pip).to receive(:`).with(/python/).and_return('[["jasmine", "1.3.1", "MIT"], ["jasmine-core", "1.3.1", "MIT"]]')
8
+
9
+ current_dists = Pip.current_dists
10
+
11
+ expect(current_dists.size).to eq(2)
12
+ expect(current_dists.first).to be_a(Package)
13
+ end
14
+
15
+ it 'memoizes the current_dists' do
16
+ allow(Pip).to receive(:`).with(/python/).and_return('[]').once
17
+
18
+ Pip.current_dists
19
+ Pip.current_dists
20
+ end
21
+ end
22
+
23
+ describe '.has_requirements' do
24
+ let(:requirements) { Pathname.new('requirements.txt').expand_path }
25
+
26
+ context 'with a requirements file' do
27
+ before :each do
28
+ allow(File).to receive(:exists?).with(requirements).and_return(true)
29
+ end
30
+
31
+ it 'returns true' do
32
+ expect(Pip.has_requirements?).to eq(true)
33
+ end
34
+ end
35
+
36
+ context 'without a requirements file' do
37
+ before :each do
38
+ allow(File).to receive(:exists?).with(requirements).and_return(false)
39
+ end
40
+
41
+ it 'returns false' do
42
+ expect(Pip.has_requirements?).to eq(false)
43
+ end
44
+ end
45
+ end
46
+
47
+ describe '.license_for' do
48
+ let(:package) { PythonPackage.new(OpenStruct.new(name: 'jasmine', version: '1.3.1')) }
49
+
50
+ before :each do
51
+ stub_request(:get, "https://pypi.python.org/pypi/jasmine/1.3.1/json").
52
+ to_return(:status => 200, :body => "{}", :headers => {})
53
+ end
54
+
55
+ it 'reaches out to PyPI with the package name and version' do
56
+ Pip.license_for(package)
57
+
58
+ WebMock.should have_requested(:get, "https://pypi.python.org/pypi/jasmine/1.3.1/json")
59
+ end
60
+
61
+ it 'returns the license from info => license preferentially' do
62
+ data = { info: { license: "MIT", classifiers: [ 'License :: OSI Approved :: Apache 2.0 License' ] } }
63
+
64
+ stub_request(:get, "https://pypi.python.org/pypi/jasmine/1.3.1/json").
65
+ to_return(:status => 200, :body => JSON.generate(data), :headers => {})
66
+
67
+ expect(Pip.license_for(package)).to eq('MIT')
68
+ end
69
+
70
+ it 'returns the first license from the classifiers if no info => license exists' do
71
+ data = { info: { classifiers: [ 'License :: OSI Approved :: Apache 2.0 License' ] } }
72
+
73
+ stub_request(:get, "https://pypi.python.org/pypi/jasmine/1.3.1/json").
74
+ to_return(:status => 200, :body => JSON.generate(data), :headers => {})
75
+
76
+ expect(Pip.license_for(package)).to eq('Apache 2.0 License')
77
+ end
78
+
79
+ it 'returns other if no license can be found' do
80
+ data = {}
81
+
82
+ stub_request(:get, "https://pypi.python.org/pypi/jasmine/1.3.1/json").
83
+ to_return(:status => 200, :body => JSON.generate(data), :headers => {})
84
+
85
+ expect(Pip.license_for(package)).to eq('other')
86
+ end
87
+ end
88
+ end
89
+ end
@@ -4,6 +4,7 @@ require 'bundler/setup'
4
4
  require 'pry'
5
5
  require 'license_finder'
6
6
  require 'rspec'
7
+ require 'webmock/rspec'
7
8
 
8
9
  Dir[File.join(File.dirname(__FILE__), 'support', '**', '*.rb')].each do |file|
9
10
  require file
@@ -24,7 +24,7 @@ shared_examples_for "a license matcher" do
24
24
 
25
25
  describe "#license_text" do
26
26
  it "should always produce a license text" do
27
- subject.class.license_text.should_not be_nil, "No license text found for #{subject.class}! Add a license template to lib/templates named '#{subject.class.demodulized_name}.txt'"
27
+ subject.class.license_text.should_not be_nil, "No license text found for #{subject.class}! Add a license template to lib/data/licenses named '#{subject.class.demodulized_name}.txt'"
28
28
  end
29
29
  end
30
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: license_finder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Maine
@@ -16,7 +16,7 @@ authors:
16
16
  autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
- date: 2013-07-30 00:00:00.000000000 Z
19
+ date: 2013-08-17 00:00:00.000000000 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: bundler
@@ -74,6 +74,20 @@ dependencies:
74
74
  - - '>='
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
+ - !ruby/object:Gem::Dependency
78
+ name: httparty
79
+ requirement: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ type: :runtime
85
+ prerelease: false
86
+ version_requirements: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
77
91
  - !ruby/object:Gem::Dependency
78
92
  name: sqlite3
79
93
  requirement: !ruby/object:Gem::Requirement
@@ -172,6 +186,20 @@ dependencies:
172
186
  - - ~>
173
187
  - !ruby/object:Gem::Version
174
188
  version: 3.2.0
189
+ - !ruby/object:Gem::Dependency
190
+ name: webmock
191
+ requirement: !ruby/object:Gem::Requirement
192
+ requirements:
193
+ - - ~>
194
+ - !ruby/object:Gem::Version
195
+ version: '1.13'
196
+ type: :development
197
+ prerelease: false
198
+ version_requirements: !ruby/object:Gem::Requirement
199
+ requirements:
200
+ - - ~>
201
+ - !ruby/object:Gem::Version
202
+ version: '1.13'
175
203
  description: |2
176
204
  Do you know the licenses of all your application's dependencies? What open source software licenses will your business accept?
177
205
 
@@ -211,16 +239,20 @@ files:
211
239
  - features/cli.feature
212
240
  - features/html_report.feature
213
241
  - features/ignore_bundle_groups.feature
242
+ - features/node_dependencies.feature
214
243
  - features/non_bundler_dependencies.feature
215
244
  - features/project_name.feature
245
+ - features/python_dependencies.feature
216
246
  - features/rails_rake.feature
217
247
  - features/set_license.feature
218
248
  - features/step_definitions/approve_dependencies_steps.rb
219
249
  - features/step_definitions/cli_steps.rb
220
250
  - features/step_definitions/html_report_steps.rb
221
251
  - features/step_definitions/ignore_bundle_groups_steps.rb
252
+ - features/step_definitions/node_steps.rb
222
253
  - features/step_definitions/non_bundler_steps.rb
223
254
  - features/step_definitions/project_name_steps.rb
255
+ - features/step_definitions/python_steps.rb
224
256
  - features/step_definitions/rails_rake_steps.rb
225
257
  - features/step_definitions/set_license_steps.rb
226
258
  - features/step_definitions/shared_steps.rb
@@ -238,12 +270,11 @@ files:
238
270
  - lib/data/licenses/LGPL.txt
239
271
  - lib/data/licenses/MIT.txt
240
272
  - lib/data/licenses/NewBSD.txt
273
+ - lib/data/licenses/Python.txt
241
274
  - lib/data/licenses/Ruby.txt
242
275
  - lib/data/licenses/SimplifiedBSD.txt
243
276
  - lib/license_finder.rb
244
277
  - lib/license_finder/bundle.rb
245
- - lib/license_finder/bundled_gem.rb
246
- - lib/license_finder/bundled_gem_saver.rb
247
278
  - lib/license_finder/cli.rb
248
279
  - lib/license_finder/configuration.rb
249
280
  - lib/license_finder/dependency_manager.rb
@@ -255,9 +286,14 @@ files:
255
286
  - lib/license_finder/license/lgpl.rb
256
287
  - lib/license_finder/license/mit.rb
257
288
  - lib/license_finder/license/new_bsd.rb
289
+ - lib/license_finder/license/python.rb
258
290
  - lib/license_finder/license/ruby.rb
259
291
  - lib/license_finder/license/simplified_bsd.rb
260
292
  - lib/license_finder/license_url.rb
293
+ - lib/license_finder/npm.rb
294
+ - lib/license_finder/package.rb
295
+ - lib/license_finder/package_saver.rb
296
+ - lib/license_finder/pip.rb
261
297
  - lib/license_finder/platform.rb
262
298
  - lib/license_finder/possible_license_file.rb
263
299
  - lib/license_finder/possible_license_files.rb
@@ -306,8 +342,6 @@ files:
306
342
  - spec/fixtures/readme/Readme.markdown
307
343
  - spec/fixtures/utf8_gem/README
308
344
  - spec/lib/license_finder/bundle_spec.rb
309
- - spec/lib/license_finder/bundled_gem_saver_spec.rb
310
- - spec/lib/license_finder/bundled_gem_spec.rb
311
345
  - spec/lib/license_finder/cli_spec.rb
312
346
  - spec/lib/license_finder/configuration_spec.rb
313
347
  - spec/lib/license_finder/dependency_manager_spec.rb
@@ -319,10 +353,15 @@ files:
319
353
  - spec/lib/license_finder/license/lgpl_spec.rb
320
354
  - spec/lib/license_finder/license/mit_spec.rb
321
355
  - spec/lib/license_finder/license/new_bsd_spec.rb
356
+ - spec/lib/license_finder/license/python_spec.rb
322
357
  - spec/lib/license_finder/license/ruby_spec.rb
323
358
  - spec/lib/license_finder/license/simplified_bsd_spec.rb
324
359
  - spec/lib/license_finder/license_spec.rb
325
360
  - spec/lib/license_finder/license_url_spec.rb
361
+ - spec/lib/license_finder/npm_spec.rb
362
+ - spec/lib/license_finder/package_saver_spec.rb
363
+ - spec/lib/license_finder/package_spec.rb
364
+ - spec/lib/license_finder/pip_spec.rb
326
365
  - spec/lib/license_finder/possible_license_file_spec.rb
327
366
  - spec/lib/license_finder/possible_license_files_spec.rb
328
367
  - spec/lib/license_finder/reporter_spec.rb
@@ -354,7 +393,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
354
393
  version: '0'
355
394
  requirements: []
356
395
  rubyforge_project:
357
- rubygems_version: 2.0.3
396
+ rubygems_version: 2.0.4
358
397
  signing_key:
359
398
  specification_version: 4
360
399
  summary: Audit the OSS licenses of your application's dependencies.
@@ -363,16 +402,20 @@ test_files:
363
402
  - features/cli.feature
364
403
  - features/html_report.feature
365
404
  - features/ignore_bundle_groups.feature
405
+ - features/node_dependencies.feature
366
406
  - features/non_bundler_dependencies.feature
367
407
  - features/project_name.feature
408
+ - features/python_dependencies.feature
368
409
  - features/rails_rake.feature
369
410
  - features/set_license.feature
370
411
  - features/step_definitions/approve_dependencies_steps.rb
371
412
  - features/step_definitions/cli_steps.rb
372
413
  - features/step_definitions/html_report_steps.rb
373
414
  - features/step_definitions/ignore_bundle_groups_steps.rb
415
+ - features/step_definitions/node_steps.rb
374
416
  - features/step_definitions/non_bundler_steps.rb
375
417
  - features/step_definitions/project_name_steps.rb
418
+ - features/step_definitions/python_steps.rb
376
419
  - features/step_definitions/rails_rake_steps.rb
377
420
  - features/step_definitions/set_license_steps.rb
378
421
  - features/step_definitions/shared_steps.rb
@@ -406,8 +449,6 @@ test_files:
406
449
  - spec/fixtures/readme/Readme.markdown
407
450
  - spec/fixtures/utf8_gem/README
408
451
  - spec/lib/license_finder/bundle_spec.rb
409
- - spec/lib/license_finder/bundled_gem_saver_spec.rb
410
- - spec/lib/license_finder/bundled_gem_spec.rb
411
452
  - spec/lib/license_finder/cli_spec.rb
412
453
  - spec/lib/license_finder/configuration_spec.rb
413
454
  - spec/lib/license_finder/dependency_manager_spec.rb
@@ -419,10 +460,15 @@ test_files:
419
460
  - spec/lib/license_finder/license/lgpl_spec.rb
420
461
  - spec/lib/license_finder/license/mit_spec.rb
421
462
  - spec/lib/license_finder/license/new_bsd_spec.rb
463
+ - spec/lib/license_finder/license/python_spec.rb
422
464
  - spec/lib/license_finder/license/ruby_spec.rb
423
465
  - spec/lib/license_finder/license/simplified_bsd_spec.rb
424
466
  - spec/lib/license_finder/license_spec.rb
425
467
  - spec/lib/license_finder/license_url_spec.rb
468
+ - spec/lib/license_finder/npm_spec.rb
469
+ - spec/lib/license_finder/package_saver_spec.rb
470
+ - spec/lib/license_finder/package_spec.rb
471
+ - spec/lib/license_finder/pip_spec.rb
426
472
  - spec/lib/license_finder/possible_license_file_spec.rb
427
473
  - spec/lib/license_finder/possible_license_files_spec.rb
428
474
  - spec/lib/license_finder/reporter_spec.rb