Sha256: b04ef51a54e5b22e6aeba9b797b774fdfd4af45652997fa0e70d8a2ab033af67

Contents?: true

Size: 1.2 KB

Versions: 17

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

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

        pages = if container.to_h['firstPage'].present?
                  [container['firstPage'], container['lastPage']].compact.join('-')
                end

        bib = {
          bibtex_type: types['bibtex'].presence || 'misc',
          bibtex_key: normalize_doi(doi),
          doi: doi,
          url: url,
          author: authors_as_string(creators),
          keywords: if subjects.present?
                      Array.wrap(subjects).map do |k|
                        parse_attributes(k, content: 'subject', first: true)
                      end.join(', ')
                    end,
          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

17 entries across 17 versions & 1 rubygems

Version Path
briard-2.9.4 lib/briard/writers/bibtex_writer.rb
briard-2.9.3 lib/briard/writers/bibtex_writer.rb
briard-2.9.2 lib/briard/writers/bibtex_writer.rb
briard-2.9.1 lib/briard/writers/bibtex_writer.rb
briard-2.9.0 lib/briard/writers/bibtex_writer.rb
briard-2.8.2 lib/briard/writers/bibtex_writer.rb
briard-2.8.1 lib/briard/writers/bibtex_writer.rb
briard-2.8.0 lib/briard/writers/bibtex_writer.rb
briard-2.7.1 lib/briard/writers/bibtex_writer.rb
briard-2.7.0 lib/briard/writers/bibtex_writer.rb
briard-2.6.7 lib/briard/writers/bibtex_writer.rb
briard-2.6.6 lib/briard/writers/bibtex_writer.rb
briard-2.6.5 lib/briard/writers/bibtex_writer.rb
briard-2.6.4 lib/briard/writers/bibtex_writer.rb
briard-2.6.2 lib/briard/writers/bibtex_writer.rb
briard-2.6.1 lib/briard/writers/bibtex_writer.rb
briard-2.6.0 lib/briard/writers/bibtex_writer.rb