berkeley_library-tind 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e7d25497211920f8416b44cef0c1571f0655ff92c3e3ff69405ce9659c9df3e
4
- data.tar.gz: 915b8fdc55e4f5d7a48bc7ef3befd2ec4d9e3f3081eedc41980b04dd073fff5c
3
+ metadata.gz: 24232cda73f63d90367c05453c325f468d6103d667e820671f19c251cabd3814
4
+ data.tar.gz: 98d09880d886d8f351f0a038b8513aefe5dfe5c3a72108f634d79f7ad2485506
5
5
  SHA512:
6
- metadata.gz: 187ede68d2a48c906ee37fa01555489e877d1ef4c941189fae5ba683d79a6ca7704e1903077bab6ef9e3e70f8cb1670dee5755aed85a241c538f0e380542879c
7
- data.tar.gz: 361ec4a2b88f4f97e53ad1eb25554b97e7cef94222b828de2f27bfc9037df02e412884adf36b31bbf9aed4671a0f62c0ad0910a94225ae18c4efd1758ccf9b43
6
+ metadata.gz: 15c2560d8bee4b55fbb66a51f101afd731ef02bf542c7e4433ea0b095efa492a9b7429a7bb8929226079bb24a40a9f5e27432c6c855812a0a29d913d6877958e
7
+ data.tar.gz: 6133181a93ef7a1204e6c73ea56a5fdee80f40817bfbe87c3c03ed063ec070e8c6f50dff732bbd987e30b929c14ba6e0b056a0b259f8327273f24e7048a069dc
@@ -1,5 +1,5 @@
1
1
  name: Build
2
- on: [ push, pull_request ]
2
+ on: [ push, pull_request, workflow_dispatch ]
3
3
  jobs:
4
4
  test:
5
5
  strategy:
data/.idea/tind.iml CHANGED
@@ -9,13 +9,13 @@
9
9
  </content>
10
10
  <orderEntry type="jdk" jdkName="RVM: ruby-2.7.5" jdkType="RUBY_SDK" />
11
11
  <orderEntry type="sourceFolder" forTests="false" />
12
- <orderEntry type="library" scope="PROVIDED" name="actionpack (v6.1.4.6, RVM: ruby-2.7.5) [gem]" level="application" />
13
- <orderEntry type="library" scope="PROVIDED" name="actionview (v6.1.4.6, RVM: ruby-2.7.5) [gem]" level="application" />
14
- <orderEntry type="library" scope="PROVIDED" name="activesupport (v6.1.4.6, RVM: ruby-2.7.5) [gem]" level="application" />
12
+ <orderEntry type="library" scope="PROVIDED" name="actionpack (v7.0.2.3, RVM: ruby-2.7.5) [gem]" level="application" />
13
+ <orderEntry type="library" scope="PROVIDED" name="actionview (v7.0.2.3, RVM: ruby-2.7.5) [gem]" level="application" />
14
+ <orderEntry type="library" scope="PROVIDED" name="activesupport (v7.0.2.3, RVM: ruby-2.7.5) [gem]" level="application" />
15
15
  <orderEntry type="library" scope="PROVIDED" name="addressable (v2.8.0, RVM: ruby-2.7.5) [gem]" level="application" />
16
16
  <orderEntry type="library" scope="PROVIDED" name="amazing_print (v1.4.0, RVM: ruby-2.7.5) [gem]" level="application" />
17
17
  <orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, RVM: ruby-2.7.5) [gem]" level="application" />
18
- <orderEntry type="library" scope="PROVIDED" name="berkeley_library-logging (v0.2.5, RVM: ruby-2.7.5) [gem]" level="application" />
18
+ <orderEntry type="library" scope="PROVIDED" name="berkeley_library-logging (v0.2.6, RVM: ruby-2.7.5) [gem]" level="application" />
19
19
  <orderEntry type="library" scope="PROVIDED" name="berkeley_library-marc (v0.3.1, RVM: ruby-2.7.5) [gem]" level="application" />
