license_finder 0.9.3-java → 0.9.4-java

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3519eda1dd7ddf902c942bf89e24de4c961230e0
4
+ data.tar.gz: 453c040ae74bfb687dede2aba3c24eb7120dfd8c
5
+ SHA512:
6
+ metadata.gz: fb17d88ef9ab566b058a97dcf8feccb59301ed1bd3c2dc9a59f04b74cfa9b9e06e587fb7540a4ff17816ce9a527aee1a04b68df8eaf0d37b3b9af52f67c77bd1
7
+ data.tar.gz: 6086821b912563945238553cd910044eeddb6f7320c230bbc754947f5fa44fbf04cdd25318eb3237482eb7d19df861b4959ffb67fa7236e4f37866dbed3cd42d
@@ -1,4 +1,5 @@
1
1
  rvm:
2
+ - 2.1.0
2
3
  - 2.0.0
3
4
  - 1.9.3
4
5
  - 1.9.2
@@ -1,4 +1,18 @@
1
- === 0.9.3 / 2012-10-01
1
+ === 0.9.4 / 2014-01-05
2
+
3
+ * Features
4
+
5
+ * Add detailed csv report
6
+ * Add markdown report
7
+ * Add support for "licenses" => ["license"] (npn)
8
+ * Add basic bower support
9
+ * Allow adding/removing multiple licenses from whitelist
10
+
11
+ * Bugfixes
12
+
13
+ * Use all dependencies by default for npm as bundler does
14
+
15
+ === 0.9.3 / 2013-10-01
2
16
 
3
17
  * Features
4
18
 
@@ -18,7 +18,7 @@ Feature: License Finder command line executable
18
18
  Given I have an app with license finder that depends on a MIT licensed gem
19
19
  When I whitelist MIT and 'other' and New BSD and Apache 2.0 licenses
20
20
  Then it should exit with status code 0
21
- And I should see all gems approved for use
21
+ And I should see all dependencies approved for use
22
22
 
23
23
  Scenario: Keep manually set license dependencies
24
24
  Given I have a project that depends on mime-types with a manual license type
@@ -44,8 +44,8 @@ Then(/^should list my MIT gem in the output$/) do
44
44
  @output.should include 'mit_gem'
45
45
  end
46
46
 
47
- Then(/^I should see all gems approved for use$/) do
48
- @output.should include 'All gems are approved for use'
47
+ Then(/^I should see all dependencies approved for use$/) do
48
+ @output.should include 'All dependencies are approved for use'
49
49
  end
50
50
 
51
51
  Then(/^the mime\-types license remains set with my manual license type$/) do
@@ -10,7 +10,7 @@ end
10
10
 
11
11
  When(/^I add my JS dependency with an approval flag$/) do
12
12
  @output = @user.execute_command 'license_finder dependencies add --approve MIT my_js_dep 1.2.3'
13
- @output.should == "The my_js_dep dependency has been added and approved!\n"
13
+ @output.should match /The my_js_dep dependency has been added and approved/
14
14
  end
15
15
 
16
16
  When(/^I remove my JS dependency$/) do
@@ -9,6 +9,7 @@ module LicenseFinder
9
9
 
10
10
  autoload :Bundle, 'license_finder/bundle'
11
11
  autoload :PackageSaver, 'license_finder/package_saver'
12
+ autoload :Bower, 'license_finder/bower'
12
13
  autoload :CLI, 'license_finder/cli'
13
14
  autoload :Configuration, 'license_finder/configuration'
14
15
  autoload :DependencyManager, 'license_finder/dependency_manager'
@@ -29,8 +30,10 @@ module LicenseFinder
29
30
 
30
31
  autoload :DependencyReport, 'license_finder/reports/dependency_report'
31
32
  autoload :HtmlReport, 'license_finder/reports/html_report'
33
+ autoload :MarkdownReport, 'license_finder/reports/markdown_report'
32
34
  autoload :Reporter, 'license_finder/reports/reporter'
33
35
  autoload :TextReport, 'license_finder/reports/text_report'
36
+ autoload :DetailedTextReport, 'license_finder/reports/detailed_text_report'
34
37
 
35
38
  def self.config
36
39
  @config ||= Configuration.ensure_default
@@ -0,0 +1,57 @@
1
+ require 'json'
2
+ require 'license_finder/package'
3
+
4
+ module LicenseFinder
5
+ class Bower
6
+
7
+ def self.current_packages
8
+ return @packages if @packages
9
+
10
+ output = `bower list --json`
11
+
12
+ json = JSON(output)
13
+
14
+ @packages = json.fetch("dependencies",[]).map do |package|
15
+ package = package[1]
16
+ pkg_meta = package.fetch("pkgMeta", Hash.new)
17
+
18
+ Package.new(OpenStruct.new(
19
+ :name => pkg_meta.fetch("name", nil),
20
+ :version => pkg_meta.fetch("version", nil),
21
+ :full_gem_path => package.fetch("canonicalDir", nil),
22
+ :license => self.harvest_license(pkg_meta),
23
+ :summary => pkg_meta.fetch("description", nil),
24
+ :description => pkg_meta.fetch("readme", nil)
25
+ ))
26
+ end
27
+ end
28
+
29
+ def self.has_package_file?
30
+ File.exists?(package_path)
31
+ end
32
+
33
+ private
34
+
35
+ def self.package_path
36
+ Pathname.new('bower.json').expand_path
37
+ end
38
+
39
+ def self.harvest_license(package)
40
+ license = package.fetch("licenses", []).first
41
+
42
+ if license.is_a? Hash
43
+ license = license.fetch("type", nil)
44
+ end
45
+
46
+ if license.nil?
47
+ license = package.fetch("license", nil)
48
+
49
+ if license.is_a? Hash
50
+ license = license.fetch("type", nil)
51
+ end
52
+ end
53
+
54
+ license
55
+ end
56
+ end
57
+ end
@@ -74,26 +74,30 @@ module LicenseFinder
74
74
  end
75
75
  end
