license_finder 0.9.4-java → 0.9.5-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -7
  3. data/.travis.yml +1 -3
  4. data/CHANGELOG.rdoc +13 -0
  5. data/db/migrate/201307251004_data_fix_manual_licenses.rb +2 -2
  6. data/db/migrate/201307251107_reassociate_license.rb +18 -18
  7. data/db/migrate/201311192002_add_manually_approved_to_dependencies.rb +7 -0
  8. data/db/migrate/201311192003_reassociate_manual_approval.rb +14 -0
  9. data/db/migrate/201311192010_drop_approvals.rb +5 -0
  10. data/features/cli.feature +1 -1
  11. data/features/html_report.feature +1 -1
  12. data/features/{non_bundler_dependencies.feature → manually_managed_dependencies.feature} +6 -6
  13. data/features/step_definitions/html_report_steps.rb +2 -9
  14. data/features/step_definitions/{non_bundler_steps.rb → manually_managed_steps.rb} +0 -0
  15. data/features/step_definitions/shared_steps.rb +4 -8
  16. data/lib/license_finder.rb +21 -17
  17. data/lib/license_finder/bower.rb +3 -34
  18. data/lib/license_finder/bower_package.rb +63 -0
  19. data/lib/license_finder/bundler.rb +73 -0
  20. data/lib/license_finder/bundler_package.rb +33 -0
  21. data/lib/license_finder/cli.rb +33 -35
  22. data/lib/license_finder/dependency_manager.rb +14 -23
  23. data/lib/license_finder/license/apache2.rb +1 -1
  24. data/lib/license_finder/license/lgpl.rb +1 -0
  25. data/lib/license_finder/npm.rb +22 -39
  26. data/lib/license_finder/npm_package.rb +61 -0
  27. data/lib/license_finder/package.rb +14 -80
  28. data/lib/license_finder/package_saver.rb +13 -75
  29. data/lib/license_finder/pip.rb +21 -33
  30. data/lib/license_finder/pip_package.rb +51 -0
  31. data/lib/license_finder/platform.rb +3 -15
  32. data/lib/license_finder/possible_license_file.rb +0 -4
  33. data/lib/license_finder/possible_license_files.rb +4 -0
  34. data/lib/license_finder/tables.rb +2 -2
  35. data/lib/license_finder/tables/bundler_group.rb +3 -0
  36. data/lib/license_finder/tables/dependency.rb +43 -18
  37. data/lib/license_finder/tables/license_alias.rb +4 -0
  38. data/lib/license_finder/yml_to_sql.rb +22 -30
  39. data/license_finder.gemspec +3 -3
  40. data/readme.md +5 -5
  41. data/spec/lib/license_finder/bower_package_spec.rb +56 -0
  42. data/spec/lib/license_finder/bower_spec.rb +3 -24
  43. data/spec/lib/license_finder/bundler_package_spec.rb +62 -0
  44. data/spec/lib/license_finder/{bundle_spec.rb → bundler_spec.rb} +7 -7
  45. data/spec/lib/license_finder/cli_spec.rb +6 -6
  46. data/spec/lib/license_finder/dependency_manager_spec.rb +14 -15
  47. data/spec/lib/license_finder/html_report_spec.rb +2 -3
  48. data/spec/lib/license_finder/markdown_report_spec.rb +4 -4
  49. data/spec/lib/license_finder/npm_package_spec.rb +51 -0
  50. data/spec/lib/license_finder/npm_spec.rb +25 -25
  51. data/spec/lib/license_finder/package_saver_spec.rb +50 -190
  52. data/spec/lib/license_finder/pip_package_spec.rb +74 -0
  53. data/spec/lib/license_finder/pip_spec.rb +33 -55
  54. data/spec/lib/license_finder/tables/dependency_spec.rb +83 -32
  55. data/spec/lib/license_finder/yml_to_sql_spec.rb +5 -12
  56. data/spec/spec_helper.rb +22 -2
  57. metadata +30 -18
  58. data/lib/license_finder/bundle.rb +0 -74
  59. data/lib/license_finder/tables/approval.rb +0 -4
  60. data/spec/lib/license_finder/package_spec.rb +0 -98