20
20
  <orderEntry type="library" scope="PROVIDED" name="berkeley_library-util (v0.1.1, RVM: ruby-2.7.5) [gem]" level="application" />
21
21
  <orderEntry type="library" scope="PROVIDED" name="builder (v3.2.4, RVM: ruby-2.7.5) [gem]" level="application" />
@@ -25,7 +25,7 @@
25
25
  <orderEntry type="library" scope="PROVIDED" name="ci_reporter (v2.0.0, RVM: ruby-2.7.5) [gem]" level="application" />
26
26
  <orderEntry type="library" scope="PROVIDED" name="ci_reporter_rspec (v1.0.0, RVM: ruby-2.7.5) [gem]" level="application" />
27
27
  <orderEntry type="library" scope="PROVIDED" name="colorize (v0.8.1, RVM: ruby-2.7.5) [gem]" level="application" />
28
- <orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.1.9, RVM: ruby-2.7.5) [gem]" level="application" />
28
+ <orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.1.10, RVM: ruby-2.7.5) [gem]" level="application" />
29
29
  <orderEntry type="library" scope="PROVIDED" name="crack (v0.4.5, RVM: ruby-2.7.5) [gem]" level="application" />
30
30
  <orderEntry type="library" scope="PROVIDED" name="crass (v1.0.6, RVM: ruby-2.7.5) [gem]" level="application" />
31
31
  <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.5.0, RVM: ruby-2.7.5) [gem]" level="application" />
@@ -40,7 +40,7 @@
40
40
  <orderEntry type="library" scope="PROVIDED" name="i18n (v1.10.0, RVM: ruby-2.7.5) [gem]" level="application" />
41
41
  <orderEntry type="library" scope="PROVIDED" name="ice_nine (v0.11.2, RVM: ruby-2.7.5) [gem]" level="application" />
42
42
  <orderEntry type="library" scope="PROVIDED" name="lograge (v0.11.2, RVM: ruby-2.7.5) [gem]" level="application" />
43
- <orderEntry type="library" scope="PROVIDED" name="loofah (v2.14.0, RVM: ruby-2.7.5) [gem]" level="application" />
43
+ <orderEntry type="library" scope="PROVIDED" name="loofah (v2.15.0, RVM: ruby-2.7.5) [gem]" level="application" />
44
44
  <orderEntry type="library" scope="PROVIDED" name="marc (v1.1.1, RVM: ruby-2.7.5) [gem]" level="application" />
45
45
  <orderEntry type="library" scope="PROVIDED" name="method_source (v1.0.0, RVM: ruby-2.7.5) [gem]" level="application" />
46
46
  <orderEntry type="library" scope="PROVIDED" name="mime-types (v3.4.1, RVM: ruby-2.7.5) [gem]" level="application" />
@@ -59,7 +59,7 @@
59
59
  <orderEntry type="library" scope="PROVIDED" name="rack-test (v1.1.0, RVM: ruby-2.7.5) [gem]" level="application" />
60
60
  <orderEntry type="library" scope="PROVIDED" name="rails-dom-testing (v2.0.3, RVM: ruby-2.7.5) [gem]" level="application" />
61
61
  <orderEntry type="library" scope="PROVIDED" name="rails-html-sanitizer (v1.4.2, RVM: ruby-2.7.5) [gem]" level="application" />
62
- <orderEntry type="library" scope="PROVIDED" name="railties (v6.1.4.6, RVM: ruby-2.7.5) [gem]" level="application" />
62
+ <orderEntry type="library" scope="PROVIDED" name="railties (v7.0.2.3, RVM: ruby-2.7.5) [gem]" level="application" />
63
63
  <orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, RVM: ruby-2.7.5) [gem]" level="application" />
64
64
  <orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, RVM: ruby-2.7.5) [gem]" level="application" />