76
76
 
77
- desc "add LICENSE", "Add a license to the whitelist"
78
- def add(license)
77
+ desc "add LICENSE", "Add one ore more licenses to the whitelist"
78
+ def add(*licenses)
79
79
  die_on_error {
80
- LicenseFinder.config.whitelist.push(license)
80
+ licenses.each do |license|
81
+ LicenseFinder.config.whitelist.push(license)
82
+ end
81
83
  LicenseFinder.config.save
82
84
 
83
85
  Reporter.write_reports
84
86
  }
85
- say "Added #{license} to the license whitelist"
87
+ say "Added #{licenses.join(", ")} to the license whitelist"
86
88
  end
87
89
 
88
- desc "remove LICENSE", "Remove a license from the whitelist"
89
- def remove(license)
90
+ desc "remove LICENSE", "Remove one ore more licenses from the whitelist"
91
+ def remove(*licenses)
90
92
  die_on_error {
91
- LicenseFinder.config.whitelist.delete(license)
93
+ licenses.each do |license|
94
+ LicenseFinder.config.whitelist.delete(license)
95
+ end
92
96
  LicenseFinder.config.save
93
97
 
94
98
  Reporter.write_reports
95
99
  }
96
- say "Removed #{license} from the license whitelist"
100
+ say "Removed #{licenses.join(", ")} from the license whitelist"
97
101
  end
98
102
  end
99
103
 
@@ -158,13 +162,13 @@ module LicenseFinder
158
162
  end
159
163
  default_task :rescan
160
164
 
161
- desc "approve DEPENDENCY_NAME", "Approve a dependency by name."
162
- def approve(name)
165
+ desc "approve DEPENDENCY_NAME", "Approve one ore more dependencies by name."
166
+ def approve(*names)
163
167
  die_on_error {
164
- DependencyManager.approve!(name)
168
+ names.each { |name| DependencyManager.approve!(name) }
165
169
  }
166
170
 
167
- say "The #{name} dependency has been approved!", :green
171
+ say "The #{names.join(", ")} dependency has been approved!", :green
168
172
  end
169
173
 
170
174
  desc "license LICENSE DEPENDENCY_NAME", "Update a dependency's license."
@@ -187,7 +191,7 @@ module LicenseFinder
187
191
  unapproved = Dependency.unapproved
188
192
 
189
193
  if unapproved.empty?
190
- say "All gems are approved for use", :green
194
+ say "All dependencies are approved for use", :green
191
195
  else
192
196
  say "Dependencies that need approval:", :red
193
197
  say TextReport.new(unapproved)
@@ -61,6 +61,10 @@ module LicenseFinder
61
61
  File.join(dependencies_dir, "dependencies.csv")
62
62
  end
63
63
 
64
+ def dependencies_detailed_text
65
+ File.join(dependencies_dir, "dependencies_detailed.csv")
66
+ end
67
+
64
68
  def dependencies_legacy_text
65
69
  File.join(dependencies_dir, "dependencies.txt")
66
70
  end
@@ -69,6 +73,10 @@ module LicenseFinder
69
73
  File.join(dependencies_dir, "dependencies.html")
70
74
  end
71
75
 
76
+ def dependencies_markdown
77
+ File.join(dependencies_dir, "dependencies.md")
78
+ end
79
+
72
80
  def whitelisted?(license_name)
73
81
  license = License.find_by_name(license_name) || license_name
74
82
  whitelisted_licenses.include? license
@@ -18,6 +18,10 @@ module LicenseFinder
18
18
  current_dependencies += PackageSaver.save_packages(NPM.current_modules())
19
19
  end
20
20
 
21
+ if Bower.has_package_file?
22
+ current_dependencies += PackageSaver.save_packages(Bower.current_packages())
23
+ end
24
+
21
25
  Dependency.bundler.obsolete(current_dependencies).each(&:destroy)
22
26
  }
23
27
  end
@@ -1,5 +1,5 @@
1
1
  class LicenseFinder::License::Apache2 < LicenseFinder::License::Base
2
- self.alternative_names = ["Apache 2.0", "Apache2", "Apache-2.0", "Apache Software License", "Apache License 2.0"]
2
+ self.alternative_names = ["Apache 2.0", "Apache2", "Apache-2.0", "Apache Software License", "Apache License 2.0", "Apache License Version 2.0"]
3
3
  self.license_url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
4
4
 
5
5
  def self.pretty_name
@@ -4,16 +4,19 @@ require 'license_finder/package'
4
4
  module LicenseFinder
5
5
  class NPM
6
6
 
7
+ DEPENDENCY_GROUPS = ["dependencies", "devDependencies", "bundleDependencies", "bundledDependencies"]
8
+
7
9
  def self.current_modules
8
10
  return @modules if @modules
9
11
 
10
- output = `npm list --json --long`
12
+ command = "npm list --json --long"
13
+ output, success = capture(command)
14
+ raise "Command #{command} failed to execute: #{output}" unless success
11
15
 
12
16
  json = JSON(output)
17
+ dependencies = DEPENDENCY_GROUPS.map { |g| (json[g] || {}).values }.flatten(1)
13
18
 
