repubmark/tests/bibtex.rb
2024-10-19 02:02:30 +04:00

37 lines
1,009 B
Ruby
Executable file

#!/usr/bin/env ruby
# frozen_string_literal: true
require 'repubmark'
bib = BibTeX.parse(
File.expand_path('../examples/refs/bibtex.bib', __dir__),
filter: :latex,
)
Repubmark::References::Item
.from_bibtex('citekey-article', bib[:CitekeyArticle])
.tap do |ref|
p ref
raise unless
ref.title == 'The independence of the continuum hypothesis' &&
ref.year == 1963 &&
ref.authors.size == 1 &&
ref.authors[0].last == 'Cohen' &&
ref.authors[0].first == 'P. J.'
end
Repubmark::References::Item
.from_bibtex('citekey-techreport', bib[:CitekeyTechreport])
.tap do |ref|
p ref
raise unless
ref.title == 'Wasatch Solar Project Final Report' &&
ref.year == 2018 &&
ref.authors.size == 3 &&
ref.authors[0].last == 'Bennett' &&
ref.authors[0].first == 'Vicki' &&
ref.authors[1].last == 'Bowman' &&
ref.authors[1].first == 'Kate' &&
ref.authors[2].last == 'Wright' &&
ref.authors[2].first == 'Sarah'
end