65
65
  <orderEntry type="library" scope="PROVIDED" name="rchardet (v1.8.0, RVM: ruby-2.7.5) [gem]" level="application" />
@@ -90,7 +90,7 @@
90
90
  <orderEntry type="library" scope="PROVIDED" name="typesafe_enum (v0.3.0, RVM: ruby-2.7.5) [gem]" level="application" />
91
91
  <orderEntry type="library" scope="PROVIDED" name="tzinfo (v2.0.4, RVM: ruby-2.7.5) [gem]" level="application" />
92
92
  <orderEntry type="library" scope="PROVIDED" name="unf (v0.1.4, RVM: ruby-2.7.5) [gem]" level="application" />
93
- <orderEntry type="library" scope="PROVIDED" name="unf_ext (v0.0.8, RVM: ruby-2.7.5) [gem]" level="application" />
93
+ <orderEntry type="library" scope="PROVIDED" name="unf_ext (v0.0.8.1, RVM: ruby-2.7.5) [gem]" level="application" />
94
94
  <orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v2.1.0, RVM: ruby-2.7.5) [gem]" level="application" />
95
95
  <orderEntry type="library" scope="PROVIDED" name="webmock (v3.14.0, RVM: ruby-2.7.5) [gem]" level="application" />
96
96
  <orderEntry type="library" scope="PROVIDED" name="zeitwerk (v2.5.4, RVM: ruby-2.7.5) [gem]" level="application" />
data/CHANGES.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 0.5.1 (2023-03-23)
2
+
3
+ - Fix an issue where `BerkeleyLibrary::TIND::MARC::XMLWriter` would drop fields with nonstandard tags (e.g. `FFT` fields)
4
+ and would group and sort fields by tag instead of preserving the original order.
5
+
1
6
  # 0.5.0 (2022-01-17)
2
7
 
3
8
  - Adds a class `BerkeleyLibrary::TIND::MARC::XMLWriter` to write MARCXML in the format expected by the TIND batch uploader:
@@ -20,8 +20,7 @@ module BerkeleyLibrary
20
20
  Nokogiri::XML::Builder.new do |xml|
21
21
  xml.record do
22
22
  add_leader(xml)
23
- marc_record.each_control_field { |cf| add_control_field(xml, cf) }
24
- marc_record.each_data_field { |df| add_data_field(xml, df) }
23
+ marc_record.each { |f| add_field(xml, f) }
25
24
  end
26
25
  end
27
26
  end
@@ -49,6 +48,15 @@ module BerkeleyLibrary
49
48
  xml.controlfield(value, tag: cf.tag)
50
49
  end
51
50
 
51
+ def add_field(xml, f)
52
+ case f
53
+ when ::MARC::ControlField
54
+ add_control_field(xml, f)
55
+ when ::MARC::DataField
56
+ add_data_field(xml, f)
57
+ end
58
+ end
59
+
52
60
  def clean_leader(leader)
53
61
  leader.gsub(/[^\w|^\s]/, 'Z').tap do |ldr|
54
62
  ldr[20..23] = '4500' unless ldr[20..23] == '4500'
@@ -7,7 +7,7 @@ module BerkeleyLibrary
7
7
  SUMMARY = 'TIND DA utilities for the UC Berkeley Library'.freeze
8
8
  DESCRIPTION = 'UC Berkeley Library utility gem for working with the TIND DA digital archive.'.freeze
9
9
  LICENSE = 'MIT'.freeze
10
- VERSION = '0.5.0'.freeze
10
+ VERSION = '0.5.1'.freeze
11
11
  HOMEPAGE = 'https://github.com/BerkeleyLibrary/tind'.freeze
12
12
  end
13
13
  end
@@ -149,6 +149,44 @@ module BerkeleyLibrary
149
149
  end
150
150
  expect(marc_xml).not_to include('leader')
151
151
  end
