diff options
| author | mo khan <mo.khan@gmail.com> | 2020-03-07 15:14:52 -0700 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2020-03-07 15:14:52 -0700 |
| commit | 09e3c5b986ed0251dd45e1854ad8ef304fe46952 (patch) | |
| tree | 6a0c84fa858cb5126e037828d56d94d5010451d2 /lib | |
| parent | bc29a9d7a98fab7de435d8a06007197efa189709 (diff) | |
Move license finder overrides to ext.rb
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/license/finder/ext.rb | 34 | ||||
| -rw-r--r-- | lib/license/management.rb | 33 |
2 files changed, 35 insertions, 32 deletions
diff --git a/lib/license/finder/ext.rb b/lib/license/finder/ext.rb new file mode 100644 index 0000000..7bd85df --- /dev/null +++ b/lib/license/finder/ext.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +# Apply patch to the JsonReport found in the `license_finder` gem. +LicenseFinder::JsonReport.prepend(License::Management::Report) + +module LicenseFinder + class Nuget + def prepare_command + "mono /usr/local/bin/nuget.exe restore -Verbosity detailed" + end + + def license_urls(dependency) + filename = "#{dependency.name}.#{dependency.version}.nupkg" + files = Dir["**/#{filename}"] + + Dir.glob(File.join(Dir.home, '.nuget', 'packages', '**', '**', filename.downcase)) + + return if files.empty? + + Zip::File.open(files.first) do |zipfile| + Nuget.nuspec_license_urls(zipfile.read(dependency.name + '.nuspec')) + end + end + end + + module SharedHelpers + class Cmd + def self.run(command) + stdout, stderr, status = Open3.capture3(command) + puts stdout if ENV['LM_DEBUG'] + [stdout, stderr, status] + end + end + end +end diff --git a/lib/license/management.rb b/lib/license/management.rb index 9003ab1..bfcf54c 100644 --- a/lib/license/management.rb +++ b/lib/license/management.rb @@ -10,38 +10,7 @@ require 'license/management/repository' require 'license/management/report' require 'license/management/version' -# This applies a monkey patch to the JsonReport found in the `license_finder` gem. -LicenseFinder::JsonReport.prepend(License::Management::Report) -module LicenseFinder - class Nuget - def prepare_command - "mono /usr/local/bin/nuget.exe restore -Verbosity detailed" - end - - def license_urls(dependency) - filename = "#{dependency.name}.#{dependency.version}.nupkg" - files = Dir["**/#{filename}"] + - Dir.glob(File.join(Dir.home, '.nuget', 'packages', '**', '**', filename.downcase)) - - return if files.empty? - - Zip::File.open(files.first) do |zipfile| - Nuget.nuspec_license_urls(zipfile.read(dependency.name + '.nuspec')) - end - end - end - - module SharedHelpers - class Cmd - def self.run(command) - stdout, stderr, status = Open3.capture3(command) - puts command - puts stdout - [stdout, stderr, status] - end - end - end -end +require 'license/finder/ext' module License module Management |
