summaryrefslogtreecommitdiff
path: root/lib/up2date.rb
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2023-10-20 19:23:21 +0200
committerEugen Wissner <belka@caraus.de>2023-10-20 19:23:21 +0200
commit8a69240d88470c3f6076c8dd9130144a2e231a46 (patch)
tree7cdca1375affa47b2c36c3d19ce24c013ea38cb7 /lib/up2date.rb
parent3a6d17952b247682f1cb794ef27b26c9b007f00d (diff)
downloadslackbuilder-8a69240d88470c3f6076c8dd9130144a2e231a46.tar.gz
Add librsync and dmd
Diffstat (limited to 'lib/up2date.rb')
-rw-r--r--lib/up2date.rb58
1 files changed, 0 insertions, 58 deletions
diff --git a/lib/up2date.rb b/lib/up2date.rb
deleted file mode 100644
index c74dc90..0000000
--- a/lib/up2date.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at https://mozilla.org/MPL/2.0/.
-
-# frozen_string_literal: true
-
-require 'net/http'
-require 'json'
-require_relative '../config/config'
-require 'term/ansicolor'
-
-module SlackBuilder
- extend Term::ANSIColor
-
- # Remote repository for a single package.
- class Repository
- # Request the latest tag in the given repository.
- def latest
- raise NotImplementedError
- end
- end
-
- # Reads a remote LATEST file.
- class LatestText < Repository
- def initialize(latest_url)
- super()
-
- @latest_url = latest_url
- end
-
- def latest
- `./bin/slackbuilder text #{@latest_url}`.strip
- end
- end
-
- module_function
-
- # Checks if there is a new version for the package and returns the latest
- # version if an update is available, otherwise returns nil.
- def check_for_latest(package_name, repository)
- package = find_package_info package_name
- latest_version = repository.latest
-
- if package.version == latest_version
- puts green "#{package_name} is up to date (Version #{package.version})."
- nil
- else
- puts red "#{package_name}: Current version is #{package.version}, #{latest_version} is available."
- latest_version
- end
- end
-
- private_class_method def find_package_info(package_name)
- package_path = Pathname.new Dir.glob("#{CONFIG[:repository]}/*/#{package_name}").first
- package_category = package_path.dirname.basename.to_s
- Package.parse("#{package_category}/#{package_name}", File.read("#{package_path}/#{package_name}.info"))
- end
-end