152
+
153
+ describe 'issue #4' do
154
+ let(:record_expected) { ::MARC::XMLReader.new('spec/data/issue-4.xml').first }
155
+ let(:record_actual) do
156
+ marc_xml = StringIO.open do |out|
157
+ XMLWriter.open(out) { |w| w.write(record_expected) }
158
+ out.string
159
+ end
160
+
161
+ ::MARC::XMLReader.new(StringIO.new(marc_xml)).first
162
+ end
163
+
164
+ it 'does not reorder fields' do
165
+ expected_tags = record_expected.fields.map(&:tag)
166
+ actual_tags = record_actual.fields.map(&:tag).reject { |t| t == '000' }
167
+
168
+ expect(actual_tags).to eq(expected_tags)
169
+ end
170
+
171
+ it 'supports FFT fields' do
172
+ df_expected = record_expected['FFT']
173
+ expect(df_expected).to be_a(::MARC::DataField) # just to be sure
174
+
175
+ df_actual = record_actual['FFT']
176
+ expect(df_actual).to be_a(::MARC::DataField)
177
+ %i[tag indicator1 indicator2].each do |attr|
178
+ v_actual = df_actual.send(attr)
179
+ v_expected = df_expected.send(attr)
180
+ expect(v_actual).to eq(v_expected)
181
+ end
182
+
183
+ df_expected.subfields.each_with_index do |sf_expected, i|
184
+ sf_actual = df_actual.subfields[i]
185
+ expect(sf_actual.code).to eq(sf_expected.code)
186
+ expect(sf_actual.value).to eq(sf_expected.value)
187
+ end
188
+ end
189
+ end
152
190
  end
153
191
  end
154
192
  end