14
- @modules = json.fetch("dependencies",[]).map do |node_module|
15
- node_module = node_module[1]
16
-
19
+ @modules = dependencies.map do |node_module|
17
20
  Package.new(OpenStruct.new(
18
21
  :name => node_module.fetch("name", nil),
19
22
  :version => node_module.fetch("version", nil),
@@ -31,6 +34,10 @@ module LicenseFinder
31
34
 
32
35
  private
33
36
 
37
+ def self.capture(command)
38
+ [`#{command}`, $?.success?]
39
+ end
40
+
34
41
  def self.package_path
35
42
  Pathname.new('package.json').expand_path
36
43
  end
@@ -38,7 +45,7 @@ module LicenseFinder
38
45
  def self.harvest_license(node_module)
39
46
  license = node_module.fetch("licenses", []).first
40
47
 
41
- if license
48
+ if license.is_a? Hash
42
49
  license = license.fetch("type", nil)
43
50
  end
44
51
 
@@ -53,4 +60,4 @@ module LicenseFinder
53
60
  license
54
61
  end
55
62
  end
56
- end
63
+ end
@@ -0,0 +1,20 @@
1
+ # encoding: UTF-8
2
+ require 'csv'
3
+
4
+ module LicenseFinder
5
+ class DetailedTextReport < DependencyReport
6
+ def to_s
7
+ CSV.generate(col_sep: ",") do |csv|
8
+ sorted_dependencies.each do |s|
9
+ csv << [
10
+ s.name,
11
+ s.version,
12
+ s.license.name,
13
+ s.summary ? s.summary.strip : "",
14
+ s.description ? s.description.strip : ""
15
+ ]
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,23 @@
1
+ # encoding: UTF-8
2
+
3
+ module LicenseFinder
4
+ class MarkdownReport < DependencyReport
5
+ private
6
+ def unapproved_dependencies
7
+ dependencies.reject(&:approved?)
8
+ end
9
+
10
+ def grouped_dependencies
11
+ find_name = lambda do |dep|
12
+ license = License.find_by_name(dep.license.name)
13
+ if license
14
+ license.pretty_name
15
+ else
16
+ dep.license.name
17
+ end
18
+ end
19
+
20
+ dependencies.group_by(&find_name).sort_by { |_, group| group.size }.reverse
21
+ end
22
+ end
23
+ end
@@ -6,7 +6,9 @@ module LicenseFinder
6
6
  dependencies = Dependency.all
7
7
 
8
8
  write_file LicenseFinder.config.dependencies_text, TextReport.new(dependencies).to_s
9
+ write_file LicenseFinder.config.dependencies_detailed_text, DetailedTextReport.new(dependencies).to_s
9
10
  write_file LicenseFinder.config.dependencies_html, HtmlReport.new(dependencies).to_s
11
+ write_file LicenseFinder.config.dependencies_markdown, MarkdownReport.new(dependencies).to_s
10
12
 
11
13
  if File.exists?(LicenseFinder.config.dependencies_legacy_text)
12
14
  File.delete(LicenseFinder.config.dependencies_legacy_text)
@@ -0,0 +1,43 @@
1
+ # <%= LicenseFinder.config.project_name %>
2
+
3
+ As of <%= Time.now.strftime("%B %e, %Y %l:%M%P") %>. <%= dependencies.size %> total, _<%= unapproved_dependencies.size %> unapproved_
4
+
5
+ ## Summary
6
+ <% grouped_dependencies.each do |license_name, group| -%>
7
+ * <%= group.size %> <%= license_name %>
8
+ <% end %>
9
+
10
+ <% if unapproved_dependencies.any? -%>
11
+ <%= unapproved_dependencies.size %> unapproved dependencies
12
+
13
+ <% unapproved_dependencies.each do |dependency| -%>
14
+ * <a href='#<%= dependency.name %>'><%= dependency.name %></a> (<%= dependency.license.name %>)
15
+ <% end %>
16
+ <% end -%>
17
+
18
+ ## Items
19
+
20
+ <% sorted_dependencies.each do |dependency|
21
+ version_groups = "v#{dependency.version}"
22
+ if dependency.bundler_groups.any?
23
+ version_groups += "(#{dependency.bundler_groups.map(&:name).join(", ")})"
24
+ end -%>
25
+
26
+ <% if dependency.homepage && !dependency.homepage.empty? -%>
27
+ <a name="<%= dependency.name %>"></a>
28
+ ### [<%= dependency.name %>](<%= dependency.homepage %>) <%= version_groups -%>
29
+ <% else -%>
30
+ ### <%= dependency.name %> <%= version_groups -%>
31
+ <% end -%>
32
+ <%
33
+ license_text = (dependency.license.url && !dependency.license.url.empty?) ? "<a href='#{dependency.license.url}'>#{dependency.license.name}</a>" : dependency.license.name
34
+ %>
35
+
36
+ | Summary | License | Approved? |
37
+ |---------|-------------|---------|
38
+ |<%= dependency.summary %>|<%= license_text %>| <%= dependency.approved? ? 'Yes' : '_*No*_' %> |
39
+
40
+ <% if dependency.description %>
41
+ <% dependency.description.lines.each{|l| %>> <%= l -%><% } %>
42
+ <% end %>
43
+ <% end -%>
@@ -1,8 +1,9 @@
1
1
  require './lib/license_finder/platform'
2
2
 
3
3
  Gem::Specification.new do |s|
4
+ s.required_ruby_version = '>= 1.9.2'
4
5
  s.name = "license_finder"
5
- s.version = "0.9.3"
6
+ s.version = "0.9.4"
6
7
  s.authors = ["Jacob Maine", "Matthew Kane Parker", "Ian Lesperance", "David Edwards", "Paul Meskers", "Brent Wheeldon", "Trevor John", "David Tengdin", "William Ramsey"]
7
8
  s.email = ["licensefinder@pivotalabs.com"]
8
9
  s.homepage = "https://github.com/pivotal/LicenseFinder"
@@ -22,7 +23,7 @@ Gem::Specification.new do |s|
22
23
  s.add_dependency "sequel"
23
24
  s.add_dependency "thor"
24
25
  s.add_dependency "rake"
25
- s.add_dependency "httparty"
26
+ s.add_dependency "httparty", "0.11.0"
26
27
  s.add_dependency LicenseFinder::Platform.sqlite_gem
27
28
 
28
29
  %w(rspec xpath cucumber pry).each do |gem|
data/readme.md CHANGED
@@ -100,16 +100,16 @@ To list licenses currently on the whitelist:
100
100
  $ license_finder whitelist list
101
101
  ```
102
102
 
103
- To add a license to the whitelist:
103
+ To add a licenses to the whitelist:
104
104
 
105
105
  ```sh
106
- $ license_finder whitelist add MIT
106
+ $ license_finder whitelist add MIT [BSD [...]]
107
107
  ```
108
108
 
109
- To remove a license from the whitelist:
109
+ To remove a licenses from the whitelist:
110
110
 
111
111
  ```sh
112
- $ license_finder whitelist remove MIT
112
+ $ license_finder whitelist remove MIT [BSD [...]]
113
113
  ```
114
114
 
115
115
  ### Managing ignored Bundler groups
@@ -215,7 +215,7 @@ This will move your dependencies.* files to the /doc directory and update the co
215
215
 
216
216
  ## Compatibility
217
217
 
218
- license_finder is compatible with ruby 1.9, and ruby 2.0. There is also experimental support for jruby.
218
+ license_finder is compatible with ruby >= 1.9, and jruby.
219
219
 
220
220
 
221
221
  ## A note to gem authors / maintainers
@@ -15,9 +15,9 @@ any existing Gemfile.lock in the directory.
15
15
 
16
16
 
17
17
  ```sh
18
- $ rvm use jruby-1.7.4
18
+ $ rvm use jruby
19
19
  $ rake build
20
- $ rvm use ruby-2.0.0
20
+ $ rvm use ruby
21
21
  $ rake build
22
22
  ```
23
23
 
@@ -14,12 +14,12 @@ function perform {
14
14
  $1
15
15
  }
16
16
 
17
- printf "\nBuilding jruby... (1.7.4)"
18
- perform "rvm use jruby-1.7.4"
17
+ printf "\nBuilding jruby..."
18
+ perform "rvm use jruby"
19
19
  perform "rake build"
20
20
 
21
- printf "\nBuilding ruby... (2.0.0)"
22
- perform "rvm use ruby-2.0.0"
21
+ printf "\nBuilding ruby..."
22
+ perform "rvm use ruby"
23
23
  perform "rake build"
24
24
 
25
25
  printf "\nPublishing to rubygems..."
@@ -0,0 +1,85 @@
1
+ require 'spec_helper'
2
+
3
+ module LicenseFinder
4
+ describe Bower do
5
+ describe '.current_packages' do
6
+ it 'lists all the current packages' do
7
+ json = <<-resp
8
+ {
9
+ "dependencies": {
10
+ "dependency-library": {
11
+ "canonicalDir": "/path/to/thing",
12
+ "pkgMeta": {
13
+ "name": "dependency-library",
14
+ "description": "description",
15
+ "version": "1.3.3.7",
16
+ "main": "normalize.css"
17
+ }
18
+ },
19
+ "another-dependency": {
20
+ "canonicalDir": "/path/to/thing2",
21
+ "pkgMeta": {
22
+ "name": "another-dependency",
23
+ "description": "description2",
24
+ "version": "4.2",
25
+ "main": "denormalize.css"
26
+ }
27
+ }
28
+ }
29
+ }
30
+ resp
31
+ allow(Bower).to receive(:`).with(/bower/).and_return(json)
32
+
33
+ current_packages = Bower.current_packages
34
+
35
+ expect(current_packages.size).to eq(2)
36
+ expect(current_packages.first).to be_a(Package)
37
+ end
38
+
39
+ it 'memoizes the current_packages' do
40
+ allow(Bower).to receive(:`).with(/bower/).and_return('{}').once
41
+
42
+ Bower.current_packages
43
+ Bower.current_packages
44
+ end
45
+ end
46
+
47
+ describe '.harvest_license' do
48
+ let(:package1) { {"license" => "MIT"} }
49
+ let(:package2) { {"licenses" => [{"type" => "BSD", "url" => "github.github/github"}]} }
50
+ let(:package3) { {"license" => {"type" => "PSF", "url" => "github.github/github"}} }
51
+ let(:package4) { {"licenses" => ["MIT"]} }
52
+
53
+ it 'finds the license for both license structures' do
54
+ Bower.harvest_license(package1).should eq("MIT")
55
+ Bower.harvest_license(package2).should eq("BSD")
56
+ Bower.harvest_license(package3).should eq("PSF")
57
+ Bower.harvest_license(package4).should eq("MIT")
58
+ end
59
+ end
60
+
61
+ describe '.has_package_file?' do
62
+ let(:package) { Pathname.new('bower.json').expand_path }
63
+
64
+ context 'with a bower.json file' do
65
+ before :each do
66
+ allow(File).to receive(:exists?).with(package).and_return(true)
67
+ end
68
+
69
+ it 'returns true' do
70
+ expect(Bower.has_package_file?).to eq(true)
71
+ end
72
+ end
73
+
74
+ context 'without a bower.json file' do
75
+ before :each do
76
+ allow(File).to receive(:exists?).with(package).and_return(false)
77
+ end
78
+
79
+ it 'returns false' do
80
+ expect(Bower.has_package_file?).to eq(false)
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
@@ -63,6 +63,17 @@ module LicenseFinder
63
63
  subject.add("test")
64
64
  end
65
65
  end
66
+
67
+ it "adds multiple licenses to the whitelist" do
68
+ config.whitelist.should_receive(:push).with("test")
69
+ config.whitelist.should_receive(:push).with("rest")
70
+ config.should_receive(:save)
71
+ Reporter.should_receive(:write_reports)
72
+
73
+ silence_stdout do
74
+ subject.add("test", "rest")
75
+ end
76
+ end
66
77
  end
67
78
 
68
79
  describe "remove" do
@@ -72,9 +83,21 @@ module LicenseFinder
72
83
  Reporter.should_receive(:write_reports)
73
84
 
74
85
  silence_stdout do
86
+
75
87
  subject.remove("test")
76
88
  end
77
89
  end
90
+
91
+ it "removes multiple licenses from the whitelist" do
92
+ config.should_receive(:save)
93
+ config.whitelist.should_receive(:delete).with("test")
94
+ config.whitelist.should_receive(:delete).with("rest")
95
+ Reporter.should_receive(:write_reports)
96
+
97
+ silence_stdout do
98
+ subject.remove("test", "rest")
99
+ end
100
+ end
78
101
  end
79
102
  end
80
103
 
@@ -174,6 +197,15 @@ module LicenseFinder
174
197
  subject.approve 'foo'
175
198
  end
176
199
  end
200
+
201
+ it "approves multiple gem" do
202
+ DependencyManager.should_receive(:approve!).with("foo")
203
+ DependencyManager.should_receive(:approve!).with("bar")
204
+
205
+ silence_stdout do
206
+ subject.approve 'foo', 'bar'
207
+ end
208
+ end
177
209
  end
178
210
 
179
211
  describe "#action_items" do
@@ -0,0 +1,35 @@
1
+ require "spec_helper"
2
+
3
+ module LicenseFinder
4
+ describe DetailedTextReport do
5
+ describe '#to_s' do
6
+ let(:dep1) do
7
+ dependency = Dependency.new(
8
+ 'name' => 'gem_a',
9
+ 'version' => '1.0',
10
+ 'summary' => 'Summary',
11
+ 'description' => 'Description'
12
+ )
13
+ dependency.license = LicenseFinder::LicenseAlias.create(name: 'MIT')
14
+ dependency
15
+ end
16
+
17
+ let(:dep2) do
18
+ dependency = Dependency.new(
19
+ 'name' => 'gem_b',
20
+ 'version' => '1.0',
21
+ 'summary' => 'Summary',
22
+ 'description' => 'Description'
23
+ )
24
+ dependency.license = LicenseFinder::LicenseAlias.create(name: 'MIT')
25
+ dependency
26
+ end
27
+
28
+ subject { DetailedTextReport.new([dep2, dep1]).to_s }
29
+
30
+ it 'should generate a text report with the name, version, license, summary and description of each dependency, sorted by name' do
31
+ should == "gem_a,1.0,MIT,Summary,Description\ngem_b,1.0,MIT,Summary,Description\n"
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,54 @@
1
+ require "spec_helper"
2
+
3
+ module LicenseFinder
4
+ describe MarkdownReport do
5
+ describe '#to_s' do
6
+ let(:dep1) do
7
+ dependency = Dependency.new(
8
+ 'name' => 'gem_a',
9
+ 'version' => '1.0'
10
+ )
11
+ dependency.license = LicenseFinder::LicenseAlias.create(name: 'MIT')
12
+ dependency.approval = Approval.create(state: false)
13
+ dependency
14
+ end
15
+
16
+ let(:dep2) do
17
+ dependency = Dependency.new(
18
+ 'name' => 'gem_b',
19
+ 'version' => '2.3'
20
+ )
21
+ dependency.license = LicenseFinder::LicenseAlias.create(name: 'BSD')
22
+ dependency.approval = Approval.create(state: true)
23
+ dependency
24
+ end
25
+
26
+ subject { MarkdownReport.new([dep2, dep1]).to_s }
27
+
28
+ it 'should have the correct header' do
29
+ LicenseFinder.config.project_name = "new_project_name"
30
+ should match "# new_project_name"
31
+ end
32
+
33
+ it 'should list the total, and unapproved counts' do
34
+ should match "2 total, _1 unapproved_"
35
+ end
36
+
37
+ it "should list the unapproved dependency" do
38
+ should match "href='#gem_a'"
39
+ end
40
+
41
+ it "should display a summary" do
42
+ should match "## Summary"
43
+ should match /\s+\* 1 MIT/
44
+ should match /\s+\* 1 BSD/
45
+ end
46
+
47
+ it "should list both gems" do
48
+ should match "## Items"
49
+ should match "### gem_a v1.0"
50
+ should match "### gem_b v2.3"
51
+ end
52
+ end
53
+ end
54
+ end
@@ -3,52 +3,97 @@ require 'spec_helper'
3
3
  module LicenseFinder
4
4
  describe NPM do
5
5
  describe '.current_modules' do
6
+ before { NPM.instance_variable_set(:@modules, nil) }
7
+
6
8
  it 'lists all the current modules' do
7
- json = <<-resp
8
- {
9
- "dependencies": {
10
- "dependency.js": {
11
- "name": "depjs",
12
- "version": "1.3.3.7",
13
- "description": "description",
14
- "readme": "readme",
15
- "path": "/path/to/thing"
16
- },
17
- "dependency2.js": {
18
- "name": "dep2js",
19
- "version": "4.2",
20
- "description": "description2",
21
- "readme": "readme2",
22
- "path": "/path/to/thing2"
23
- }
24
- }
25
- }
26
- resp
27
- allow(NPM).to receive(:`).with(/npm/).and_return(json)
9
+ json = <<-JSON
10
+ {
11
+ "dependencies": {
12
+ "dependency.js": {
13
+ "name": "depjs",
14
+ "version": "1.3.3.7",
15
+ "description": "description",
16
+ "readme": "readme",
17
+ "path": "/path/to/thing"
18
+ },
19
+ "dependency2.js": {
20
+ "name": "dep2js",
21
+ "version": "4.2",
22
+ "description": "description2",
23
+ "readme": "readme2",
24
+ "path": "/path/to/thing2"
25
+ }
26
+ },
27
+ "devDependencies": {
28
+ "dependency3.js": {
29
+ "name": "dep3js",
30
+ "version": "4.2",
31
+ "description": "description3",
32
+ "readme": "readme3",
33
+ "path": "/path/to/thing3"
34
+ }
35
+ },
36
+ "bundledDependencies": {
37
+ "dependency4.js": {
38
+ "name": "dep4js",
39
+ "version": "4.2",
40
+ "description": "description4",
41
+ "readme": "readme4",
42
+ "path": "/path/to/thing4"
43
+ }
44
+ },
45
+ "bundleDependencies": {
46
+ "dependency5.js": {
47
+ "name": "dep5js",
48
+ "version": "4.2",
49
+ "description": "description5",
50
+ "readme": "readme5",
51
+ "path": "/path/to/thing5"
52
+ }
53
+ },
54
+ "notADependency": {
55
+ "dependency6.js": {
56
+ "name": "dep6js",
57
+ "version": "4.2",
58
+ "description": "description6",
59
+ "readme": "readme6",
60
+ "path": "/path/to/thing6"
61
+ }
62
+ }
63
+ }
64
+ JSON
65
+ allow(NPM).to receive(:capture).with(/npm/).and_return([json, true])
28
66
 
29
67
  current_modules = NPM.current_modules
30
68
 
31
- expect(current_modules.size).to eq(2)
69
+ expect(current_modules.map(&:name)).to eq(["depjs 1.3.3.7", "dep2js 4.2", "dep3js 4.2", "dep5js 4.2", "dep4js 4.2"])
32
70
  expect(current_modules.first).to be_a(Package)
33
71
  end
34
72
 
35
73
  it 'memoizes the current_modules' do
36
- allow(NPM).to receive(:`).with(/npm/).and_return('{}').once
74
+ allow(NPM).to receive(:capture).with(/npm/).and_return(['{}', true]).once
37
75
 
38
76
  NPM.current_modules
39
77
  NPM.current_modules
40
78
  end
79
+
80
+ it "fails when command fails" do
81
+ allow(NPM).to receive(:capture).with(/npm/).and_return('Some error', false).once
82
+ expect { NPM.current_modules }.to raise_error(RuntimeError)
83
+ end
41
84
  end
42
85
 
43
86
  describe '.harvest_license' do
44
87
  let(:node_module1) { {"license" => "MIT"} }
45
88
  let(:node_module2) { {"licenses" => [{"type" => "BSD", "url" => "github.github/github"}]} }
46
89
  let(:node_module3) { {"license" => {"type" => "PSF", "url" => "github.github/github"}} }
90
+ let(:node_module4) { {"licenses" => ["MIT"]} }
47
91
 
48
92
  it 'finds the license for both license structures' do
49
93
  NPM.harvest_license(node_module1).should eq("MIT")
50
94
  NPM.harvest_license(node_module2).should eq("BSD")
51
95
  NPM.harvest_license(node_module3).should eq("PSF")
96
+ NPM.harvest_license(node_module4).should eq("MIT")
52
97
  end
53
98
  end
54
99
 
@@ -11,7 +11,11 @@ module LicenseFinder
11
11
 
12
12
  LicenseFinder.stub_chain(:config, :dependencies_html) { 'html_file_path' }
13
13
  LicenseFinder.stub_chain(:config, :dependencies_text) { 'text_file_path' }
14
+ LicenseFinder.stub_chain(:config, :dependencies_detailed_text) { 'detailed_text_file_path' }
15
+ LicenseFinder.stub_chain(:config, :dependencies_markdown) { 'markdown_file_path' }
14
16
 
17
+ MarkdownReport.stub_chain(:new, :to_s) { 'text report' }
18
+ DetailedTextReport.stub_chain(:new, :to_s) { 'text report' }
15
19
  TextReport.stub_chain(:new, :to_s) { 'text report' }
16
20
  HtmlReport.stub_chain(:new, :to_s) { 'text report' }
17
21
 
@@ -20,11 +24,15 @@ module LicenseFinder
20
24
 
21
25
  File.stub(:open).with('html_file_path', 'w+')
22
26
  File.stub(:open).with('text_file_path', 'w+')
27
+ File.stub(:open).with('detailed_text_file_path', 'w+')
28
+ File.stub(:open).with('markdown_file_path', 'w+')
23
29
  end
24
30
 
25
31
  it "writes an html file" do
26
32
  File.should_receive(:open).with('html_file_path', 'w+')
27
33
  File.should_receive(:open).with('text_file_path', 'w+')
34
+ File.should_receive(:open).with('detailed_text_file_path', 'w+')
35
+ File.should_receive(:open).with('markdown_file_path', 'w+')
28
36
  subject
29
37
  end
30
38
 
@@ -6,7 +6,7 @@ module LicenseFinder
6
6
  let(:dep1) do
7
7
  dependency = Dependency.new(
8
8
  'name' => 'gem_a',
9
- 'version' => '1.0',
9
+ 'version' => '1.0'
10
10
  )
11
11
  dependency.license = LicenseFinder::LicenseAlias.create(name: 'MIT')
12
12
  dependency
@@ -15,7 +15,7 @@ module LicenseFinder
15
15
  let(:dep2) do
16
16
  dependency = Dependency.new(
17
17
  'name' => 'gem_b',
18
- 'version' => '1.0',
18
+ 'version' => '1.0'
19
19
  )
20
20
  dependency.license = LicenseFinder::LicenseAlias.create(name: 'MIT')
21
21
  dependency
@@ -23,7 +23,7 @@ module LicenseFinder
23
23
 
24
24
  subject { TextReport.new([dep2, dep1]).to_s }
25
25
 
26
- it 'should generate a text report with the name, version, and license of each dependency, sorted by name' do
26
+ it 'should generate a text report with the name, version and license of each dependency, sorted by name' do
27
27
  should == "gem_a, 1.0, MIT\ngem_b, 1.0, MIT"
28
28
  end
29
29
  end
@@ -15,7 +15,8 @@ RSpec.configure do |config|
15
15
  end
16
16
 
17
17
  RSpec.configure do |config|
18
- config.around(:each) do |example|
18
+ config.before { FileUtils.rm_f("config/license_finder.yml") }
19
+ config.around do |example|
19
20
  DB.transaction(rollback: :always) { example.run }
20
21
  end
21
22
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: license_finder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
5
- prerelease:
4
+ version: 0.9.4
6
5
  platform: java
7
6
  authors:
8
7
  - Jacob Maine
@@ -17,7 +16,7 @@ authors:
17
16
  autorequire:
18
17
  bindir: bin
19
18
  cert_chain: []
20
- date: 2013-10-01 00:00:00.000000000 Z
19
+ date: 2014-01-05 00:00:00.000000000 Z
21
20
  dependencies:
22
21
  - !ruby/object:Gem::Dependency
23
22
  name: bundler
@@ -26,13 +25,11 @@ dependencies:
26
25
  - - '>='
27
26
  - !ruby/object:Gem::Version
28
27
  version: '0'
29
- none: false
30
28
  requirement: !ruby/object:Gem::Requirement
31
29
  requirements:
32
30
  - - '>='
33
31
  - !ruby/object:Gem::Version
34
32
  version: '0'
35
- none: false
36
33
  prerelease: false
37
34
  type: :runtime
38
35
  - !ruby/object:Gem::Dependency
@@ -42,13 +39,11 @@ dependencies:
42
39
  - - '>='
43
40
  - !ruby/object:Gem::Version
44
41
  version: '0'
45
- none: false
46
42
  requirement: !ruby/object:Gem::Requirement
47
43
  requirements:
48
44
  - - '>='
49
45
  - !ruby/object:Gem::Version
50
46
  version: '0'
51
- none: false
52
47
  prerelease: false
53
48
  type: :runtime
54
49
  - !ruby/object:Gem::Dependency
@@ -58,13 +53,11 @@ dependencies:
58
53
  - - '>='
59
54
  - !ruby/object:Gem::Version
60
55
  version: '0'
61
- none: false
62
56
  requirement: !ruby/object:Gem::Requirement
63
57
  requirements:
64
58
  - - '>='
65
59
  - !ruby/object:Gem::Version
66
60
  version: '0'
67
- none: false
68
61
  prerelease: false
69
62
  type: :runtime
70
63
  - !ruby/object:Gem::Dependency
@@ -74,29 +67,25 @@ dependencies:
74
67
  - - '>='
75
68
  - !ruby/object:Gem::Version
76
69
  version: '0'
77
- none: false
78
70
  requirement: !ruby/object:Gem::Requirement
79
71
  requirements:
80
72
  - - '>='
81
73
  - !ruby/object:Gem::Version
82
74
  version: '0'
83
- none: false
84
75
  prerelease: false
85
76
  type: :runtime
86
77
  - !ruby/object:Gem::Dependency
87
78
  name: httparty
88
79
  version_requirements: !ruby/object:Gem::Requirement
89
80
  requirements:
90
- - - '>='
81
+ - - '='
91
82
  - !ruby/object:Gem::Version
92
- version: '0'
93
- none: false
83
+ version: 0.11.0
94
84
  requirement: !ruby/object:Gem::Requirement
95
85
  requirements:
96
- - - '>='
86
+ - - '='
97
87
  - !ruby/object:Gem::Version
98
- version: '0'
99
- none: false
88
+ version: 0.11.0
100
89
  prerelease: false
101
90
  type: :runtime
102
91
  - !ruby/object:Gem::Dependency
@@ -106,13 +95,11 @@ dependencies:
106
95
  - - '>='
107
96
  - !ruby/object:Gem::Version
108
97
  version: '0'
109
- none: false
110
98
  requirement: !ruby/object:Gem::Requirement
111
99
  requirements:
112
100
  - - '>='
113
101
  - !ruby/object:Gem::Version
114
102
  version: '0'
115
- none: false
116
103
  prerelease: false
117
104
  type: :runtime
118
105
  - !ruby/object:Gem::Dependency
@@ -122,13 +109,11 @@ dependencies:
122
109
  - - '>='
123
110
  - !ruby/object:Gem::Version
124
111
  version: '0'
125
- none: false
126
112
  requirement: !ruby/object:Gem::Requirement
127
113
  requirements:
128
114
  - - '>='
129
115
  - !ruby/object:Gem::Version
130
116
  version: '0'
131
- none: false
132
117
  prerelease: false
133
118
  type: :development
134
119
  - !ruby/object:Gem::Dependency
@@ -138,13 +123,11 @@ dependencies:
138
123
  - - '>='
139
124
  - !ruby/object:Gem::Version
140
125
  version: '0'
141
- none: false
142
126
  requirement: !ruby/object:Gem::Requirement
143
127
  requirements:
144
128
  - - '>='
145
129
  - !ruby/object:Gem::Version
146
130
  version: '0'
147
- none: false
148
131
  prerelease: false
149
132
  type: :development
150
133
  - !ruby/object:Gem::Dependency
@@ -154,13 +137,11 @@ dependencies:
154
137
  - - '>='
155
138
  - !ruby/object:Gem::Version
156
139
  version: '0'
157
- none: false
158
140
  requirement: !ruby/object:Gem::Requirement
159
141
  requirements:
160
142
  - - '>='
161
143
  - !ruby/object:Gem::Version
162
144
  version: '0'
163
- none: false
164
145
  prerelease: false
165
146
  type: :development
166
147
  - !ruby/object:Gem::Dependency
@@ -170,13 +151,11 @@ dependencies:
170
151
  - - '>='
171
152
  - !ruby/object:Gem::Version
172
153
  version: '0'
173
- none: false
174
154
  requirement: !ruby/object:Gem::Requirement
175
155
  requirements:
176
156
  - - '>='
177
157
  - !ruby/object:Gem::Version
178
158
  version: '0'
179
- none: false
180
159
  prerelease: false
181
160
  type: :development
182
161
  - !ruby/object:Gem::Dependency
@@ -186,13 +165,11 @@ dependencies:
186
165
  - - ~>
187
166
  - !ruby/object:Gem::Version
188
167
  version: 2.0.0
189
- none: false
190
168
  requirement: !ruby/object:Gem::Requirement
191
169
  requirements:
192
170
  - - ~>
193
171
  - !ruby/object:Gem::Version
194
172
  version: 2.0.0
195
- none: false
196
173
  prerelease: false
197
174
  type: :development
198
175
  - !ruby/object:Gem::Dependency
@@ -202,13 +179,11 @@ dependencies:
202
179
  - - ~>
203
180
  - !ruby/object:Gem::Version
204
181
  version: 3.2.0
205
- none: false
206
182
  requirement: !ruby/object:Gem::Requirement
207
183
  requirements:
208
184
  - - ~>
209
185
  - !ruby/object:Gem::Version
210
186
  version: 3.2.0
211
- none: false
212
187
  prerelease: false
213
188
  type: :development
214
189
  - !ruby/object:Gem::Dependency
@@ -218,13 +193,11 @@ dependencies:
218
193
  - - ~>
219
194
  - !ruby/object:Gem::Version
220
195
  version: '1.13'
221
- none: false
222
196
  requirement: !ruby/object:Gem::Requirement
223
197
  requirements:
224
198
  - - ~>
225
199
  - !ruby/object:Gem::Version
226
200
  version: '1.13'
227
- none: false
228
201
  prerelease: false
229
202
  type: :development
230
203
  description: |2
@@ -301,6 +274,7 @@ files:
301
274
  - lib/data/licenses/Ruby.txt
302
275
  - lib/data/licenses/SimplifiedBSD.txt
303
276
  - lib/license_finder.rb
277
+ - lib/license_finder/bower.rb
304
278
  - lib/license_finder/bundle.rb
305
279
  - lib/license_finder/cli.rb
306
280
  - lib/license_finder/configuration.rb
@@ -326,7 +300,9 @@ files:
326
300
  - lib/license_finder/possible_license_files.rb
327
301
  - lib/license_finder/railtie.rb
328
302
  - lib/license_finder/reports/dependency_report.rb
303
+ - lib/license_finder/reports/detailed_text_report.rb
329
304
  - lib/license_finder/reports/html_report.rb
305
+ - lib/license_finder/reports/markdown_report.rb
330
306
  - lib/license_finder/reports/reporter.rb
331
307
  - lib/license_finder/reports/text_report.rb
332
308
  - lib/license_finder/tables.rb
@@ -337,6 +313,7 @@ files:
337
313
  - lib/license_finder/yml_to_sql.rb
338
314
  - lib/tasks/license_finder.rake
339
315
  - lib/templates/html_report.erb
316
+ - lib/templates/markdown_report.erb
340
317
  - lib/templates/text_report.erb
341
318
  - license_finder.gemspec
342
319
  - readme.md
@@ -368,10 +345,12 @@ files:
368
345
  - spec/fixtures/readme/README
369
346
  - spec/fixtures/readme/Readme.markdown
370
347
  - spec/fixtures/utf8_gem/README
348
+ - spec/lib/license_finder/bower_spec.rb
371
349
  - spec/lib/license_finder/bundle_spec.rb
372
350
  - spec/lib/license_finder/cli_spec.rb
373
351
  - spec/lib/license_finder/configuration_spec.rb
374
352
  - spec/lib/license_finder/dependency_manager_spec.rb
353
+ - spec/lib/license_finder/detailed_text_report_spec.rb
375
354
  - spec/lib/license_finder/html_report_spec.rb
376
355
  - spec/lib/license_finder/license/apache_spec.rb
377
356
  - spec/lib/license_finder/license/bsd_spec.rb
@@ -385,6 +364,7 @@ files:
385
364
  - spec/lib/license_finder/license/simplified_bsd_spec.rb
386
365
  - spec/lib/license_finder/license_spec.rb
387
366
  - spec/lib/license_finder/license_url_spec.rb
367
+ - spec/lib/license_finder/markdown_report_spec.rb
388
368
  - spec/lib/license_finder/npm_spec.rb
389
369
  - spec/lib/license_finder/package_saver_spec.rb
390
370
  - spec/lib/license_finder/package_spec.rb
@@ -403,6 +383,7 @@ files:
403
383
  homepage: https://github.com/pivotal/LicenseFinder
404
384
  licenses:
405
385
  - MIT
386
+ metadata: {}
406
387
  post_install_message:
407
388
  rdoc_options: []
408
389
  require_paths:
@@ -411,25 +392,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
411
392
  requirements:
412
393
  - - '>='
413
394
  - !ruby/object:Gem::Version
414
- segments:
415
- - 0
416
- version: '0'
417
- hash: 2
418
- none: false
395
+ version: 1.9.2
419
396
  required_rubygems_version: !ruby/object:Gem::Requirement
420
397
  requirements:
421
398
  - - '>='
422
399
  - !ruby/object:Gem::Version
423
- segments:
424
- - 0
425
400
  version: '0'
426
- hash: 2
427
- none: false
428
401
  requirements: []
429
402
  rubyforge_project:
430
- rubygems_version: 1.8.24
403
+ rubygems_version: 2.2.0
431
404
  signing_key:
432
- specification_version: 3
405
+ specification_version: 4
433
406
  summary: Audit the OSS licenses of your application's dependencies.
434
407
  test_files:
435
408
  - features/approve_dependencies.feature
@@ -482,10 +455,12 @@ test_files:
482
455
  - spec/fixtures/readme/README
483
456
  - spec/fixtures/readme/Readme.markdown
484
457
  - spec/fixtures/utf8_gem/README
458
+ - spec/lib/license_finder/bower_spec.rb
485
459
  - spec/lib/license_finder/bundle_spec.rb
486
460
  - spec/lib/license_finder/cli_spec.rb
487
461
  - spec/lib/license_finder/configuration_spec.rb
488
462
  - spec/lib/license_finder/dependency_manager_spec.rb
463
+ - spec/lib/license_finder/detailed_text_report_spec.rb
489
464
  - spec/lib/license_finder/html_report_spec.rb
490
465
  - spec/lib/license_finder/license/apache_spec.rb
491
466
  - spec/lib/license_finder/license/bsd_spec.rb
@@ -499,6 +474,7 @@ test_files:
499
474
  - spec/lib/license_finder/license/simplified_bsd_spec.rb
500
475
  - spec/lib/license_finder/license_spec.rb
501
476
  - spec/lib/license_finder/license_url_spec.rb
477
+ - spec/lib/license_finder/markdown_report_spec.rb
502
478
  - spec/lib/license_finder/npm_spec.rb
503
479
  - spec/lib/license_finder/package_saver_spec.rb
504
480
  - spec/lib/license_finder/package_spec.rb