@@ -1,74 +0,0 @@
1
- require "bundler"
2
-
3
- module LicenseFinder
4
- class Bundle
5
- attr_writer :ignore_groups
6
-
7
- class << self
8
- def current_gems(config, bundler_definition=nil)
9
- new(config, bundler_definition).gems
10
- end
11
-
12
- def has_gemfile?
13
- File.exists?(gemfile_path)
14
- end
15
-
16
- def gemfile_path
17
- Pathname.new("Gemfile").expand_path
18
- end
19
- end
20
-
21
- def initialize(config=nil, bundler_definition=nil)
22
- @definition = bundler_definition || Bundler::Definition.build(self.class.gemfile_path, lockfile_path, nil)
23
- @config ||= config
24
- end
25
-
26
- def gems
27
- return @gems if @gems
28
-
29
- gem_names_cache = {}
30
-
31
- @gems ||= definition.specs_for(included_groups).map do |spec|
32
- dependency = dependencies.detect { |dep| dep.name == spec.name }
33
-
34
- formatted_name = format_name(spec)
35
- gem_names_cache[format_name(spec)] = true
36
-
37
- Package.new(spec, dependency)
38
- end
39
-
40
- @gems.each do |gem|
41
- gem.children = children_for(gem, gem_names_cache)
42
- end
43
-
44
- @gems
45
- end
46
-
47
- private
48
- attr_reader :definition
49
-
50
- def ignore_groups
51
- @ignore_groups ||= @config.ignore_groups
52
- end
53
-
54
- def dependencies
55
- @dependencies ||= definition.dependencies
56
- end
57
-
58
- def included_groups
59
- definition.groups - ignore_groups.map(&:to_sym)
60
- end
61
-
62
- def lockfile_path
63
- self.class.gemfile_path.dirname.join('Gemfile.lock')
64
- end
65
-
66
- def children_for(gem, cache)
67
- gem.spec.dependencies.map(&:name).select { |name| cache[name] }
68
- end
69
-
70
- def format_name(gem)
71
- gem.name.split(" ")[0]
72
- end
73
- end
74
- end
@@ -1,4 +0,0 @@
1
- module LicenseFinder
2
- class Approval < Sequel::Model
3
- end
4
- end
@@ -1,98 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module LicenseFinder
4
- describe Package do
5
- subject { described_class.new(gemspec) }
6
-
7
- let(:gemspec) do
8
- Gem::Specification.new do |s|
9
- s.name = 'spec_name'
10
- s.version = '2.1.3'
11
- s.summary = 'summary'
12
- s.description = 'description'
13
- s.homepage = 'homepage'
14
-
15
- s.add_dependency 'foo'
16
- end
17
- end
18
-
19
- def fixture_path(fixture)
20
- Pathname.new(File.join(File.dirname(__FILE__), '..', '..', '..', 'spec', 'fixtures', fixture)).realpath.to_s
21
- end
22
-
23
- its(:name) { should == 'spec_name 2.1.3' }
24
- its(:dependency_name) { should == 'spec_name' }
25
- its(:dependency_version) { should == '2.1.3' }
26
-
27
- describe "#license" do
28
- subject do
29
- details = Package.new(gemspec)
30
- details.stub(:license_files).and_return([license_file])
31
- details
32
- end
33
-
34
- let(:license_file) { PossibleLicenseFile.new('gem', 'gem/license/path') }
35
-
36
- it "returns the license from the gemspec if provided" do
37
- gemspec.stub(:license).and_return('Some License')
38
-
39
- subject.license.should == "Some License"
40
- end
41
-
42
- it "returns the matched license if detected" do
43
- license_file.stub(:license).and_return('Detected License')
44
-
45
- subject.license.should == "Detected License"
46
- end
47
-
48
- it "returns 'other' otherwise" do
49
- license_file.stub(:license).and_return(nil)
50
-
51
- subject.license.should == "other"
52
- end
53
- end
54
-
55
- describe "#license_files" do
56
- it "delegates to the license files helper" do
57
- PossibleLicenseFiles.should_receive(:new).with(gemspec.full_gem_path) { double(find: [] )}
58
- subject.license_files
59
- end
60
- end
61
-
62
- describe "#groups" do
63
- context "bundler_dependency is present" do
64
- subject { described_class.new(gemspec, bundler_dependency) }
65
-
66
- let(:bundler_dependency) { double(:dependency, groups: [1, 2, 3]) }
67
-
68
- it "returns bundler dependency's groups" do
69
- subject.groups.should == bundler_dependency.groups
70
- end
71
- end
72
-
73
- context "bundler_dependency is nil" do
74
- it "returns empty array" do
75
- subject.groups.should == []
76
- end
77
- end
78
- end
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
98
- end