@@ -0,0 +1,157 @@
1
+ <?xml version="1.0"?>
2
+ <collection xmlns="http://www.loc.gov/MARC21/slim" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd">
3
+ <record>
4
+ <leader> Z 22 4500</leader>
5
+ <datafield tag="245" ind1=" " ind2=" ">
6
+ <subfield code="a">Caricatures of Paul Bunyan</subfield>
7
+ </datafield>
8
+ <datafield tag="260" ind1=" " ind2=" ">
9
+ <subfield code="c">19--.</subfield>
10
+ </datafield>
11
+ <datafield tag="300" ind1=" " ind2=" ">
12
+ <subfield code="b">color</subfield>
13
+ <subfield code="c">10 1/2 x 12 1/2 inches.</subfield>
14
+ <subfield code="a">16 caricatures</subfield>
15
+ </datafield>
16
+ <datafield tag="500" ind1=" " ind2=" ">
17
+ <subfield code="a">Title supplied by cataloger.</subfield>
18
+ </datafield>
19
+ <datafield tag="500" ind1=" " ind2=" ">
20
+ <subfield code="a">Published or produced by the Mead Sales Company. Identified artists include Hutton, S.W. Wilcox, and Henry C. Pitz.</subfield>
21
+ </datafield>
22
+ <datafield tag="650" ind1=" " ind2=" ">
23
+ <subfield code="a">Bunyan, Paul (Legendary character) Pictorial works. </subfield>
24
+ </datafield>
25
+ <datafield tag="655" ind1=" " ind2=" ">
26
+ <subfield code="2">gmgpc</subfield>
27
+ <subfield code="a">Caricatures Color. </subfield>
28
+ </datafield>
29
+ <datafield tag="700" ind1="1" ind2=" ">
30
+ <subfield code="a">Pitz, Henry C. 1895-1976. (Henry Clarence),</subfield>
31
+ </datafield>
32
+ <datafield tag="710" ind1="2" ind2=" ">
33
+ <subfield code="a">Mead Sales Company.</subfield>
34
+ </datafield>
35
+ <datafield tag="903" ind1=" " ind2=" ">
36
+ <subfield code="b">c</subfield>
37
+ </datafield>
38
+ <datafield tag="041" ind1=" " ind2=" ">
39
+ <subfield code="a">eng</subfield>
40
+ </datafield>
41
+ <datafield tag="902" ind1=" " ind2=" ">
42
+ <subfield code="d">2022-03-23</subfield>
43
+ </datafield>
44
+ <datafield tag="336" ind1=" " ind2=" ">
45
+ <subfield code="a">Image</subfield>
46
+ </datafield>
47
+ <datafield tag="852" ind1=" " ind2=" ">
48
+ <subfield code="c">Bioscience, Natural Resources &amp; Public Health Library</subfield>
49
+ </datafield>
50
+ <datafield tag="980" ind1=" " ind2=" ">
51
+ <subfield code="a">Forestry</subfield>
52
+ </datafield>
53
+ <datafield tag="982" ind1=" " ind2=" ">
54
+ <subfield code="a">Forestry</subfield>
55
+ <subfield code="b">Forestry</subfield>
56
+ </datafield>
57
+ <datafield tag="901" ind1=" " ind2=" ">
58
+ <subfield code="m">991065640639706532</subfield>
59
+ </datafield>
60
+ <datafield tag="856" ind1="4" ind2="1">
61
+ <subfield code="u">https://search.library.berkeley.edu/discovery/fulldisplay?context=L&amp;vid=01UCS_BER:UCB&amp;docid=alma991065640639706532</subfield>
62
+ <subfield code="y">View library catalog record.</subfield>
63
+ </datafield>
64
+ <datafield tag="998" ind1=" " ind2=" ">
65
+ <subfield code="a">fake-value</subfield>
66
+ </datafield>
67
+ <datafield tag="035" ind1=" " ind2=" ">
68
+ <subfield code="a">b142086125</subfield>
69
+ </datafield>
70
+ <datafield tag="FFT" ind1=" " ind2=" ">
71
+ <subfield code="d">001</subfield>
72
+ <subfield code="a">https://digitalassets.lib.berkeley.edu/forestry/ucb/images/b142086125_i180839998/b142086125_i180839998_001.jpg</subfield>
73
+ </datafield>
74
+ </record>
75
+ <record>
76
+ <leader> Z 22 4500</leader>
77
+ <datafield tag="245" ind1=" " ind2=" ">
78
+ <subfield code="a">Photographs from the University of California Forestry Club</subfield>
79
+ </datafield>
80
+ <datafield tag="260" ind1=" " ind2=" ">
81
+ <subfield code="c">1930-1939.</subfield>
82
+ </datafield>
83
+ <datafield tag="300" ind1=" " ind2=" ">
84
+ <subfield code="a">1 album (photographic prints)</subfield>
85
+ </datafield>
86
+ <datafield tag="500" ind1=" " ind2=" ">
87
+ <subfield code="a">Title supplied by cataloger.</subfield>
88
+ </datafield>
89
+ <datafield tag="500" ind1=" " ind2=" ">
90
+ <subfield code="a">Photographed and or compiled by the Forestry Club.</subfield>
91
+ </datafield>
92
+ <datafield tag="520" ind1=" " ind2=" ">
93
+ <subfield code="a">Album contains views of the University of California campus, Camp Califorest, and of the camp newspaper (Bull of the Woods).</subfield>
94
+ </datafield>
95
+ <datafield tag="610" ind1=" " ind2=" ">
96
+ <subfield code="a">University of California (1868-1952) Forestry Club Pictorial works. </subfield>
97
+ </datafield>
98
+ <datafield tag="610" ind1=" " ind2=" ">
99
+ <subfield code="a">University of California (1868-1952) Camp Califorest Pictorial works. </subfield>
100
+ </datafield>
101
+ <datafield tag="610" ind1=" " ind2=" ">
102
+ <subfield code="a">University of California (1868-1952) Pictorial works. </subfield>
103
+ </datafield>
104
+ <datafield tag="655" ind1=" " ind2=" ">
105
+ <subfield code="2">gmgpc</subfield>
106
+ <subfield code="a">Photographs.</subfield>
107
+ </datafield>
108
+ <datafield tag="710" ind1="2" ind2=" ">
109
+ <subfield code="a">University of California, Berkeley. Forestry students.</subfield>
110
+ </datafield>
111
+ <datafield tag="710" ind1="2" ind2=" ">
112
+ <subfield code="a">University of California (1868-1952) Forestry Club.</subfield>
113
+ </datafield>
114
+ <datafield tag="903" ind1=" " ind2=" ">
115
+ <subfield code="b">c</subfield>
116
+ </datafield>
117
+ <datafield tag="041" ind1=" " ind2=" ">
118
+ <subfield code="a">eng</subfield>
119
+ </datafield>
120
+ <datafield tag="269" ind1=" " ind2=" ">
121
+ <subfield code="a">1930</subfield>
122
+ </datafield>
123
+ <datafield tag="902" ind1=" " ind2=" ">
124
+ <subfield code="d">2022-03-23</subfield>
125
+ </datafield>
126
+ <datafield tag="336" ind1=" " ind2=" ">
127
+ <subfield code="a">Image</subfield>
128
+ </datafield>
129
+ <datafield tag="852" ind1=" " ind2=" ">
130
+ <subfield code="c">Bioscience, Natural Resources &amp; Public Health Library</subfield>
131
+ </datafield>
132
+ <datafield tag="980" ind1=" " ind2=" ">
133
+ <subfield code="a">Forestry</subfield>
134
+ </datafield>
135
+ <datafield tag="982" ind1=" " ind2=" ">
136
+ <subfield code="a">Forestry</subfield>
137
+ <subfield code="b">Forestry</subfield>
138
+ </datafield>
139
+ <datafield tag="901" ind1=" " ind2=" ">
140
+ <subfield code="m">991065707389706532</subfield>
141
+ </datafield>
142
+ <datafield tag="856" ind1="4" ind2="1">
143
+ <subfield code="u">https://search.library.berkeley.edu/discovery/fulldisplay?context=L&amp;vid=01UCS_BER:UCB&amp;docid=alma991065707389706532</subfield>
144
+ <subfield code="y">View library catalog record.</subfield>
145
+ </datafield>
146
+ <datafield tag="998" ind1=" " ind2=" ">
147
+ <subfield code="a">fake-value</subfield>
148
+ </datafield>
149
+ <datafield tag="035" ind1=" " ind2=" ">
150
+ <subfield code="a">b142107827</subfield>
151
+ </datafield>
152
+ <datafield tag="FFT" ind1=" " ind2=" ">
153
+ <subfield code="d">002</subfield>
154
+ <subfield code="a">https://digitalassets.lib.berkeley.edu/forestry/ucb/images/b142086125_i180839998/b142086125_i180839998_002.jpg</subfield>
155
+ </datafield>
156
+ </record>
157
+ </collection>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: berkeley_library-tind
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Moles
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-17 00:00:00.000000000 Z
11
+ date: 2022-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: berkeley_library-logging
@@ -490,6 +490,7 @@ files:
490
490
  - spec/data/collection-names.txt
491
491
  - spec/data/collections.json
492
492
  - spec/data/disjoint-records.xml
493
+ - spec/data/issue-4.xml
493
494
  - spec/data/new-records.xml
494
495
  - spec/data/record-184453.xml
495
496
  - spec/data/record-184458.xml
@@ -563,6 +564,7 @@ test_files:
563
564
  - spec/data/collection-names.txt
564
565
  - spec/data/collections.json
565
566
  - spec/data/disjoint-records.xml
567
+ - spec/data/issue-4.xml
566
568
  - spec/data/new-records.xml
567
569
  - spec/data/record-184453.xml
568
570
  - spec/data/record-184458.xml