import: cpan: Update CPAN importer to use MetaCPAN v1 API.

* guix/import/cpan.scm (module->dist-name, cpan-fetch): Use metacpan.org
URLs.
* tests/cpan.scm ("cpan->guix-package"): Adjust accordingly.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
James Richardson 2017-06-03 14:37:54 -04:00 committed by Ludovic Courtès
parent fe4e0b0ae7
commit 4679dd6967
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
2 changed files with 4 additions and 4 deletions

View File

@ -88,7 +88,7 @@
"Return the base distribution module for a given module. E.g. the 'ok' "Return the base distribution module for a given module. E.g. the 'ok'
module is distributed with 'Test::Simple', so (module->dist-name \"ok\") would module is distributed with 'Test::Simple', so (module->dist-name \"ok\") would
return \"Test-Simple\"" return \"Test-Simple\""
(assoc-ref (json-fetch (string-append "https://api.metacpan.org/module/" (assoc-ref (json-fetch (string-append "https://fastapi.metacpan.org/v1/module/"
module module
"?fields=distribution")) "?fields=distribution"))
"distribution")) "distribution"))
@ -113,7 +113,7 @@ return \"Test-Simple\""
"Return an alist representation of the CPAN metadata for the perl module MODULE, "Return an alist representation of the CPAN metadata for the perl module MODULE,
or #f on failure. MODULE should be e.g. \"Test::Script\"" or #f on failure. MODULE should be e.g. \"Test::Script\""
;; This API always returns the latest release of the module. ;; This API always returns the latest release of the module.
(json-fetch (string-append "https://api.metacpan.org/release/" name))) (json-fetch (string-append "https://fastapi.metacpan.org/v1/release/" name)))
(define (cpan-home name) (define (cpan-home name)
(string-append "http://search.cpan.org/dist/" name)) (string-append "http://search.cpan.org/dist/" name))

View File

@ -74,10 +74,10 @@
(mock ((guix http-client) http-fetch (mock ((guix http-client) http-fetch
(lambda (url . rest) (lambda (url . rest)
(match url (match url
("https://api.metacpan.org/release/Foo-Bar" ("https://fastapi.metacpan.org/v1/release/Foo-Bar"
(values (open-input-string test-json) (values (open-input-string test-json)
(string-length test-json))) (string-length test-json)))
("https://api.metacpan.org/module/Test::Script?fields=distribution" ("https://fastapi.metacpan.org/v1/module/Test::Script?fields=distribution"
(let ((result "{ \"distribution\" : \"Test-Script\" }")) (let ((result "{ \"distribution\" : \"Test-Script\" }"))
(values (open-input-string result) (values (open-input-string result)
(string-length result)))) (string-length result))))