mirror of
https://https.git.savannah.gnu.org/git/guix.git/
synced 2025-07-16 12:00:35 +02:00
gnu: ruby-anystyle: Initialize dictionary files.
For the GDBM and Marshal dictionary adapters to be useful with their default settings, we must initialize their data files during the package build: upstream would initialize them lazily, but that doesn't work with an immutable installation directory (at least, not without more complex patches). Otherwise, we would always end up rebuilding the dictionary at startup, which is “slow” and “not recommended”. * gnu/packages/patches/ruby-anystyle-fix-dictionary-populate.patch: New patch. * gnu/local.mk (dist_patch_DATA): Add it. * gnu/packages/ruby.scm (ruby-anystyle)[patches]: Use it. [arguments]<#:phases>: Add 'populate-dictionaries' phase. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
parent
bc2de56572
commit
14a50b62d4
3 changed files with 125 additions and 1 deletions
|
@ -13516,6 +13516,9 @@ the power of the built-in @code{OptionParser}.")
|
|||
(substitute* "spec/anystyle/parser_spec.rb"
|
||||
(("language: 'en'," orig)
|
||||
(string-append "# " orig " # no lanugage_detector")))))
|
||||
(patches
|
||||
(search-patches
|
||||
"ruby-anystyle-fix-dictionary-populate.patch"))
|
||||
(file-name (git-file-name name version))))
|
||||
(build-system ruby-build-system)
|
||||
(propagated-inputs
|
||||
|
@ -13545,7 +13548,33 @@ the power of the built-in @code{OptionParser}.")
|
|||
(lambda args
|
||||
(substitute* "anystyle.gemspec"
|
||||
(("`git ls-files spec`")
|
||||
"`find spec -type f | sort`")))))))
|
||||
"`find spec -type f | sort`"))))
|
||||
(add-after 'wrap 'populate-dictionaries
|
||||
(lambda args
|
||||
;; We must initiallize these files here, or they will never be
|
||||
;; usable with the default settings. A more flexible approach
|
||||
;; might use something like `Gem.find_files()` or
|
||||
;; XDG_DATA_DIRS.
|
||||
(with-output-to-file "initialize-dictionaries.rb"
|
||||
(lambda ()
|
||||
(display "
|
||||
require 'anystyle/dictionary' # must come before 'anystyle/data'
|
||||
require 'anystyle/data'
|
||||
[:marshal, :gdbm].each do |adapter|
|
||||
AnyStyle::Dictionary.create({adapter: adapter}).open().close()
|
||||
end
|
||||
")))
|
||||
(let* ((old-gems (getenv "GEM_PATH"))
|
||||
(new-gems (string-append #$output
|
||||
"/lib/ruby/vendor_ruby:"
|
||||
old-gems)))
|
||||
(dynamic-wind
|
||||
(lambda ()
|
||||
(setenv "GEM_PATH" new-gems))
|
||||
(lambda ()
|
||||
(invoke "ruby" "initialize-dictionaries.rb"))
|
||||
(lambda ()
|
||||
(setenv "GEM_PATH" old-gems)))))))))
|
||||
(home-page "https://anystyle.io")
|
||||
(synopsis "Fast and smart citation reference parsing (Ruby library)")
|
||||
(description
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue