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

pulibrary / bibdata / 1dcebae2-3318-4e77-bc53-82276e293354

02 May 2025 04:45PM UTC coverage: 28.256% (-63.9%) from 92.189%
1dcebae2-3318-4e77-bc53-82276e293354

push

circleci

sandbergja
Add basic infrastructure for compiling rust code

* Add a rake compile task to compile
* Run the rake task in CI
* Run the rake task before rspec tests with the rust tag, to provide quick feedback on rust changes in TDD cycles

2 of 7 new or added lines in 2 files covered. (28.57%)

2467 existing lines in 97 files now uncovered.

1089 of 3854 relevant lines covered (28.26%)

0.29 hits per line

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

38.81
/marc_to_solr/lib/format/bib_format.rb
1
# given a record, find the bib_format code
2
require_relative '../format'
1✔
3

4
# This class is responsible for assigning one or more 2-letter
5
# codes that represent the format of a title.  The 2-letter
6
# codes can be found in the Format translation map.
7
class BibFormat
1✔
8
  attr_reader :code
1✔
9

10
  # Determine the bib format code
11
  #
12
  # @param [MARC::Record] record The record to test
13

14
  def initialize(record)
1✔
UNCOV
15
    @record = record
×
UNCOV
16
    @code = []
×
UNCOV
17
    @code << self.determine_bib_code
×
UNCOV
18
    @code << 'WM' if microform?
×
UNCOV
19
    @code = @code.flatten
×
20
  end
21

22
  def determine_bib_code
1✔
UNCOV
23
    format = []
×
UNCOV
24
    format << 'AJ' if bibformat_jn # journal
×
UNCOV
25
    format << 'CF' if bibformat_cf # data file
×
UNCOV
26
    format << 'VM' if bibformat_vm # visual material
×
UNCOV
27
    format << 'VP' if bibformat_vp # video
×
UNCOV
28
    format << 'MS' if bibformat_mu # musical score
×
UNCOV
29
    format << 'AU' if bibformat_au # audio
×
UNCOV
30
    format << 'MP' if bibformat_mp # map
×
UNCOV
31
    format << 'MW' if bibformat_mw # manuscript
×
UNCOV
32
    format << 'BK' if bibformat_bk # book
×
UNCOV
33
    format << 'DB' if bibformat_db # databases
×
UNCOV
34
    format << 'XA' if bibformat_xa # archival item
×
UNCOV
35
    format
×
36
  end
37

38
  def bibformat_bk
1✔
UNCOV
39
    ((type == 't') && !check_pulfa) || ((type == 'a') && %w[a b c d m].include?(lev))
×
40
  end
41

42
  def bibformat_db
1✔
UNCOV
43
    (type == 'a') && (lev == 'i')
×
44
  end
45

46
  def bibformat_jn
1✔
UNCOV
47
    (type == 'a') && (lev == 's')
×
48
  end
49

50
  def bibformat_cf
1✔
UNCOV
51
    (type == 'm')
×
52
  end
53

54
  def bibformat_au
1✔
UNCOV
55
    %w[i j].include?(type)
×
56
  end
57

58
  def bibformat_vm
1✔
UNCOV
59
    %w[k o r].include?(type)
×
60
  end
61

62
  def bibformat_vp
1✔
UNCOV
63
    (type == 'g')
×
64
  end
65

66
  def bibformat_mu
1✔
UNCOV
67
    %w[c d].include?(type)
×
68
  end
69

70
  def bibformat_mp
1✔
UNCOV
71
    %w[e f].include?(type)
×
72
  end
73

74
  def bibformat_mw
1✔
UNCOV
75
    %w[d f p t].include?(type)
×
76
  end
77

78
  def bibformat_xa
1✔
UNCOV
79
    (type == 't') && (lev == 'm') && check_pulfa && archival?
×
80
  end
81

82
  private
1✔
83

84
    attr_reader :record
1✔
85

86
    def microform?
1✔
UNCOV
87
      record.fields('007').any? { |field| field.value&.start_with? 'h' }
×
88
    end
89

90
    def ldr
1✔
UNCOV
91
      @ldr ||= record.leader
×
92
    end
93

94
    def type
1✔
UNCOV
95
      @type ||= ldr[6]
×
96
    end
97

98
    def lev
1✔
UNCOV
99
      @lev ||= ldr[7]
×
100
    end
101

102
    def check_pulfa
1✔
UNCOV
103
      @check_pulfa ||= record['035'] && record['035']['a'] && record['035']['a'].start_with?('(PULFA)')
×
104
    end
105

106
    def archival?
1✔
UNCOV
107
      @archival ||= begin
×
UNCOV
108
        cataloging_sources = record.fields('040')
×
UNCOV
109
        return true if cataloging_sources.empty?
×
110

UNCOV
111
        cataloging_sources.any? { |field| field_uses_archival_standard?(field) }
×
112
      end
113
    end
114

115
    def field_uses_archival_standard?(field)
1✔
UNCOV
116
      field.subfields.any? { |subfield| subfield.code == 'e' && archival_standard?(subfield.value) } ||
×
UNCOV
117
        field.subfields.none? { |subfield| subfield.code == 'e' && !archival_standard?(subfield.value) }
×
118
    end
119

120
    def archival_standard?(code)
1✔
UNCOV
121
      %w[dacs appm].include? code
×
122
    end
123
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