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

pulibrary / bibdata / 2b274cd3-5d04-438b-ba47-a8d5eeac0c16

11 Aug 2025 04:31PM UTC coverage: 87.857% (-4.3%) from 92.158%
2b274cd3-5d04-438b-ba47-a8d5eeac0c16

Pull #2830

circleci

sandbergja
[#2746] Begin indexing access restriction notes

Advances #2746
Pull Request #2830: [#2746] Begin indexing access restriction notes

3350 of 3813 relevant lines covered (87.86%)

668.76 hits per line

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

41.51
/marc_to_solr/lib/action_note_builder.rb
1
class ActionNoteBuilder
1✔
2
  attr_reader :record
1✔
3

4
  def initialize(record:)
1✔
5
    @record = record
39✔
6
  end
7

8
  def self.build(record:)
1✔
9
    new(record:).build
39✔
10
  end
11

12
  def build
1✔
13
    notes = []
39✔
14

15
    @record.fields('583').each do |field|
39✔
16
      public_note = field.indicator1 == '1'
×
17
      field_link = field['8']
×
18
      next unless public_note && (field_link.present? || pulfa_record? || scsb_record?)
×
19

20
      notes << { description: description(field), uri: uri(field) }
×
21
    end
22
    notes = [notes.to_json.to_s] if notes.present?
39✔
23
    notes.presence
39✔
24
  end
25

26
  private
1✔
27

28
    def description(field)
1✔
29
      description = ''
×
30
      description << materials_specified(field)
×
31
      description << action(field)
×
32
      description << action_interval(field)
×
33
      description << authorization_phrase(field)
×
34
      description << institution(field)
×
35
    end
36

37
    def uri(field)
1✔
38
      return '' if field['u'].blank?
×
39

40
      field['u'].strip
×
41
    end
42

43
    def action(field)
1✔
44
      return '' if field['a'].blank?
×
45

46
      field['a']&.upcase_first
×
47
    end
48

49
    def action_interval(field)
1✔
50
      return '' if field['d'].blank?
×
51

52
      " #{field['d']}"
×
53
    end
54

55
    def authorization_phrase(field)
1✔
56
      return '' if field['f'].blank?
×
57

58
      auth_array = authorization_array(field)
×
59
      auth_phrase = ''
×
60
      first_auth = auth_array.shift
×
61
      auth_phrase << " — #{first_auth}"
×
62
      auth_array.each do |auth|
×
63
        auth_phrase << " #{auth}"
×
64
      end
65
      auth_phrase
×
66
    end
67

68
    def authorization_array(field)
1✔
69
      field.subfields.select { |s_field| s_field.code == 'f' }.map(&:value)
×
70
    end
71

72
    def institution(field)
1✔
73
      return '' if field['5'].blank?
×
74

75
      " (#{field['5']})"
×
76
    end
77

78
    def materials_specified(field)
1✔
79
      return '' if field['3'].blank?
×
80

81
      "#{field['3']}: "
×
82
    end
83

84
    def pulfa_record?
1✔
85
      @pulfa_record ||= @record.fields('035').select { |f| f['a']&.downcase =~ /pulfa/ }.present?
×
86
    end
87

88
    def scsb_record?
1✔
89
      @scsb_record ||= scsb_doc?(@record['001']&.value)
×
90
    end
91
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