Sha256: b367ea821d17845a5c837195eafa7e7a955d38dc28077d7b4896be9d2669bb32

Contents?: true

Size: 1.34 KB

Versions: 25

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

module Commonmeta
  module Writers
    module RisWriter
      def ris
        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(creators),
          '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)
          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

25 entries across 25 versions & 1 rubygems

Version Path
commonmeta-ruby-3.2.13 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.2.12 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.2.11 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.2.10 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.2.9 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.2.8 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.2.7 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.2.6 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.2.5 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.2.4 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.2.3 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.2.2 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.2.1 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.2.0 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.0.10 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.0.9 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.0.8 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.0.7 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.0.6 lib/commonmeta/writers/ris_writer.rb
commonmeta-ruby-3.0.5 lib/commonmeta/writers/ris_writer.rb