Adds the following functions to the `versions' egg:

   (define (local egg)
      (irregex-replace
       (format "~%")
       (last
        (string-split
         (call-with-input-pipe
          (string-append "chicken-status " egg)
          read-all)))))

   (define (remote egg #!optional url)
      (let ((.url.
         (if url
             url
   "http://chicken.kitten-technologies.co.uk/henrietta.cgi?name=";)))
        (version-sort
         (string-split
          (with-input-from-request
           (string-append
        .url.
        (uri-encode-string egg)
        "&listversions=1")
           #f read-all)
          (format "~%")))))

   (define (update-available? egg #!optional url)
      (version-newer? (last (remote egg)) (local egg)))


The above functions can/could be used as the basis for a more flexible/powerful means of updating eggs, as in only updating eggs that actually needed to be updated instead of just updating all of them. The functions depend on the /http-client/, /uri-generic/, and /versions/ eggs; they also use the /irregex/, /posix/, and /utils/ units.

If these don't seem like a good fit for /versions/, then that's okay: so long as these functions get added to /some/ egg, I'll live: I just felt that they'd be out of place in the /readline/ egg.


>From 5d16d26605dad1c3970a9143603e3d22eeeb6198 Mon Sep 17 00:00:00 2001
From: amagura <sickhadas.c...@gmail.com>
Date: Wed, 12 Aug 2015 03:55:40 -0600
Subject: [PATCH] adds `local', `remote', and `update-available?'

---
 versions/versions.meta |  2 +-
 versions/versions.scm  | 32 +++++++++++++++++++++++++++++++-
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/versions/versions.meta b/versions/versions.meta
index 9662d76..6a2c63f 100644
--- a/versions/versions.meta
+++ b/versions/versions.meta
@@ -14,7 +14,7 @@
 ((egg       "versions.egg")
  (category  egg-tools)
  (synopsis  "Procedures for extraction and comparison of version strings")
- (needs     eggdoc)
+ (needs     eggdoc http-client uri-generic)
  (eggdoc    "doc.scm")
  (author    "elf")
  (license   "BSD")
diff --git a/versions/versions.scm b/versions/versions.scm
index 5b4d707..9930892 100644
--- a/versions/versions.scm
+++ b/versions/versions.scm
@@ -48,13 +48,17 @@
  bump:micro!
  bump:patch!
  bump!
+ local
+ remote
+ update-available?
 
  )
 
 (import chicken scheme)
 (require-library srfi-1 srfi-13)
-(import srfi-1 srfi-13 data-structures)
+(import srfi-1 srfi-13 data-structures irregex posix utils)
 (import (only extras fprintf))
+(use http-client uri-generic)
 
 
 ;;; version type
@@ -485,6 +489,32 @@
      ((version:micro version) (bump:micro! version))
      ((version:minor version) (bump:minor! version)))))
 
+(define (local egg)
+  (irregex-replace
+   (format "~%")
+   (last
+    (string-split
+     (call-with-input-pipe
+      (string-append "chicken-status " egg)
+      read-all)))))
+
+(define (remote egg #!optional url)
+  (let ((.url.
+	 (if url
+	     url
+	     "http://chicken.kitten-technologies.co.uk/henrietta.cgi?name=";)))
+    (version-sort
+     (string-split
+      (with-input-from-request
+       (string-append
+	.url.
+	(uri-encode-string egg)
+	"&listversions=1")
+       #f read-all)
+      (format "~%")))))
+
+(define (update-available? egg #!optional url)
+  (version-newer? (last (remote egg)) (local egg)))
 
 
 )
-- 
2.5.0


_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to