summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2023-06-30 11:02:20 +0200
committerEugen Wissner <belka@caraus.de>2023-06-30 11:02:20 +0200
commitdf4c9b4ae96afa7d8e7e44dbefc9e5035c3666db (patch)
tree76188d0b4bed1728bf37ad2dfbc9f7b9e6c70c52 /lib
parente0b98189ebb3d524777bf1f4727e3a47e3a3bd38 (diff)
downloadslackbuilder-df4c9b4ae96afa7d8e7e44dbefc9e5035c3666db.tar.gz
Check the latest version from the LATEST text file
Diffstat (limited to 'lib')
-rw-r--r--lib/up2date.rb19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/up2date.rb b/lib/up2date.rb
index f68a1fc..3387941 100644
--- a/lib/up2date.rb
+++ b/lib/up2date.rb
@@ -20,6 +20,7 @@ module SlackBuilder
end
end
+ # Reads the list fo tags from the GitHub API.
class GitHub < Repository
GITHUB_QUERY = <<~GQL
query ($name: String!, $owner: String!) {
@@ -66,6 +67,7 @@ module SlackBuilder
end
end
+ # Request the latest version from the packagist API.
class Packagist < Repository
def initialize(vendor, name)
super()
@@ -74,7 +76,6 @@ module SlackBuilder
@name = name
end
- # Request the latest version from the packagist API.
def latest
full_name = [@vendor, @name].join '/'
uri = URI "https://repo.packagist.org/p2/#{full_name}.json"
@@ -85,6 +86,22 @@ module SlackBuilder
end
end
+ # Reads a remote LATEST file.
+ class LatestText < Repository
+ def initialize(latest_url)
+ super()
+
+ @latest_url = URI latest_url
+ end
+
+ def latest
+ response = Net::HTTP.get @latest_url, {
+ 'content-type' => 'text/plain'
+ }
+ response.strip
+ end
+ end
+
module_function
# Checks if there is a new version for the package and returns the latest