license_finder 2.0.3 → 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.rdoc +7 -0
- data/features/features/configure/set_project_path_spec.rb +17 -0
- data/features/support/testing_dsl.rb +12 -4
- data/lib/license_finder/cli/base.rb +2 -2
- data/lib/license_finder/core.rb +10 -11
- data/lib/license_finder/license/definitions.rb +1 -1
- data/lib/license_finder/package_managers/npm.rb +6 -2
- data/lib/license_finder/reports/erb_report.rb +1 -2
- data/lib/license_finder/version.rb +1 -1
- data/spec/lib/license_finder/package_managers/npm_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -3
- data/spec/support/stdout_helpers.rb +13 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3b754e74ea1f89d22e72c1f145618bafbda14aa
|
4
|
+
data.tar.gz: f6a5e9c7f1717e5901a746fc6dcac108e565a78c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0eb69ee77b1c8734e3d4b1baef6c1dacca50bf267273926c548f5982e69f1080c50b0cb327fe3c655fa5b4cb9ca1de91fb14b06f64acf63d9e70aa1a42ee035f
|
7
|
+
data.tar.gz: 8a67ab3a162f55da1802a3b551a8a6398f0d2946cc977473052a991331ab3b9f727ee9411c9feec4b8955d09e101df5422eedbd855606886950b53ef1bc9a453
|
data/CHANGELOG.rdoc
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'feature_helper'
|
2
|
+
|
3
|
+
describe "Project path" do
|
4
|
+
# As a developer
|
5
|
+
# I want to set a project path
|
6
|
+
# So that I can run license finder in a different Bundle environment to the project.
|
7
|
+
|
8
|
+
let(:developer) { LicenseFinder::TestingDSL::User.new }
|
9
|
+
|
10
|
+
specify "can be overridden on the command line" do
|
11
|
+
project = developer.create_ruby_app
|
12
|
+
gem = developer.create_gem 'mitlicensed_dep', license: 'MIT', version: '1.2.3'
|
13
|
+
project.depend_on gem
|
14
|
+
developer.execute_command_outside_project("license_finder --quiet --project_path #{project.project_dir}")
|
15
|
+
expect(developer).to be_seeing 'mitlicensed_dep, 1.2.3, MIT'
|
16
|
+
end
|
17
|
+
end
|
@@ -19,7 +19,11 @@ module LicenseFinder::TestingDSL
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def execute_command(command)
|
22
|
-
|
22
|
+
execute_command_in_path(command, Paths.project)
|
23
|
+
end
|
24
|
+
|
25
|
+
def execute_command_outside_project(command)
|
26
|
+
execute_command_in_path(command, Paths.root)
|
23
27
|
end
|
24
28
|
|
25
29
|
def seeing?(content)
|
@@ -42,6 +46,12 @@ module LicenseFinder::TestingDSL
|
|
42
46
|
execute_command 'license_finder report --format html'
|
43
47
|
HtmlReport.from_string(@output)
|
44
48
|
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def execute_command_in_path(command, path)
|
53
|
+
@output, @exit_code = path.shell_out(command, true)
|
54
|
+
end
|
45
55
|
end
|
46
56
|
|
47
57
|
require 'forwardable'
|
@@ -67,8 +77,6 @@ module LicenseFinder::TestingDSL
|
|
67
77
|
def install
|
68
78
|
end
|
69
79
|
|
70
|
-
private
|
71
|
-
|
72
80
|
def project_dir
|
73
81
|
Paths.project
|
74
82
|
end
|
@@ -262,7 +270,7 @@ module LicenseFinder::TestingDSL
|
|
262
270
|
|
263
271
|
def root
|
264
272
|
# where license_finder is installed
|
265
|
-
Pathname.new(__FILE__).dirname.join("..", "..").realpath
|
273
|
+
ProjectDir.new(Pathname.new(__FILE__).dirname.join("..", "..").realpath)
|
266
274
|
end
|
267
275
|
|
268
276
|
def fixtures
|
@@ -3,6 +3,7 @@ require 'thor'
|
|
3
3
|
module LicenseFinder
|
4
4
|
module CLI
|
5
5
|
class Base < Thor
|
6
|
+
class_option :project_path, desc: "Path to the project. Defaults to current working directory."
|
6
7
|
class_option :decisions_file, desc: "Where decisions are saved. Defaults to doc/dependency_decisions.yml."
|
7
8
|
|
8
9
|
no_commands do
|
@@ -18,9 +19,8 @@ module LicenseFinder
|
|
18
19
|
end
|
19
20
|
|
20
21
|
def license_finder_config
|
21
|
-
result = extract_options(:decisions_file, :gradle_command, :rebar_command, :rebar_deps_dir)
|
22
|
+
result = extract_options(:project_path, :decisions_file, :gradle_command, :rebar_command, :rebar_deps_dir)
|
22
23
|
result[:logger] = logger_config
|
23
|
-
result[:project_path] = Pathname.pwd
|
24
24
|
result
|
25
25
|
end
|
26
26
|
|
data/lib/license_finder/core.rb
CHANGED
@@ -15,19 +15,18 @@ module LicenseFinder
|
|
15
15
|
Logger::Default.new
|
16
16
|
end
|
17
17
|
|
18
|
-
# +options
|
18
|
+
# Default +options+:
|
19
19
|
# {
|
20
|
-
#
|
21
|
-
#
|
22
|
-
# decisions_file: "
|
23
|
-
# gradle_command: "
|
24
|
-
# rebar_command: "
|
25
|
-
# rebar_deps_dir: "
|
20
|
+
# project_path: Pathname.pwd
|
21
|
+
# logger: {}, # can include quiet: true or debug: true
|
22
|
+
# decisions_file: "doc/dependency_decisions.yml",
|
23
|
+
# gradle_command: "gradle",
|
24
|
+
# rebar_command: "rebar",
|
25
|
+
# rebar_deps_dir: "deps",
|
26
26
|
# }
|
27
|
-
|
28
|
-
|
29
|
-
@
|
30
|
-
@project_path = Pathname(options.fetch(:project_path))
|
27
|
+
def initialize(options = {})
|
28
|
+
@logger = Logger.new(options.fetch(:logger, {}))
|
29
|
+
@project_path = Pathname(options.fetch(:project_path, Pathname.pwd))
|
31
30
|
@config = Configuration.with_optional_saved_config(options, project_path)
|
32
31
|
@decisions = Decisions.saved!(config.decisions_file)
|
33
32
|
end
|
@@ -157,7 +157,7 @@ module LicenseFinder
|
|
157
157
|
License.new(
|
158
158
|
short_name: "SimplifiedBSD",
|
159
159
|
pretty_name: "Simplified BSD",
|
160
|
-
other_names: ["FreeBSD", "2-clause BSD", "BSD-2-Clause"],
|
160
|
+
other_names: ["FreeBSD", "2-clause BSD", "BSD-2-Clause", "BSD 2-Clause"],
|
161
161
|
url: "http://opensource.org/licenses/bsd-license"
|
162
162
|
)
|
163
163
|
end
|
@@ -24,9 +24,13 @@ module LicenseFinder
|
|
24
24
|
if success
|
25
25
|
json = JSON(output)
|
26
26
|
else
|
27
|
-
json =
|
27
|
+
json = begin
|
28
|
+
JSON(output)
|
29
|
+
rescue JSON::ParserError
|
30
|
+
nil
|
31
|
+
end
|
28
32
|
if json
|
29
|
-
$stderr.puts "Command #{command} returned error but parsing succeeded."
|
33
|
+
$stderr.puts "Command #{command} returned error but parsing succeeded."
|
30
34
|
else
|
31
35
|
raise "Command #{command} failed to execute: #{output}"
|
32
36
|
end
|
@@ -4,8 +4,7 @@ module LicenseFinder
|
|
4
4
|
class ErbReport < Report
|
5
5
|
TEMPLATE_PATH = ROOT_PATH.join('reports', 'templates')
|
6
6
|
|
7
|
-
def to_s
|
8
|
-
filename = TEMPLATE_PATH.join("#{template_name}.erb")
|
7
|
+
def to_s(filename = TEMPLATE_PATH.join("#{template_name}.erb"))
|
9
8
|
template = ERB.new(filename.read, nil, '-')
|
10
9
|
template.result(binding)
|
11
10
|
end
|
@@ -91,7 +91,7 @@ module LicenseFinder
|
|
91
91
|
|
92
92
|
it "does not fail when command fails but produces output" do
|
93
93
|
allow(npm).to receive(:capture).with(/npm/).and_return('{"foo":"bar"}', false).once
|
94
|
-
npm.current_packages
|
94
|
+
silence_stderr { npm.current_packages }
|
95
95
|
end
|
96
96
|
end
|
97
97
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -7,8 +7,6 @@ require 'rspec'
|
|
7
7
|
require 'webmock/rspec'
|
8
8
|
require 'rspec/its'
|
9
9
|
|
10
|
-
ENV['test_run'] = true.to_s
|
11
|
-
|
12
10
|
Dir[File.join(File.dirname(__FILE__), 'support', '**', '*.rb')].each do |file|
|
13
11
|
require file
|
14
12
|
end
|
@@ -20,7 +18,8 @@ end
|
|
20
18
|
RSpec.configure do |config|
|
21
19
|
config.after(:suite) do
|
22
20
|
["./doc"].each do |tmp_dir|
|
23
|
-
Pathname(tmp_dir)
|
21
|
+
tmp_dir = Pathname(tmp_dir)
|
22
|
+
tmp_dir.rmtree if tmp_dir.directory?
|
24
23
|
end
|
25
24
|
end
|
26
25
|
|
@@ -1,4 +1,17 @@
|
|
1
1
|
module StdoutHelpers
|
2
|
+
def capture_stderr
|
3
|
+
orig_stderr = $stderr
|
4
|
+
$stderr = StringIO.new
|
5
|
+
|
6
|
+
yield
|
7
|
+
|
8
|
+
$stderr.string
|
9
|
+
ensure
|
10
|
+
$stderr = orig_stderr
|
11
|
+
end
|
12
|
+
|
13
|
+
alias silence_stderr capture_stderr
|
14
|
+
|
2
15
|
def capture_stdout
|
3
16
|
orig_stdout = $stdout
|
4
17
|
$stdout = StringIO.new
|
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: 2.0.
|
4
|
+
version: 2.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacob Maine
|
@@ -20,7 +20,7 @@ authors:
|
|
20
20
|
autorequire:
|
21
21
|
bindir: bin
|
22
22
|
cert_chain: []
|
23
|
-
date: 2015-
|
23
|
+
date: 2015-04-16 00:00:00.000000000 Z
|
24
24
|
dependencies:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
@@ -199,6 +199,7 @@ files:
|
|
199
199
|
- features/features/configure/ignore_dependencies_spec.rb
|
200
200
|
- features/features/configure/ignore_groups_spec.rb
|
201
201
|
- features/features/configure/name_project_spec.rb
|
202
|
+
- features/features/configure/set_project_path_spec.rb
|
202
203
|
- features/features/configure/whitelist_licenses_spec.rb
|
203
204
|
- features/features/package_managers/bower_spec.rb
|
204
205
|
- features/features/package_managers/cocoapods_spec.rb
|
@@ -370,7 +371,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
370
371
|
version: '0'
|
371
372
|
requirements: []
|
372
373
|
rubyforge_project:
|
373
|
-
rubygems_version: 2.4.
|
374
|
+
rubygems_version: 2.4.6
|
374
375
|
signing_key:
|
375
376
|
specification_version: 4
|
376
377
|
summary: Audit the OSS licenses of your application's dependencies.
|