Skip to content

Commit 998546d

Browse files
author
qount25
committed
Rename Pgpm::Package::PGXN#license into #license_text, restore old #license method
1 parent 7dec4dc commit 998546d

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

lib/pgpm/package/metadata.rb

-10
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,6 @@ def broken?
2525
requires.any?(&:broken?)
2626
end
2727

28-
def license
29-
path = "#{self.source.to_s}"
30-
["LICENSE", "license", "License"].each do |fn|
31-
if File.exist?("#{path}/#{fn}")
32-
return File.read("#{path}/#{fn}")
33-
end
34-
end
35-
nil
36-
end
37-
3828
module ClassMethods
3929
def extension_name
4030
self[:latest]&.extension_name

lib/pgpm/package/pgxn.rb

+16
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,22 @@ def description
4242
end
4343

4444
def license
45+
if provides_pgxn_meta_json?
46+
lic = pgxn_meta_json["license"]
47+
case lic
48+
when Hash
49+
lic.keys.join(" or ")
50+
when Array
51+
lic.join(" or ")
52+
when String
53+
lic
54+
end
55+
else
56+
super
57+
end
58+
end
59+
60+
def license_text
4561
path = "#{self.source.to_s}"
4662
["LICENSE", "license", "License"].each do |fn|
4763
if File.exist?("#{path}/#{fn}")

0 commit comments

Comments
 (0)