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

pulibrary / bibdata / c5fc01f6-b849-40cf-ba4f-b81ac98e755d

01 May 2025 05:51PM UTC coverage: 90.656% (-1.5%) from 92.189%
c5fc01f6-b849-40cf-ba4f-b81ac98e755d

push

circleci

maxkadel
WIP - not loading correctly

16 of 16 new or added lines in 3 files covered. (100.0%)

59 existing lines in 6 files now uncovered.

3415 of 3767 relevant lines covered (90.66%)

335.44 hits per line

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

90.57
/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
86✔
6
  end
7

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

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

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

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

26
  private
1✔
27

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

88
    def scsb_record?
1✔
UNCOV
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