1
Fork 0
mirror of https://https.git.savannah.gnu.org/git/guix.git/ synced 2025-07-14 02:50:45 +02:00

gnu: ruby-anystyle: Update to 1.4.2.

* gnu/packages/ruby.scm (ruby-anystyle): Update to 1.4.2.
[native-inputs]: Add ruby-gdbm.
* gnu/packages/patches/ruby-anystyle-fix-dictionary-populate.patch:
Update patch.

Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
This commit is contained in:
Nicolas Graves 2025-01-31 09:19:34 +01:00 committed by Andreas Enge
parent e68b589e96
commit d129a6fdae
No known key found for this signature in database
GPG key ID: F7D5C9BF765C61E3
2 changed files with 87 additions and 90 deletions

View file

@ -52,7 +52,7 @@ index 761ca36..b9529d0 100644
end end
def open def open
- if File.exists?(options[:path]) - if File.exist?(options[:path])
- @db = ::Marshal.load(File.open(options[:path])) - @db = ::Marshal.load(File.open(options[:path]))
- else - else
- @db = {} - @db = {}

View file

@ -17809,100 +17809,97 @@ the power of the built-in @code{OptionParser}.")
(license license:bsd-2))) (license license:bsd-2)))
(define-public ruby-anystyle (define-public ruby-anystyle
(let ((commit "50f1dd547d28ab4b830e45d70e840cb1898a37b0") (package
(revision "1")) (name "ruby-anystyle")
;; Releases point to specific commits, but recent releases haven't been (version "1.4.2")
;; tagged in Git. Meanwhile, the rubygems archive lacks tests. (source (origin
(package (method git-fetch)
(name "ruby-anystyle") (uri (git-reference
(version (git-version "1.3.14" revision commit)) (url "https://github.com/inukshuk/anystyle")
(source (origin (commit (string-append "v" version))))
(method git-fetch) (sha256
(uri (git-reference (base32
(url "https://github.com/inukshuk/anystyle") "0xhy7wj8v7iahikck6vxbdpncaz5w2gb11b32kmvg5ckgi2kz23p"))
(commit commit))) (snippet
(sha256 ;; There is an optional dependency on
(base32 ;; <https://github.com/feedbackmine/language_detector>, which
"0f4qcrywl1kl6qysn24lj3yp85ln4i7za7b7ld2fglyzwcggxwb0")) ;; seems like it was intended to be free software, but
(snippet ;; doesn't have a clear license statement. Maybe someone can
;; There is an optional dependency on ;; do more sleuthing, or else find a replacement? See also
;; <https://github.com/feedbackmine/language_detector>, which ;; <https://github.com/inukshuk/anystyle/issues/186>. For
;; seems like it was intended to be free software, but ;; now, patch it out, but leave a pointer to follow up.
;; doesn't have a clear license statement. Maybe someone can #~(begin
;; do more sleuthing, or else find a replacement? See also (use-modules (guix build utils))
;; <https://github.com/inukshuk/anystyle/issues/186>. For (substitute* "Gemfile"
;; now, patch it out, but leave a pointer to follow up. (("gem 'language_detector', github: '[^']*'" orig)
#~(begin (string-append "# " orig " # unclear license")))
(use-modules (guix build utils)) (substitute* "spec/anystyle/parser_spec.rb"
(substitute* "Gemfile" (("language: 'en'," orig)
(("gem 'language_detector', github: '[^']*'" orig) (string-append "# " orig " # no lanugage_detector")))))
(string-append "# " orig " # unclear license"))) (patches
(substitute* "spec/anystyle/parser_spec.rb" (search-patches
(("language: 'en'," orig) "ruby-anystyle-fix-dictionary-populate.patch"))
(string-append "# " orig " # no lanugage_detector"))))) (file-name (git-file-name name version))))
(patches (build-system ruby-build-system)
(search-patches (propagated-inputs
"ruby-anystyle-fix-dictionary-populate.patch")) (list ruby-anystyle-data
(file-name (git-file-name name version)))) ruby-bibtex-ruby
(build-system ruby-build-system) ruby-namae
(propagated-inputs ruby-wapiti))
(list ruby-anystyle-data (native-inputs
ruby-bibtex-ruby (list ruby-byebug
ruby-namae ruby-citeproc
ruby-wapiti)) ruby-edtf
(native-inputs ruby-gdbm
(list ruby-byebug ruby-rspec
ruby-citeproc ruby-unicode-scripts))
ruby-edtf (arguments
ruby-rspec (list
ruby-unicode-scripts)) #:test-target "spec"
(arguments #:phases
(list #~(modify-phases %standard-phases
#:test-target "spec" (add-after 'extract-gemspec 'avoid-bundler
#:phases (lambda args
#~(modify-phases %standard-phases (substitute* "Rakefile"
(add-after 'extract-gemspec 'avoid-bundler (("require 'bundler" orig)
(lambda args (string-append "# " orig " # patched for Guix"))
(substitute* "Rakefile" (("Bundler\\.setup" orig)
(("require 'bundler" orig) (string-append "true # " orig " # patched for Guix")))))
(string-append "# " orig " # patched for Guix")) (add-after 'replace-git-ls-files 'replace-another-git-ls-files
(("Bundler\\.setup" orig) (lambda args
(string-append "true # " orig " # patched for Guix"))))) (substitute* "anystyle.gemspec"
(add-after 'replace-git-ls-files 'replace-another-git-ls-files (("`git ls-files spec`")
(lambda args "`find spec -type f | sort`"))))
(substitute* "anystyle.gemspec" (add-after 'wrap 'populate-dictionaries
(("`git ls-files spec`") (lambda args
"`find spec -type f | sort`")))) ;; We must initialize these files here, or they will never be
(add-after 'wrap 'populate-dictionaries ;; usable with the default settings. A more flexible approach
(lambda args ;; might use something like `Gem.find_files()` or
;; We must initialize these files here, or they will never be ;; XDG_DATA_DIRS.
;; usable with the default settings. A more flexible approach (with-output-to-file "initialize-dictionaries.rb"
;; might use something like `Gem.find_files()` or (lambda ()
;; XDG_DATA_DIRS. (display "\
(with-output-to-file "initialize-dictionaries.rb"
(lambda ()
(display "
require 'anystyle/dictionary' # must come before 'anystyle/data' require 'anystyle/dictionary' # must come before 'anystyle/data'
require 'anystyle/data' require 'anystyle/data'
[:marshal, :gdbm].each do |adapter| [:marshal, :gdbm].each do |adapter|
AnyStyle::Dictionary.create({adapter: adapter}).open().close() AnyStyle::Dictionary.create({adapter: adapter}).open().close()
end end
"))) ")))
(let* ((old-gems (getenv "GEM_PATH")) (let* ((old-gems (getenv "GEM_PATH"))
(new-gems (string-append #$output (new-gems (string-append #$output
"/lib/ruby/vendor_ruby:" "/lib/ruby/vendor_ruby:"
old-gems))) old-gems)))
(dynamic-wind (dynamic-wind
(lambda () (lambda ()
(setenv "GEM_PATH" new-gems)) (setenv "GEM_PATH" new-gems))
(lambda () (lambda ()
(invoke "ruby" "initialize-dictionaries.rb")) (invoke "ruby" "initialize-dictionaries.rb"))
(lambda () (lambda ()
(setenv "GEM_PATH" old-gems))))))))) (setenv "GEM_PATH" old-gems)))))))))
(home-page "https://anystyle.io") (home-page "https://anystyle.io")
(synopsis "Fast and smart citation reference parsing (Ruby library)") (synopsis "Fast and smart citation reference parsing (Ruby library)")
(description (description
"AnyStyle is a very fast and smart parser for academic reference lists "AnyStyle is a very fast and smart parser for academic reference lists
and bibliographies. AnyStyle uses powerful machine learning heuristics based and bibliographies. AnyStyle uses powerful machine learning heuristics based
on Conditional Random Fields and aims to make it easy to train the model with on Conditional Random Fields and aims to make it easy to train the model with
data that is relevant to your parsing needs. data that is relevant to your parsing needs.
@ -17910,7 +17907,7 @@ data that is relevant to your parsing needs.
This package provides the Ruby module @code{AnyStyle}. AnyStyle can also be This package provides the Ruby module @code{AnyStyle}. AnyStyle can also be
used via the @command{anystyle} command-line utility or a web application, used via the @command{anystyle} command-line utility or a web application,
though the later has not yet been packaged for Guix.") though the later has not yet been packaged for Guix.")
(license license:bsd-2)))) (license license:bsd-2)))
(define-public anystyle (define-public anystyle
(package (package