branch: elpa/hyperdrive
commit 751d46b3c5daac5e19a249f90478a1b874d35ab9
Author: Adam Porter <[email protected]>
Commit: Joseph Turner <[email protected]>
Change: (h//gateway-version) Factor out into new function
---
hyperdrive-lib.el | 12 +++++++++---
hyperdrive.el | 14 ++++----------
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/hyperdrive-lib.el b/hyperdrive-lib.el
index 6a9a683dab..3eb8943d74 100644
--- a/hyperdrive-lib.el
+++ b/hyperdrive-lib.el
@@ -202,14 +202,20 @@ make the request."
Unconditionally sets `h/gateway-version-checked-p' to t. The
caller should ensure that the gateway is running before calling
this function."
- ;; TODO: Consider moving `hyperdrive-hyper-gateway-ushin-version' into this
file.
- (declare-function hyperdrive-hyper-gateway-ushin-version "hyperdrive")
(unless (equal h/gateway-version-expected
;; This will signal an error if the gateway is not responsive.
- (hyperdrive-hyper-gateway-ushin-version))
+ (h//gateway-version))
(display-warning 'hyperdrive "Gateway version not expected; consider
installing the latest version with \\[hyperdrive-install]" :warning))
(setf h/gateway-version-checked-p t))
+(defun h//gateway-version ()
+ "Return the version number of gateway.
+If it's not running, signal an error."
+ (condition-case err
+ (let ((url (format "http://localhost:%d/" h/hyper-gateway-ushin-port)))
+ (alist-get 'version (plz 'get url :as #'json-read)))
+ (plz-error (h/api-default-else nil (caddr err)))))
+
(defun h/api-default-else (else plz-err)
"Handle common errors, overriding ELSE.
Checks for common errors; if none are found, calls ELSE with
diff --git a/hyperdrive.el b/hyperdrive.el
index 5632dd9632..aa577a0315 100644
--- a/hyperdrive.el
+++ b/hyperdrive.el
@@ -112,17 +112,11 @@ which see."
(funcall h/gateway-stop-function))
;;;###autoload
-(defun hyperdrive-hyper-gateway-ushin-version ()
- "Say version number of `hyper-gateway-ushin'.
-Gateway must be running."
+(defun hyperdrive-gateway-version ()
+ "Say version number of gateway.
+Return version if gateway is running; otherwise signal an error."
(interactive)
- (condition-case err
- (let* ((url (format "http://localhost:%d/" h/hyper-gateway-ushin-port))
- (version (alist-get 'version (plz 'get url :as #'json-read))))
- (when (called-interactively-p 'any)
- (h/message "hyper-gateway-ushin version %s" version))
- version)
- (plz-error (h/api-default-else nil (caddr err)))))
+ (h/message "%s" (h//gateway-version)))
;;;###autoload
(defun hyperdrive-new (seed)