import: gem: Factorize "bundler" special case for name mapping.

* guix/import/gem.scm (ruby-package-name): Add "bundler" special case.
(gem->guix-package): Adjust accordingly.
* tests/gem.scm ("gem-recursive-import")
("gem-recursive-import with a specific version"): Remove "ruby-bundler"
from the expected packages.
This commit is contained in:
Ludovic Courtès 2023-05-28 23:11:03 +02:00
parent d46d1bee1e
commit e6f82fcd5f
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
2 changed files with 6 additions and 38 deletions

View file

@ -93,9 +93,11 @@ (define* (rubygems-fetch name #:optional version)
(define (ruby-package-name name)
"Given the NAME of a package on RubyGems, return a Guix-compliant name for
the package."
(if (string-prefix? "ruby-" name)
(snake-case name)
(string-append "ruby-" (snake-case name))))
(if (string=? name "bundler")
name ;special case: no prefix
(if (string-prefix? "ruby-" name)
(snake-case name)
(string-append "ruby-" (snake-case name)))))
(define (make-gem-sexp name version hash home-page synopsis description
dependencies licenses)
@ -135,11 +137,7 @@ (define* (gem->guix-package package-name #:key (repo 'rubygems) version
(let* ((dependencies-names (map gem-dependency-name
(gem-dependencies-runtime
(gem-dependencies gem))))
(dependencies (map (lambda (dep)
(if (string=? dep "bundler")
"bundler" ; special case, no prefix
(ruby-package-name dep)))
dependencies-names))
(dependencies (map ruby-package-name dependencies-names))
(licenses (map string->license (gem-licenses gem))))
(values (make-gem-sexp (gem-name gem) (gem-version gem)
(gem-sha256 gem) (gem-home-page gem)

View file

@ -181,21 +181,6 @@ (define test-bundler-json
('description "Another cool gem")
('home-page "https://example.com")
('license #f)) ;no licensing info
('package
('name "ruby-bundler")
('version "1.14.2")
('source
('origin
('method 'url-fetch)
('uri ('rubygems-uri "bundler" 'version))
('sha256
('base32
"1446xiz7zg0bz7kgx9jv84y0s4hpsg61dj5l3qb0i00avc1kxd9v"))))
('build-system 'ruby-build-system)
('synopsis "Ruby gem bundler")
('description "Ruby gem bundler")
('home-page "https://bundler.io/")
('license 'license:expat))
('package
('name "ruby-foo")
('version "1.0.0")
@ -248,21 +233,6 @@ (define test-bundler-json
('description "Another cool gem")
('home-page "https://example.com")
('license #f)) ;no licensing info
('package
('name "ruby-bundler")
('version "1.14.2")
('source
('origin
('method 'url-fetch)
('uri ('rubygems-uri "bundler" 'version))
('sha256
('base32
"1446xiz7zg0bz7kgx9jv84y0s4hpsg61dj5l3qb0i00avc1kxd9v"))))
('build-system 'ruby-build-system)
('synopsis "Ruby gem bundler")
('description "Ruby gem bundler")
('home-page "https://bundler.io/")
('license 'license:expat))
('package
('name "ruby-foo")
('version "2.0.0")