From 772f04dffd94970466e68642a896c5e4f59b55eb Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sat, 16 Aug 2014 19:37:50 -0400 Subject: Use unquote-splicing feature of guile-json 0.4.0. * README.md ("Dependencies"): Specify guile-json >= 0.4.0. * guix-web/view.scm (package->json): Use unquote-splicing to dedupe code. --- README.md | 2 +- guix-web/view.scm | 36 +++++++++++++++--------------------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 295bbfa..db9e9a9 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Dependencies * [GNU Guile](https://gnu.org/s/guile) >= 2.0.5 * [GNU Guix](https://gnu.org/s/guix) >= 0.6 -* [guile-json](https://github.com/aconchillo/guile-json) >= 0.3.1 +* [guile-json](https://github.com/aconchillo/guile-json) >= 0.4.0 Copyright --------- diff --git a/guix-web/view.scm b/guix-web/view.scm index 831fc7b..162e16b 100644 --- a/guix-web/view.scm +++ b/guix-web/view.scm @@ -106,27 +106,21 @@ (define (serialize-inputs packages) (map package->json (filter package? (map second packages)))) - (if serialize-inputs? - (json - (object - ("name" ,(package-name package)) - ("version" ,(package-version package)) - ("synopsis" ,(package-synopsis package)) - ("description" ,(package-description package)) - ("homepage" ,(package-home-page package)) - ("license" ,(serialize-license package)) - ("inputs" ,(serialize-inputs (package-inputs package))) - ("native-inputs" ,(serialize-inputs (package-native-inputs package))) - ("propagated-inputs" ,(serialize-inputs - (package-propagated-inputs package))))) - (json - (object - ("name" ,(package-name package)) - ("version" ,(package-version package)) - ("synopsis" ,(package-synopsis package)) - ("description" ,(package-description package)) - ("homepage" ,(package-home-page package)) - ("license" ,(serialize-license package)))))) + (json + (object + ("name" ,(package-name package)) + ("version" ,(package-version package)) + ("synopsis" ,(package-synopsis package)) + ("description" ,(package-description package)) + ("homepage" ,(package-home-page package)) + ("license" ,(serialize-license package)) + ,@(if serialize-inputs? + `(("inputs" ,(serialize-inputs (package-inputs package))) + ("native-inputs" ,(serialize-inputs + (package-native-inputs package))) + ("propagated-inputs" ,(serialize-inputs + (package-propagated-inputs package)))) + '())))) (define (all-packages-json) (map package->json (fold-packages cons '()))) -- cgit v1.2.3