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

pulibrary / pdc_describe / 4e4e59fc-9df4-4838-9fd4-6c7ea33cdb7c

07 Apr 2025 06:36PM UTC coverage: 1.283% (-94.6%) from 95.862%
4e4e59fc-9df4-4838-9fd4-6c7ea33cdb7c

Pull #1994

circleci

hectorcorrea
Switched to use the autocomplete that we aleady use for ROR. Integrated it with the existing logic for creators
Pull Request #1994: Started adding auto complete to contributors

0 of 46 new or added lines in 2 files covered. (0.0%)

4806 existing lines in 74 files now uncovered.

65 of 5065 relevant lines covered (1.28%)

0.01 hits per line

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

0.0
/app/models/pdc_metadata/related_object.rb
1
# frozen_string_literal: true
2
# Class for storing a related object
UNCOV
3
module PDCMetadata
×
4
  # let(:related_identifier) { "https://www.biorxiv.org/content/10.1101/545517v1" }
5
  # let(:related_identifier_type) { "arXiv" }
6
  # let(:relation_type) { "IsCitedBy" }
UNCOV
7
  class RelatedObject
×
UNCOV
8
    attr_accessor :related_identifier, :related_identifier_type, :relation_type, :errors
×
9

UNCOV
10
    def initialize(related_identifier:, related_identifier_type:, relation_type:)
×
UNCOV
11
      @related_identifier = related_identifier
×
UNCOV
12
      @related_identifier_type = related_identifier_type
×
UNCOV
13
      @relation_type = relation_type
×
14

15
      # TODO: Older records have a different format.
16
      # When we migrate these, then this can be removed.
UNCOV
17
      unless related_identifier_type.blank? || valid_related_identifier_type?
×
UNCOV
18
        @related_identifier_type = ::Datacite::Mapping::RelatedIdentifierType.find do |obj|
×
UNCOV
19
          ::PDCMetadata.fuzzy_match(obj, related_identifier_type)
×
UNCOV
20
        end.value
×
UNCOV
21
      end
×
UNCOV
22
      unless relation_type.blank? || valid_relation_type?
×
UNCOV
23
        @relation_type = ::Datacite::Mapping::RelationType.find do |obj|
×
UNCOV
24
          ::PDCMetadata.fuzzy_match(obj, relation_type)
×
UNCOV
25
        end.value
×
UNCOV
26
      end
×
27

UNCOV
28
      @errors = []
×
UNCOV
29
    end
×
30

UNCOV
31
    def valid?
×
UNCOV
32
      valid = related_identifier.present? && valid_related_identifier_type? && valid_relation_type?
×
UNCOV
33
      return valid if valid
×
UNCOV
34
      if related_identifier.blank?
×
UNCOV
35
        errors << "Related identifier is missing"
×
UNCOV
36
      else
×
UNCOV
37
        errors << "Related Identifier Type is missing or invalid for #{related_identifier}" unless valid_related_identifier_type?
×
UNCOV
38
        errors << "Relationship Type is missing or invalid for #{related_identifier}" unless valid_relation_type?
×
UNCOV
39
      end
×
UNCOV
40
      false
×
UNCOV
41
    end
×
42

UNCOV
43
    def value
×
UNCOV
44
      @related_identifier
×
UNCOV
45
    end
×
46

UNCOV
47
    def compare_value
×
UNCOV
48
      "#{related_identifier} ('#{relation_type}' relation #{related_identifier_type})"
×
UNCOV
49
    end
×
50

UNCOV
51
    def self.new_related_object(related_identifier, related_identifier_type, relation_type)
×
UNCOV
52
      RelatedObject.new(related_identifier:, related_identifier_type:, relation_type:)
×
UNCOV
53
    end
×
54

UNCOV
55
    private
×
56

UNCOV
57
      def valid_related_identifier_type?
×
UNCOV
58
        @valid_related_identifier_type ||= valid_type_values.include?(related_identifier_type)
×
UNCOV
59
      end
×
60

UNCOV
61
      def valid_relation_type?
×
UNCOV
62
        @valid_relation_type ||= valid_relationship_types.include?(relation_type)
×
UNCOV
63
      end
×
64

UNCOV
65
      def valid_type_values
×
UNCOV
66
        @valid_type_values ||= Datacite::Mapping::RelatedIdentifierType.map(&:value)
×
UNCOV
67
      end
×
68

UNCOV
69
      def valid_relationship_types
×
UNCOV
70
        @valid_relationship_types ||= Datacite::Mapping::RelationType.map(&:value)
×
UNCOV
71
      end
×
UNCOV
72
  end
×
UNCOV
73
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