Sha256: a70e30369344ff7ff27b3df80cf1bb27082f3adf40ec286e692169f212688e29

Contents?: true

Size: 1.08 KB

Versions: 25

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module Bolognese
  module Writers
    module BibtexWriter
      def bibtex
        return nil unless valid?

        pages = container.to_h["firstPage"].present? ? [container["firstPage"], container["lastPage"]].compact.join("-") : nil

        bib = {
          bibtex_type: types["bibtex"].presence || "misc",
          bibtex_key: normalize_doi(doi),
          doi: doi,
          url: url,
          author: authors_as_string(creators),
          keywords: subjects.present? ? Array.wrap(subjects).map { |k| parse_attributes(k, content: "subject", first: true) }.join(", ") : nil,
          language: language,
          title: parse_attributes(titles, content: "title", first: true),
          journal: container && container["title"],
          volume: container.to_h["volume"],
          issue: container.to_h["issue"],
          pages: pages,
          publisher: publisher,
          year: publication_year,
          copyright: Array.wrap(rights_list).map { |l| l["rights"] }.first,
        }.compact
        BibTeX::Entry.new(bib).to_s
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
bolognese-1.11.5 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.11.4 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.11.3 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.11.2 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.11.0 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.10.0 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.9.18 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.9.17 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.9.14 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.9.13 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.9.12 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.9.11 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.9.10 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.9.9 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.9.8 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.9.7 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.9.6 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.9.5 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.9.4 lib/bolognese/writers/bibtex_writer.rb
bolognese-1.9.3 lib/bolognese/writers/bibtex_writer.rb