import: cran: Move beautify-description to utils module.

* guix/import/cran.scm (beautify-description): Move from here...
* guix/import/utils.scm: ... to here.
This commit is contained in:
Ben Woodcroft 2016-01-06 00:09:19 +10:00
parent 6b3a1ce8d7
commit 2028a2c960
2 changed files with 13 additions and 12 deletions

View file

@ -136,17 +136,6 @@ (define (listify meta field)
(string-any char-set:whitespace item)))
(map string-trim-both items))))))
(define (beautify-description description)
"Improve the package DESCRIPTION by turning a beginning sentence fragment
into a proper sentence and by using two spaces between sentences."
(let ((cleaned (if (string-prefix? "A " description)
(string-append "This package provides a"
(substring description 1))
description)))
;; Use double spacing between sentences
(regexp-substitute/global #f "\\. \\b"
cleaned 'pre ". " 'post)))
(define (description->package meta)
"Return the `package' s-expression for a CRAN package from the alist META,
which was derived from the R package's DESCRIPTION file."

View file

@ -37,7 +37,8 @@ (define-module (guix import utils)
string->license
license->symbol
snake-case))
snake-case
beautify-description))
(define (factorize-uri uri version)
"Factorize URI, a package tarball URI as a string, such that any occurrences
@ -136,3 +137,14 @@ (define (snake-case str)
"Return a downcased version of the string STR where underscores are replaced
with dashes."
(string-join (string-split (string-downcase str) #\_) "-"))
(define (beautify-description description)
"Improve the package DESCRIPTION by turning a beginning sentence fragment
into a proper sentence and by using two spaces between sentences."
(let ((cleaned (if (string-prefix? "A " description)
(string-append "This package provides a"
(substring description 1))
description)))
;; Use double spacing between sentences
(regexp-substitute/global #f "\\. \\b"
cleaned 'pre ". " 'post)))