• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pulibrary / orangelight / 00dbc10b-d747-4ad7-b211-7b26d753abbb

14 Aug 2025 01:25PM UTC coverage: 0.483% (-94.9%) from 95.343%
00dbc10b-d747-4ad7-b211-7b26d753abbb

push

circleci

web-flow
Merge pull request #5181 from pulibrary/dependabot/bundler/activestorage-7.2.2.2

Bump activestorage from 7.2.2.1 to 7.2.2.2

47 of 9721 relevant lines covered (0.48%)

0.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/app/models/concerns/blacklight/document/ris.rb
1
# frozen_string_literal: false
2

3
require 'builder'
×
4
# This module provide Dublin Core export based on the document's semantic values
5
module Blacklight
×
6
  module Document
×
7
    module Ris
×
8
      def self.extended(document)
×
9
        # Register our exportable formats
10
        Blacklight::Document::Ris.register_export_formats(document)
×
11
      end
×
12

13
      def self.register_export_formats(document)
×
14
        document.will_export_as(:ris, 'application/x-research-info-systems')
×
15
        document.will_export_as(:mendeley, 'application/x-research-info-systems')
×
16
      end
×
17

18
      def ris_field_names
×
19
        {
×
20
          title_citation_display: 'TI',
×
21
          call_number_display: 'CN',
×
22
          form_genre_display: 'M3',
×
23
          summary_note_display: 'AB',
×
24
          notes_display: 'N1',
×
25
          source_acquisition_display: 'N1',
×
26
          edition_display: 'ET',
×
27
          number_of_pages_citation_display: 'SP',
×
28
          advisor_display: 'A2',
×
29
          department_display: 'A2',
×
30
          title_vern_display: 'T2',
×
31
          series_display: 'T3',
×
32
          pub_date_display: 'PY',
×
33
          pub_citation_display: 'PB',
×
34
          isbn_s: 'SN',
×
35
          issn_s: 'SN',
×
36
          language_facet: 'LA',
×
37
          subject_facet: 'KW'
×
38
        }
×
39
      end
×
40

41
      def export_as_ris
×
42
        ris = "TY - #{ris_format}\n"
×
43
        ris += ris_authors
×
44
        ris += ris_online_access_url
×
45
        to_h.each do |field, values|
×
46
          Array.wrap(values).each do |v|
×
47
            ris += "#{ris_field_name?(field)} - #{v}\n" if ris_field_name?(field)
×
48
          end
×
49
        end
×
50
        ris += 'ER - '
×
51
        ris
×
52
      end
×
53

54
      alias export_as_mendeley export_as_ris
×
55
      alias export_as_zoterio export_as_ris
×
56

57
      private
×
58

59
        def ris_format
×
60
          ris_format_mapping[self[:format].first] unless self[:format].nil?
×
61
        end
×
62

63
        def ris_format_mapping
×
64
          {
×
65
            'Audio' => 'SOUND',
×
66
            'Book' => 'BOOK',
×
67
            'Data file' => 'DATA',
×
68
            'Journal' => 'JFULL',
×
69
            'Manuscript' => 'MANSCPT',
×
70
            'Map' => 'MAP',
×
71
            'Musical Score' => 'MUSIC',
×
72
            'Musical score' => 'MUSIC',
×
73
            'Senior Thesis' => 'GEN',
×
74
            'Senior thesis' => 'GEN',
×
75
            'Video/Projected medium' => 'ADVS',
×
76
            'Visual material' => 'ART'
×
77
          }
×
78
        end
×
79

80
        def ris_field_name?(field)
×
81
          ris_field_names[field.to_sym]
×
82
        end
×
83

84
        ##
85
        # author_roles_1display_to_ris contains a JSON formatted list of authors
86
        # and their roles. Indicate primary and secondary authors in the RIS record.
87
        # @return [String]
88
        def author_roles_1display_to_ris
×
89
          authors = ''
×
90
          author_values = JSON.parse(self[:author_roles_1display]).symbolize_keys
×
91
          author_values.each do |key, value|
×
92
            if key == :primary_author # is key always a string rather than array?
×
93
              authors += "AU - #{value}\n"
×
94
            else
×
95
              unless key.empty?
×
96
                Array.wrap(value).each do |v|
×
97
                  authors += "A2 - #{v}\n"
×
98
                end
×
99
              end
×
100
            end
×
101
          end
×
102
          authors
×
103
        end
×
104

105
        ##
106
        # Populate the authors in the RIS record. Prefer the authors from author_roles_1display
107
        # if possible, so we can distinguish between primary and secondary roles.
108
        # Otherwise, list everyone in :author_display as a primary author.
109
        # @return [String]
110
        def ris_authors
×
111
          return author_roles_1display_to_ris if self[:author_roles_1display]
×
112
          authors = ''
×
113
          unless self[:author_display].nil?
×
114
            Array.wrap(self[:author_display]).each do |v|
×
115
              authors += "AU - #{v}\n"
×
116
            end
×
117
          end
×
118
          authors
×
119
        end
×
120

121
        ##
122
        # Populate the online access url from electronic_access_1display
123
        # @return [String]
124
        def ris_online_access_url
×
125
          return '' if self[:electronic_access_1display].blank?
×
126
          url_values = JSON.parse(self[:electronic_access_1display]).keys
×
127
          "UR - #{url_values.first}\n"
×
128
        end
×
129
    end
×
130
  end
×
131
end
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc