Sha256: 9205c591fe349a8da4a34a15b5bc2dae94909c501bd7d385c857500505dcd85d

Contents?: true

Size: 1.43 KB

Versions: 21

Compression:

Stored size: 1.43 KB

Contents

# frozen_string_literal: true

module Commonmeta
  module Writers
    module RisWriter
      def ris
        authors = contributors.select { |c| c['contributorRoles'] == ['Author'] }
        sn = container.to_h['identifier']
        sn = sn.downcase if sn.present? && container.to_h['identifierType'] == 'DOI'
        {
          'TY' => Commonmeta::Utils::CM_TO_RIS_TRANSLATIONS.fetch(type, 'GEN'),
          'T1' => parse_attributes(titles, content: 'title', first: true),
          'T2' => container.to_h['title'],
          'AU' => to_ris(authors),
          'DO' => doi_from_url(id),
          'UR' => url,
          'AB' => parse_attributes(descriptions, content: 'description', first: true),
          'KW' => Array.wrap(subjects).map do |k|
            parse_attributes(k, content: 'subject', first: true).capitalize
          end.presence,
          'PY' => date['published'] && date['published'].split('-').first,
          'PB' => publisher['name'],
          'LA' => language,
          'VL' => container.to_h['volume'],
          'IS' => container.to_h['issue'],
          'SP' => container.to_h['firstPage'],
          'EP' => container.to_h['lastPage'],
          'SN' => sn,
          'ER' => ''
        }.compact.map do |k, v|
          if v.is_a?(Array)
            v.map do |vi|
              "#{k}  - #{vi}"
            end.join("\r\n")
          else
            "#{k}  - #{v}"
          end
        end.join("\r\n")
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
commonmeta-ruby-3.13 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.12.1 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.12.0 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.11.0 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.9.0 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.8.3 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.8.2 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.8.1 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.8.0 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.7.3 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.7.2 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.7.1 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.7.0 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.6.1 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.6 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.5.5 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.5.4 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.5.3 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.5.2 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.5.1 lib/commonmeta/writers/ris_writer.rb