summaryrefslogtreecommitdiff
path: root/lib/license/management/nuspec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/license/management/nuspec.rb')
-rw-r--r--lib/license/management/nuspec.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/license/management/nuspec.rb b/lib/license/management/nuspec.rb
new file mode 100644
index 0000000..cd785b4
--- /dev/null
+++ b/lib/license/management/nuspec.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+module License
+ module Management
+ class Nuspec
+ attr_reader :xml
+
+ def initialize(xml)
+ @xml = REXML::Document.new(xml)
+ end
+
+ def licenses
+ licenses = REXML::XPath.match(xml, "//package/metadata/license[@type='expression']").map(&:get_text).map(&:to_s)
+ return licenses if licenses.any?
+
+ REXML::XPath.match(xml, '//package/metadata/licenseUrl').map(&:get_text).map(&:to_s)
+ end
+ end
+ end
+end