summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/license/finder/ext.rb38
-rw-r--r--lib/license/finder/ext/license.rb7
-rw-r--r--lib/license/finder/ext/nuget.rb21
-rw-r--r--lib/license/finder/ext/shared_helpers.rb19
-rw-r--r--lib/license/management/version.rb2
5 files changed, 52 insertions, 35 deletions
diff --git a/lib/license/finder/ext.rb b/lib/license/finder/ext.rb
index c431b6b..9788abb 100644
--- a/lib/license/finder/ext.rb
+++ b/lib/license/finder/ext.rb
@@ -1,38 +1,8 @@
# frozen_string_literal: true
+require 'license/finder/ext/license'
+require 'license/finder/ext/nuget'
+require 'license/finder/ext/shared_helpers'
+
# 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)
- ::LicenseFinder::Core.default_logger.info(self.class, stdout) if ENV['CI_DEBUG_TRACE'] == 'true'
- [stdout, stderr, status]
- end
- end
- end
-
- class License
- attr_reader :short_name, :pretty_name, :other_names
- end
-end
diff --git a/lib/license/finder/ext/license.rb b/lib/license/finder/ext/license.rb
new file mode 100644
index 0000000..cca3bd7
--- /dev/null
+++ b/lib/license/finder/ext/license.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+module LicenseFinder
+ class License
+ attr_reader :short_name, :pretty_name, :other_names
+ end
+end
diff --git a/lib/license/finder/ext/nuget.rb b/lib/license/finder/ext/nuget.rb
new file mode 100644
index 0000000..fc06e21
--- /dev/null
+++ b/lib/license/finder/ext/nuget.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+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
+end
diff --git a/lib/license/finder/ext/shared_helpers.rb b/lib/license/finder/ext/shared_helpers.rb
new file mode 100644
index 0000000..4e61261
--- /dev/null
+++ b/lib/license/finder/ext/shared_helpers.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+module LicenseFinder
+ module SharedHelpers
+ class Cmd
+ def self.run(command)
+ stdout, stderr, status = Open3.capture3(command)
+ debug([command, stdout].join('\n'))
+ [stdout, stderr, status]
+ end
+
+ def self.debug(message)
+ return unless ENV['CI_DEBUG_TRACE'] == 'true'
+
+ ::LicenseFinder::Core.default_logger.info(self.class, message)
+ end
+ end
+ end
+end
diff --git a/lib/license/management/version.rb b/lib/license/management/version.rb
index 90b1ffa..ca107df 100644
--- a/lib/license/management/version.rb
+++ b/lib/license/management/version.rb
@@ -2,6 +2,6 @@
module License
module Management
- VERSION = '3.0.0'
+ VERSION = '3.1.0'
end
end