• 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/dublin_core.rb
1
# frozen_string_literal: true
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 DublinCore
×
8
      def self.extended(document)
×
9
        # Register our exportable formats
10
        Blacklight::Document::DublinCore.register_export_formats(document)
×
11
      end
×
12

13
      def self.register_export_formats(document)
×
14
        document.will_export_as(:xml)
×
15
        document.will_export_as(:dc_xml, 'text/xml')
×
16
        document.will_export_as(:oai_dc_xml, 'text/xml')
×
17
        document.will_export_as(:rdf_dc, 'text/xml')
×
18
      end
×
19

20
      def dublin_core_field_names
×
21
        %i[contributor coverage creator date description format
×
22
           identifier language publisher relation rights source
×
23
           subject title type]
×
24
      end
×
25

26
      # dublin core elements are mapped against the #dublin_core_field_names whitelist.
27
      def export_as_oai_dc_xml
×
28
        xml = Builder::XmlMarkup.new
×
29
        xml.tag!('oai_dc:dc',
×
30
                 'xmlns:oai_dc' => 'http://www.openarchives.org/OAI/2.0/oai_dc/',
×
31
                 'xmlns:dc' => 'http://purl.org/dc/elements/1.1/',
×
32
                 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
×
33
                 'xsi:schemaLocation' => %(http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd)) do
×
34
          to_semantic_values.select { |field, _values| dublin_core_field_name? field }.each do |field, values|
×
35
            Array.wrap(values).each do |v|
×
36
              xml.tag! "dc:#{field}", v
×
37
            end
×
38
          end
×
39
        end
×
40
        xml.target!
×
41
      end
×
42

43
      def export_as_rdf_dc
×
44
        xml = Builder::XmlMarkup.new
×
45
        xml.tag!('rdf:RDF',
×
46
                 'xmlns:rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
×
47
                 'xmlns:dc' => 'http://purl.org/dc/elements/1.1/',
×
48
                 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance') do
×
49
          xml.tag!('rdf:Description', 'rdf:about' => "https://catalog.princeton.edu/catalog/#{id}") do
×
50
            to_semantic_values.select { |field, _values| dublin_core_field_name? field }.each do |field, values|
×
51
              Array.wrap(values).each do |v|
×
52
                xml.tag! "dc:#{field}", v
×
53
              end
×
54
            end
×
55
          end
×
56
        end
×
57
        xml.target!
×
58
      end
×
59

60
      alias export_as_xml export_as_oai_dc_xml
×
61
      alias export_as_dc_xml export_as_oai_dc_xml
×
62

63
      private
×
64

65
        def dublin_core_field_name?(field)
×
66
          dublin_core_field_names.include? field.to_sym
×
67
        end
×
68
    end
×
69
  end
×
70
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