summaryrefslogtreecommitdiff
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
parente0b98189ebb3d524777bf1f4727e3a47e3a3bd38 (diff)
downloadslackbuilder-df4c9b4ae96afa7d8e7e44dbefc9e5035c3666db.tar.gz
Check the latest version from the LATEST text file
-rw-r--r--Rakefile5
-rw-r--r--lib/up2date.rb19
2 files changed, 21 insertions, 3 deletions
diff --git a/Rakefile b/Rakefile
index 7676d38..dacfa36 100644
--- a/Rakefile
+++ b/Rakefile
@@ -147,11 +147,12 @@ AUTO_UPDATABLE = {
'php82' => SlackBuilder::GitHub.new('php', 'php-src', php_transform),
'rdiff-backup' => SlackBuilder::GitHub.new('rdiff-backup', 'rdiff-backup'),
'librsync' => SlackBuilder::GitHub.new('librsync', 'librsync'),
- 'jitsi-meet-desktop' => SlackBuilder::GitHub.new('jitsi', 'jitsi-meet-electron')
+ 'jitsi-meet-desktop' => SlackBuilder::GitHub.new('jitsi', 'jitsi-meet-electron'),
+ 'dmd' => SlackBuilder::LatestText.new('https://downloads.dlang.org/releases/LATEST')
}.freeze
task :up2date do
AUTO_UPDATABLE.each do |key, value|
- latest_version = SlackBuilder.check_for_latest key, value
+ SlackBuilder.check_for_latest key, value
end
end
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