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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a685f3cfcc2a335e59d21f4848d508a24c9a082
4
- data.tar.gz: 53bedb396aac4876dcbda03be2c781b7444c0f45
3
+ metadata.gz: a3b754e74ea1f89d22e72c1f145618bafbda14aa
4
+ data.tar.gz: f6a5e9c7f1717e5901a746fc6dcac108e565a78c
5
5
  SHA512:
6
- metadata.gz: 536c44c9945a108f77d3beb5425dcf5b0888e3e6aa8a28c6750387afc90987ed5b64efe855d491f875902a47a275b47d2483e113b3fd3a5552670dd470d7e813
7
- data.tar.gz: e3775a625b547ca7843bff43eb26215049b416dbd6371c410e3006000ab71fe250467d249ec2b8d251cb20145ed93954e28de8d7f148a7cef648412f1e1ea04c
6
+ metadata.gz: 0eb69ee77b1c8734e3d4b1baef6c1dacca50bf267273926c548f5982e69f1080c50b0cb327fe3c655fa5b4cb9ca1de91fb14b06f64acf63d9e70aa1a42ee035f
7
+ data.tar.gz: 8a67ab3a162f55da1802a3b551a8a6398f0d2946cc977473052a991331ab3b9f727ee9411c9feec4b8955d09e101df5422eedbd855606886950b53ef1bc9a453
@@ -1,3 +1,10 @@
1
+ === 2.0.4 / 2015-04-16
2
+
3
+ * Features
4
+
5
+ * Allow project path to be set in a command line option (Thanks, @robertclancy!)
6
+
7
+
1
8
  === 2.0.3 / 2015-03-18
2
9
 
3
10
  * Bugfixes
@@ -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
- @output, @exit_code = Paths.project.shell_out(command, true)
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
 
@@ -15,19 +15,18 @@ module LicenseFinder
15
15
  Logger::Default.new
16
16
  end
17
17
 
18
- # +options+ look like:
18
+ # Default +options+:
19
19
  # {
20
- # logger: { quiet: true, debug: false },
21
- # project_path: "./some/project/path/"
22
- # decisions_file: "./some/path.yml",
23
- # gradle_command: "gradlew",
24
- # rebar_command: "rebar2",
25
- # rebar_deps_dir: "./some/rebar/path",
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
- # +gradle_command+ and +decisions_file+ are optional, see Configuration
28
- def initialize(options)
29
- @logger = Logger.new(options.fetch(:logger))
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 = JSON(output) rescue nil
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." unless ENV['test_run']
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
@@ -1,3 +1,3 @@
1
1
  module LicenseFinder
2
- VERSION = "2.0.3"
2
+ VERSION = "2.0.4"
3
3
  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
@@ -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).rmtree
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.3
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-03-18 00:00:00.000000000 Z
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.5
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.