berkeley_library-tind 0.6.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.idea/tind.iml +42 -42
- data/.rubocop.yml +1 -1
- data/CHANGES.md +10 -2
- data/LICENSE.md +1 -1
- data/README.md +50 -6
- data/berkeley_library-tind.gemspec +2 -3
- data/lib/berkeley_library/tind/export/ods_exporter.rb +4 -6
- data/lib/berkeley_library/tind/mapping/alma_base.rb +7 -0
- data/lib/berkeley_library/tind/mapping/data/one_to_one_mapping.csv +39 -39
- data/lib/berkeley_library/tind/mapping/field_catalog.rb +2 -11
- data/lib/berkeley_library/tind/mapping/field_catalog_util.rb +49 -3
- data/lib/berkeley_library/tind/mapping/single_rule.rb +6 -0
- data/lib/berkeley_library/tind/mapping/tind_field_from_single_map.rb +13 -1
- data/lib/berkeley_library/tind/mapping/tind_record_util.rb +135 -0
- data/lib/berkeley_library/tind/mapping/util.rb +19 -0
- data/lib/berkeley_library/tind/module_info.rb +1 -1
- data/lib/berkeley_library/util/ods/spreadsheet.rb +3 -0
- data/spec/berkeley_library/tind/mapping/alma_multiple_tind_spec.rb +1 -1
- data/spec/berkeley_library/tind/mapping/alma_single_tind_spec.rb +1 -1
- data/spec/berkeley_library/tind/mapping/field_catalog_util_spec.rb +48 -0
- data/spec/berkeley_library/tind/mapping/match_tind_field_spec.rb +1 -2
- data/spec/berkeley_library/tind/mapping/tind_field_from_single_map_spec.rb +17 -0
- data/spec/berkeley_library/tind/mapping/tind_record_util_spec.rb +30 -0
- data/spec/data/api/pre_assigned_response.json +15 -0
- data/spec/data/api/result_file.csv +3 -0
- data/spec/data/api/upload_file.json +1 -0
- data/spec/data/api/upload_response.json +13 -0
- data/spec/data/mapping/record.xml +6 -3
- metadata +21 -83
- data/lib/berkeley_library/util/files.rb +0 -38
@@ -0,0 +1,135 @@
|
|
1
|
+
require 'marc'
|
2
|
+
|
3
|
+
module BerkeleyLibrary
|
4
|
+
module TIND
|
5
|
+
module Mapping
|
6
|
+
module TindRecordUtil
|
7
|
+
|
8
|
+
class << self
|
9
|
+
include TindRecordUtil
|
10
|
+
end
|
11
|
+
|
12
|
+
# 1) tag_subfield_hash: a hash to add a new, or update an existing subfield to a field in a TIND Marc record
|
13
|
+
# If a subfield existed, it will replace the subfield, otherwise, add a new subfield
|
14
|
+
# when 'a' => nil, it will skip add/update to subfield,
|
15
|
+
# It can be useed in a case: only need to add/update subfields of specific records in a collection
|
16
|
+
# This is an example: tag_subfield_hash = { '245' => { 'b' => 'subtitle', 'a' => 'title' }, '336' => { 'a' => nil } }
|
17
|
+
# 2) fields_removal_list: an array including fields' informat: tag, indicators - "[tag, inicator1, indicator2]".
|
18
|
+
# This list is to remove fields in a record.
|
19
|
+
# An example fields_removal_list = [%w[856 4 1], %w[041 _ _]].
|
20
|
+
# '_' means an empty indicator ''
|
21
|
+
# 3) How to use it:
|
22
|
+
# a. add/update subfields of existed fields in record: TindRecordUtil.update_record(record, tag_subfield_hash)
|
23
|
+
# b. remove a list of fields in the record: TindRecordUtil.update_record(record, nil, fields_removal_list)
|
24
|
+
# c. both a. and b. : TindRecordUtil.update_record(record, tag_subfield_hash, fields_removal_list)
|
25
|
+
def update_record(record, tag_subfield_hash, fields_removal_list = nil)
|
26
|
+
return record unless valid_hash?(tag_subfield_hash) || valid_hash?(fields_removal_list)
|
27
|
+
|
28
|
+
fields = record.fields
|
29
|
+
final_fields = tag_subfield_hash ? subfields_to_existed_fields(fields, tag_subfield_hash) : fields
|
30
|
+
remove_fields(final_fields, fields_removal_list) if fields_removal_list
|
31
|
+
new_record(final_fields)
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def subfields_to_existed_fields(fields, tag_subfield_hash)
|
37
|
+
updated_fields = []
|
38
|
+
tags = tag_subfield_hash.keys
|
39
|
+
fields.each do |field|
|
40
|
+
tag = field.tag
|
41
|
+
need_change_subfield = tags.include? tag
|
42
|
+
updated_fields << (need_change_subfield ? field_changed_subfields(field, tag_subfield_hash[tag]) : field)
|
43
|
+
end
|
44
|
+
fields
|
45
|
+
end
|
46
|
+
|
47
|
+
# example: fields_removal_list = [%w[856 4 1]]
|
48
|
+
def remove_fields(fields, fields_removal_list)
|
49
|
+
fields.reject! { |f| field_in_removal_list?(f, fields_removal_list) }
|
50
|
+
end
|
51
|
+
|
52
|
+
def new_record(fields)
|
53
|
+
record = ::MARC::Record.new
|
54
|
+
fields.each { |f| record.append(f) }
|
55
|
+
record
|
56
|
+
end
|
57
|
+
|
58
|
+
# subfield_hash example { 'b' => 'subtitle', 'a' => 'title' }
|
59
|
+
def field_changed_subfields(field, subfield_hash)
|
60
|
+
tag = field.tag
|
61
|
+
indicators = [field.indicator1, field.indicator2]
|
62
|
+
subfields = changed_subfields(field, subfield_hash)
|
63
|
+
new_datafield(tag, indicators, subfields)
|
64
|
+
end
|
65
|
+
|
66
|
+
# example subfield_hash = { 'p' => 'subtitle'}
|
67
|
+
def changed_subfields(field, subfield_hash)
|
68
|
+
subfields = field.subfields
|
69
|
+
codes = subfields.map(&:code)
|
70
|
+
warning_duplicated_subfield_code(codes)
|
71
|
+
|
72
|
+
keys = subfield_hash.keys
|
73
|
+
|
74
|
+
keys_no_related_codes = keys - codes
|
75
|
+
keys_with_related_codes = keys - keys_no_related_codes
|
76
|
+
|
77
|
+
updated_subfields(subfields, keys_with_related_codes, subfield_hash)
|
78
|
+
|
79
|
+
subfields.concat new_subfields(field, keys_no_related_codes, subfield_hash)
|
80
|
+
subfields
|
81
|
+
end
|
82
|
+
|
83
|
+
# example subfield_hash = { 'p' => 'subtitle'}
|
84
|
+
def updated_subfields(subfields, existed_codes, subfield_hash)
|
85
|
+
subfields.each do |subfield|
|
86
|
+
code = subfield.code
|
87
|
+
next unless existed_codes.include? code
|
88
|
+
|
89
|
+
val = subfield_hash[code]
|
90
|
+
next unless val
|
91
|
+
|
92
|
+
subfield.value = val
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def new_subfields(_field, new_codes, subfield_hash)
|
97
|
+
subfields = []
|
98
|
+
subfield_hash.each do |key, val|
|
99
|
+
next unless val
|
100
|
+
|
101
|
+
subfields << ::MARC::Subfield.new(key, val) if new_codes.include? key
|
102
|
+
end
|
103
|
+
subfields
|
104
|
+
end
|
105
|
+
|
106
|
+
def field_in_removal_list?(f, fields_removal_list)
|
107
|
+
ls = [f.tag, clr(f.indicator1), clr(f.indicator2)]
|
108
|
+
fields_removal_list.include? ls
|
109
|
+
end
|
110
|
+
|
111
|
+
def clr(str)
|
112
|
+
str.strip.empty? ? '_' : str.strip
|
113
|
+
end
|
114
|
+
|
115
|
+
def new_datafield(tag, indicator, subfields)
|
116
|
+
datafield = ::MARC::DataField.new(tag, indicator[0], indicator[1])
|
117
|
+
subfields.each { |sf| datafield.append(sf) }
|
118
|
+
datafield
|
119
|
+
end
|
120
|
+
|
121
|
+
# suppose there are no duplicated subfield codes in a field
|
122
|
+
# giving warning for investigation if finding any dublicated subfields in a field
|
123
|
+
def warning_duplicated_subfield_code(codes)
|
124
|
+
duplicated_codes = codes.select { |code| codes.count(code) > 1 }.uniq
|
125
|
+
puts "Warning: duplicated subfields #{duplicated_codes.join(' ; ')}" unless duplicated_codes.empty?
|
126
|
+
end
|
127
|
+
|
128
|
+
def valid_hash?(hash)
|
129
|
+
hash && !hash.empty?
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
@@ -1,10 +1,12 @@
|
|
1
1
|
require 'csv'
|
2
2
|
require 'marc'
|
3
|
+
require 'berkeley_library/tind/mapping/alma_base'
|
3
4
|
|
4
5
|
module BerkeleyLibrary
|
5
6
|
module TIND
|
6
7
|
module Mapping
|
7
8
|
module Util
|
9
|
+
include AlmaBase
|
8
10
|
|
9
11
|
class << self
|
10
12
|
|
@@ -78,6 +80,23 @@ module BerkeleyLibrary
|
|
78
80
|
all_from_xml(xml).first
|
79
81
|
end
|
80
82
|
|
83
|
+
def collection_config_correct?
|
84
|
+
no_including = BerkeleyLibrary::TIND::Mapping::AlmaBase.including_origin_tags.empty?
|
85
|
+
no_excluding = BerkeleyLibrary::TIND::Mapping::AlmaBase.excluding_origin_tags.empty?
|
86
|
+
no_including || no_excluding
|
87
|
+
end
|
88
|
+
|
89
|
+
# subfield util
|
90
|
+
def order_subfields(subfields, codes)
|
91
|
+
found_subfields = []
|
92
|
+
codes.each do |code|
|
93
|
+
sfs = subfields.select { |subfield| subfield.code == code }
|
94
|
+
found_subfields.concat sfs
|
95
|
+
end
|
96
|
+
not_found_subfields = subfields - found_subfields
|
97
|
+
found_subfields.concat not_found_subfields
|
98
|
+
end
|
99
|
+
|
81
100
|
private
|
82
101
|
|
83
102
|
def clr_row(row)
|
@@ -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.
|
10
|
+
VERSION = '0.7.1'.freeze
|
11
11
|
HOMEPAGE = 'https://github.com/BerkeleyLibrary/tind'.freeze
|
12
12
|
end
|
13
13
|
end
|
@@ -144,6 +144,9 @@ module BerkeleyLibrary
|
|
144
144
|
|
145
145
|
def write_zipfile(out)
|
146
146
|
io = Zip::OutputStream.write_buffer(out) do |zip|
|
147
|
+
# Workaround for https://github.com/sparklemotion/nokogiri/issues/2773
|
148
|
+
class << zip; def external_encoding; end; end
|
149
|
+
|
147
150
|
each_document { |doc| write_zip_entry(doc, zip) }
|
148
151
|
end
|
149
152
|
# NOTE: Zip::OutputStream plays games with the stream and
|
@@ -5,7 +5,7 @@ module BerkeleyLibrary
|
|
5
5
|
module Mapping
|
6
6
|
describe AlmaMultipleTIND do
|
7
7
|
let(:additona_245_field) { [Util.datafield('245', [' ', ' '], [Util.subfield('a', 'fake 245 a')])] }
|
8
|
-
let(:marc_obj) {
|
8
|
+
let(:marc_obj) { ::MARC::Record.new.append(additona_245_field) }
|
9
9
|
|
10
10
|
it ' get tind record' do
|
11
11
|
allow_any_instance_of(BerkeleyLibrary::TIND::Mapping::AlmaMultipleTIND).to receive(:alma_record_from).with('991085821143406532').and_return(marc_obj)
|
@@ -5,7 +5,7 @@ module BerkeleyLibrary
|
|
5
5
|
module Mapping
|
6
6
|
describe AlmaSingleTIND do
|
7
7
|
let(:additona_245_field) { [Util.datafield('245', [' ', ' '], [Util.subfield('a', 'fake 245 a')])] }
|
8
|
-
let(:marc_obj) {
|
8
|
+
let(:marc_obj) { ::MARC::Record.new.append(additona_245_field) }
|
9
9
|
|
10
10
|
before { BerkeleyLibrary::Alma::Config.default! }
|
11
11
|
after { BerkeleyLibrary::Alma::Config.send(:clear!) }
|
@@ -31,6 +31,11 @@ module BerkeleyLibrary
|
|
31
31
|
let(:pre_tag) { ['264', '264'] }
|
32
32
|
let(:pre_tag_subfield) { ['507'] }
|
33
33
|
|
34
|
+
after do
|
35
|
+
BerkeleyLibrary::TIND::Mapping::AlmaBase.including_origin_tags = []
|
36
|
+
BerkeleyLibrary::TIND::Mapping::AlmaBase.excluding_origin_tags = []
|
37
|
+
end
|
38
|
+
|
34
39
|
it 'excluding fast subject field' do
|
35
40
|
fields = qualified_alm_record.fields.select { |f| ['650', '245'].include? f.tag }
|
36
41
|
expect(fields.length).to eq 3
|
@@ -51,6 +56,49 @@ module BerkeleyLibrary
|
|
51
56
|
expect(group[:pre_tag_subfield].map(&:tag)).to eq pre_tag_subfield
|
52
57
|
end
|
53
58
|
|
59
|
+
context 'Defining list of fields mapping from Alma to TIND' do
|
60
|
+
it 'no including, excluding defined from config, return all Alma fields for mapping' do
|
61
|
+
selected_field_tags = %w[255 507 245 246 260 300]
|
62
|
+
fields = qualified_alm_record.fields.select { |f| selected_field_tags.include? f.tag }
|
63
|
+
expect(fields_to_map(fields).map(&:tag)).to eq %w[255 507 245 246 260 300 300]
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'both including and excluding have tags, return empty: not allow to define both including and excluding at the same time' do
|
67
|
+
BerkeleyLibrary::TIND::Mapping::AlmaBase.including_origin_tags = %w[254 650]
|
68
|
+
BerkeleyLibrary::TIND::Mapping::AlmaBase.excluding_origin_tags = %w[507 255 650 880]
|
69
|
+
|
70
|
+
selected_field_tags = %w[255 507 245 246 260 300]
|
71
|
+
fields = qualified_alm_record.fields.select { |f| selected_field_tags.include? f.tag }
|
72
|
+
expect(fields_to_map(fields).map(&:tag)).to eq []
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'only including is defined: keeping fields defined in BerkeleyLibrary::TIND::Mapping::AlmaBase.including_origin_tags' do
|
76
|
+
selected_field_tags = regular_field_tags
|
77
|
+
selected_field_tags << '880'
|
78
|
+
selected_field_tags << '001'
|
79
|
+
fields = qualified_alm_record.fields.select { |f| selected_field_tags.include? f.tag }
|
80
|
+
BerkeleyLibrary::TIND::Mapping::AlmaBase.including_origin_tags = %w[255 650]
|
81
|
+
expect(fields_to_map(fields).map(&:tag)).to eq %w[001 255 650 650 880] # return: Two 650 fields, one 880 field with subfield6 = '650'
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'only excluding origin tags are defined ' do
|
85
|
+
it 'excluding has 880, all 880 fields will be excluded.' do
|
86
|
+
selected_field_tags = %w[001 880 245 507 255 650 630 700 264]
|
87
|
+
fields = qualified_alm_record.fields.select { |f| selected_field_tags.include? f.tag }
|
88
|
+
BerkeleyLibrary::TIND::Mapping::AlmaBase.excluding_origin_tags = %w[507 255 650 880]
|
89
|
+
final_field_tags = %w[001 245 630 700 264 264] # no 880 fields kept
|
90
|
+
expect(fields_to_map(fields).map(&:tag)).to eq final_field_tags
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'excluding has no 880, only 880 whose refered tag located in excluding list will be skipped ' do
|
94
|
+
selected_field_tags = %w[001 880 245 507 255 650 630 700 264]
|
95
|
+
fields = qualified_alm_record.fields.select { |f| selected_field_tags.include? f.tag }
|
96
|
+
BerkeleyLibrary::TIND::Mapping::AlmaBase.excluding_origin_tags = %w[507 255 650]
|
97
|
+
final_field_tags = %w[001 245 880 880 880 880 630 880 700 880 880 880 880 880 880 880 264 264]
|
98
|
+
expect(fields_to_map(fields).map(&:tag)).to eq final_field_tags
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
54
102
|
end
|
55
103
|
end
|
56
104
|
end
|
@@ -12,10 +12,9 @@ module BerkeleyLibrary
|
|
12
12
|
let(:tind_marc) { TindMarc.new(qualified_alm_record) }
|
13
13
|
|
14
14
|
let(:data_fields) { tind_marc.field_catalog.data_fields_880_group[:normal].concat tind_marc.field_catalog.data_fields_group[:normal] }
|
15
|
-
let(:no_880_matching_count) {
|
15
|
+
let(:no_880_matching_count) { 5 }
|
16
16
|
|
17
17
|
it 'get 880 un-matched fields' do
|
18
|
-
# puts tind_marc.send(:un_matched_fields_880, data_fields, '991032577079706532').inspect
|
19
18
|
expect(tind_marc.send(:un_matched_fields_880, data_fields, '991032577079706532').length).to eq no_880_matching_count
|
20
19
|
end
|
21
20
|
|
@@ -143,6 +143,23 @@ module BerkeleyLibrary
|
|
143
143
|
end
|
144
144
|
end
|
145
145
|
|
146
|
+
describe '9.1 - 710: subfields ordered on mapping file order' do
|
147
|
+
let(:tindfield_from_single_map) { TindFieldFromSingleMap.new(qualified_alma_obj.field('710'), false) }
|
148
|
+
it 'get subfield code ordered' do
|
149
|
+
codes = tindfield_from_single_map.to_datafield.subfields.map(&:code)
|
150
|
+
expect(codes).to eq %w[6 a e]
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
describe '9.2 subfield order - 255: subfields ordered on original subfields' do
|
155
|
+
let(:tindfield_from_single_map) { TindFieldFromSingleMap.new(qualified_alma_obj.field('255'), false) }
|
156
|
+
|
157
|
+
it 'get subfield code ordered' do
|
158
|
+
codes = tindfield_from_single_map.to_datafield.subfields.map(&:code)
|
159
|
+
expect(codes).to eq %w[a c b 6]
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
146
163
|
end
|
147
164
|
|
148
165
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'marc'
|
3
|
+
|
4
|
+
module BerkeleyLibrary
|
5
|
+
module TIND
|
6
|
+
module Mapping
|
7
|
+
describe TindRecordUtil do
|
8
|
+
let(:qualified_alma_obj) { Alma.new('spec/data/mapping/record.xml') }
|
9
|
+
let(:qualified_alm_record) { qualified_alma_obj.record }
|
10
|
+
let(:tind_marc) { TindMarc.new(qualified_alm_record).tind_record }
|
11
|
+
|
12
|
+
it 'Remove fields from record' do
|
13
|
+
fields_removal_list = [%w[245 _ _], %w[700 1 _], %w[880 _ _]] # '_' means empty indicator
|
14
|
+
results = %w[255 246 260 300 300 490 630 650 710 903 041 269 255 880 880 880] # some 880's inicator is not empty
|
15
|
+
new_record = TindRecordUtil.update_record(tind_marc, nil, fields_removal_list)
|
16
|
+
expect(new_record.fields.map(&:tag)).to eq results
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'add/update sufields from record' do
|
20
|
+
tag_subfield_dic = { '245' => { 'b' => 'subtitle', 'a' => 'title', 'd' => 'fake' }, '255' => { 'a' => nil } }
|
21
|
+
new_record = TindRecordUtil.update_record(tind_marc, tag_subfield_dic, nil)
|
22
|
+
expect(new_record['245']['a']).to eq 'title'
|
23
|
+
expect(new_record['245']['b']).to eq 'subtitle'
|
24
|
+
expect(new_record['245']['d']).to eq 'fake'
|
25
|
+
expect(new_record['255']['a']).to eq 'fake_255_a'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
{
|
2
|
+
"data": {
|
3
|
+
"url": "https://test_bucket.s3.amazonaws.com/",
|
4
|
+
"fields": {
|
5
|
+
"x-amz-algorithm": "AWS4-HMAC-SHA256",
|
6
|
+
"key": "711aca11-0de1-4110-ac73-8989",
|
7
|
+
"acl": "private",
|
8
|
+
"x-amz-signature": "ac8a1f0ed10e24a694fcaf266beca03687a20b46",
|
9
|
+
"x-amz-date": "20220729T204134Z",
|
10
|
+
"policy": "eyJjb25kaXRpbbs5r69kIjogInByaXZhdGUir5y1w9XQiOiAidGluZC10ZXN0YnVja2V0LWJl",
|
11
|
+
"x-amz-credential": "AKIA5NL2DYQQ3DIWY6Pe960bes66"
|
12
|
+
}
|
13
|
+
},
|
14
|
+
"bucket": "testbucket"
|
15
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
{
|
3
|
+
"code": 204,
|
4
|
+
"headers": {
|
5
|
+
"x_amz_id_2": "R8141+vOxVvEY7i8RuRTlLJE9DePeQ0hpZv0NYvSIvcO/e8OhrnO+Z3Yw=",
|
6
|
+
"x_amz_request_id": "H2EDK70DW0Y2D",
|
7
|
+
"date": "Fri, 29 Jul 2022 22:22:08 GMT",
|
8
|
+
"etag": "\"99914b932bd37a50b983c5e7c90ae93b\"",
|
9
|
+
"location": "https://testbucket.s3.amazonaws.com/b59a3d00-950e-45d2-af1c-746b8fde5977",
|
10
|
+
"server": "AmazonS3"
|
11
|
+
},
|
12
|
+
"body":""
|
13
|
+
}
|
@@ -50,6 +50,9 @@
|
|
50
50
|
</datafield> -->
|
51
51
|
<datafield ind1=" " ind2=" " tag="255">
|
52
52
|
<subfield code="a">fake_255_a</subfield>
|
53
|
+
<subfield code="c">fake_255_c</subfield>
|
54
|
+
<subfield code="b">fake_255_b</subfield>
|
55
|
+
<subfield code="6">fake_255_6</subfield>
|
53
56
|
</datafield>
|
54
57
|
|
55
58
|
<datafield ind1=" " ind2=" " tag="507">
|
@@ -165,14 +168,14 @@
|
|
165
168
|
<subfield code="e">xue.</subfield>
|
166
169
|
<subfield code="a">Sun, Xingyan,</subfield>
|
167
170
|
<subfield code="d">1753-1818,</subfield>
|
168
|
-
|
171
|
+
|
169
172
|
</datafield>
|
170
173
|
<datafield ind1="1" ind2=" " tag="880">
|
171
174
|
<subfield code="6">700-06/$1</subfield>
|
172
175
|
<subfield code="e">學.</subfield>
|
173
176
|
<subfield code="a">孫星衍,</subfield>
|
174
177
|
<subfield code="d">1753-1818,</subfield>
|
175
|
-
|
178
|
+
|
176
179
|
</datafield>
|
177
180
|
<datafield ind1="9" ind2=" " tag="710">
|
178
181
|
<subfield code="6">880-07</subfield>
|
@@ -260,4 +263,4 @@
|
|
260
263
|
<xb:exact>true</xb:exact>
|
261
264
|
<xb:responseDate>2022-01-27T19:08:03-0800</xb:responseDate>
|
262
265
|
</extraResponseData>
|
263
|
-
</searchRetrieveResponse>
|
266
|
+
</searchRetrieveResponse>
|
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.
|
4
|
+
version: 0.7.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:
|
11
|
+
date: 2023-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: berkeley_library-alma
|
@@ -65,6 +65,9 @@ dependencies:
|
|
65
65
|
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
version: '0.1'
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 0.1.2
|
68
71
|
type: :runtime
|
69
72
|
prerelease: false
|
70
73
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -72,6 +75,9 @@ dependencies:
|
|
72
75
|
- - "~>"
|
73
76
|
- !ruby/object:Gem::Version
|
74
77
|
version: '0.1'
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 0.1.2
|
75
81
|
- !ruby/object:Gem::Dependency
|
76
82
|
name: ice_nine
|
77
83
|
requirement: !ruby/object:Gem::Requirement
|
@@ -135,6 +141,9 @@ dependencies:
|
|
135
141
|
- - "~>"
|
136
142
|
- !ruby/object:Gem::Version
|
137
143
|
version: '2.3'
|
144
|
+
- - "<"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '3.0'
|
138
147
|
type: :runtime
|
139
148
|
prerelease: false
|
140
149
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -142,6 +151,9 @@ dependencies:
|
|
142
151
|
- - "~>"
|
143
152
|
- !ruby/object:Gem::Version
|
144
153
|
version: '2.3'
|
154
|
+
- - "<"
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '3.0'
|
145
157
|
- !ruby/object:Gem::Dependency
|
146
158
|
name: typesafe_enum
|
147
159
|
requirement: !ruby/object:Gem::Requirement
|
@@ -451,6 +463,7 @@ files:
|
|
451
463
|
- lib/berkeley_library/tind/mapping/tind_field_from_single_map.rb
|
452
464
|
- lib/berkeley_library/tind/mapping/tind_field_util.rb
|
453
465
|
- lib/berkeley_library/tind/mapping/tind_marc.rb
|
466
|
+
- lib/berkeley_library/tind/mapping/tind_record_util.rb
|
454
467
|
- lib/berkeley_library/tind/mapping/tind_subfield_util.rb
|
455
468
|
- lib/berkeley_library/tind/mapping/util.rb
|
456
469
|
- lib/berkeley_library/tind/marc.rb
|
@@ -458,7 +471,6 @@ files:
|
|
458
471
|
- lib/berkeley_library/tind/marc/xml_reader.rb
|
459
472
|
- lib/berkeley_library/tind/marc/xml_writer.rb
|
460
473
|
- lib/berkeley_library/tind/module_info.rb
|
461
|
-
- lib/berkeley_library/util/files.rb
|
462
474
|
- lib/berkeley_library/util/ods/spreadsheet.rb
|
463
475
|
- lib/berkeley_library/util/ods/xml/content_doc.rb
|
464
476
|
- lib/berkeley_library/util/ods/xml/document_node.rb
|
@@ -543,6 +555,7 @@ files:
|
|
543
555
|
- spec/berkeley_library/tind/mapping/tind_field_spec.rb
|
544
556
|
- spec/berkeley_library/tind/mapping/tind_field_util_spec.rb
|
545
557
|
- spec/berkeley_library/tind/mapping/tind_marc_spec.rb
|
558
|
+
- spec/berkeley_library/tind/mapping/tind_record_util_spec.rb
|
546
559
|
- spec/berkeley_library/tind/mapping/tind_subfield_util_spec.rb
|
547
560
|
- spec/berkeley_library/tind/mapping/util_spec.rb
|
548
561
|
- spec/berkeley_library/tind/marc/xml_reader_spec.rb
|
@@ -556,6 +569,10 @@ files:
|
|
556
569
|
- spec/berkeley_library/util/ods/xml/style/family_spec.rb
|
557
570
|
- spec/berkeley_library/util/ods/xml/table/table_row_spec.rb
|
558
571
|
- spec/berkeley_library/util/ods/xml/table/table_spec.rb
|
572
|
+
- spec/data/api/pre_assigned_response.json
|
573
|
+
- spec/data/api/result_file.csv
|
574
|
+
- spec/data/api/upload_file.json
|
575
|
+
- spec/data/api/upload_response.json
|
559
576
|
- spec/data/collection-names.txt
|
560
577
|
- spec/data/collections.json
|
561
578
|
- spec/data/disjoint-records.xml
|
@@ -605,83 +622,4 @@ rubygems_version: 3.1.6
|
|
605
622
|
signing_key:
|
606
623
|
specification_version: 4
|
607
624
|
summary: TIND DA utilities for the UC Berkeley Library
|
608
|
-
test_files:
|
609
|
-
- spec/.rubocop.yml
|
610
|
-
- spec/berkeley_library/tind/api/api_exception_spec.rb
|
611
|
-
- spec/berkeley_library/tind/api/api_spec.rb
|
612
|
-
- spec/berkeley_library/tind/api/collection_spec.rb
|
613
|
-
- spec/berkeley_library/tind/api/date_range_spec.rb
|
614
|
-
- spec/berkeley_library/tind/api/format_spec.rb
|
615
|
-
- spec/berkeley_library/tind/api/search_spec.rb
|
616
|
-
- spec/berkeley_library/tind/config_spec.rb
|
617
|
-
- spec/berkeley_library/tind/export/column_group_spec.rb
|
618
|
-
- spec/berkeley_library/tind/export/column_spec.rb
|
619
|
-
- spec/berkeley_library/tind/export/config_spec.rb
|
620
|
-
- spec/berkeley_library/tind/export/export_command_spec.rb
|
621
|
-
- spec/berkeley_library/tind/export/export_format_spec.rb
|
622
|
-
- spec/berkeley_library/tind/export/export_matcher.rb
|
623
|
-
- spec/berkeley_library/tind/export/export_spec.rb
|
624
|
-
- spec/berkeley_library/tind/export/exporter_spec.rb
|
625
|
-
- spec/berkeley_library/tind/export/row_spec.rb
|
626
|
-
- spec/berkeley_library/tind/export/table_spec.rb
|
627
|
-
- spec/berkeley_library/tind/mapping/additional_datafield_process_spec.rb
|
628
|
-
- spec/berkeley_library/tind/mapping/alma_base_spec.rb
|
629
|
-
- spec/berkeley_library/tind/mapping/alma_multiple_tind_spec.rb
|
630
|
-
- spec/berkeley_library/tind/mapping/alma_single_tind_spec.rb
|
631
|
-
- spec/berkeley_library/tind/mapping/alma_spec.rb
|
632
|
-
- spec/berkeley_library/tind/mapping/config_spec.rb
|
633
|
-
- spec/berkeley_library/tind/mapping/csv_mapper_spec.rb
|
634
|
-
- spec/berkeley_library/tind/mapping/csv_multiple_mapper_spec.rb
|
635
|
-
- spec/berkeley_library/tind/mapping/external_tind_field_spec.rb
|
636
|
-
- spec/berkeley_library/tind/mapping/field_catalog_spec.rb
|
637
|
-
- spec/berkeley_library/tind/mapping/field_catalog_util_spec.rb
|
638
|
-
- spec/berkeley_library/tind/mapping/match_tind_field_spec.rb
|
639
|
-
- spec/berkeley_library/tind/mapping/misc_spec.rb
|
640
|
-
- spec/berkeley_library/tind/mapping/multiple_rule_spec.rb
|
641
|
-
- spec/berkeley_library/tind/mapping/single_rule_spec.rb
|
642
|
-
- spec/berkeley_library/tind/mapping/tind_control_subfield_spec.rb
|
643
|
-
- spec/berkeley_library/tind/mapping/tind_field_from_leader_spec.rb
|
644
|
-
- spec/berkeley_library/tind/mapping/tind_field_from_multiple_map_spec.rb
|
645
|
-
- spec/berkeley_library/tind/mapping/tind_field_from_single_map_spec.rb
|
646
|
-
- spec/berkeley_library/tind/mapping/tind_field_spec.rb
|
647
|
-
- spec/berkeley_library/tind/mapping/tind_field_util_spec.rb
|
648
|
-
- spec/berkeley_library/tind/mapping/tind_marc_spec.rb
|
649
|
-
- spec/berkeley_library/tind/mapping/tind_subfield_util_spec.rb
|
650
|
-
- spec/berkeley_library/tind/mapping/util_spec.rb
|
651
|
-
- spec/berkeley_library/tind/marc/xml_reader_spec.rb
|
652
|
-
- spec/berkeley_library/tind/marc/xml_writer_spec.rb
|
653
|
-
- spec/berkeley_library/util/ods/spreadsheet_spec.rb
|
654
|
-
- spec/berkeley_library/util/ods/xml/content_doc_spec.rb
|
655
|
-
- spec/berkeley_library/util/ods/xml/manifest/file_entry_spec.rb
|
656
|
-
- spec/berkeley_library/util/ods/xml/manifest/manifest_spec.rb
|
657
|
-
- spec/berkeley_library/util/ods/xml/office/document_content_spec.rb
|
658
|
-
- spec/berkeley_library/util/ods/xml/style/automatic_styles_spec.rb
|
659
|
-
- spec/berkeley_library/util/ods/xml/style/family_spec.rb
|
660
|
-
- spec/berkeley_library/util/ods/xml/table/table_row_spec.rb
|
661
|
-
- spec/berkeley_library/util/ods/xml/table/table_spec.rb
|
662
|
-
- spec/data/collection-names.txt
|
663
|
-
- spec/data/collections.json
|
664
|
-
- spec/data/disjoint-records.xml
|
665
|
-
- spec/data/issue-4.xml
|
666
|
-
- spec/data/mapping/991032333019706532-sru.xml
|
667
|
-
- spec/data/mapping/one_to_multiple_mapping.csv
|
668
|
-
- spec/data/mapping/one_to_one_mapping.csv
|
669
|
-
- spec/data/mapping/record.xml
|
670
|
-
- spec/data/mapping/record_not_qualified.xml
|
671
|
-
- spec/data/new-records.xml
|
672
|
-
- spec/data/record-184453.xml
|
673
|
-
- spec/data/record-184458.xml
|
674
|
-
- spec/data/record-187888.xml
|
675
|
-
- spec/data/records-api-search-cjk-p1.xml
|
676
|
-
- spec/data/records-api-search-cjk-p2.xml
|
677
|
-
- spec/data/records-api-search-p1.xml
|
678
|
-
- spec/data/records-api-search-p2.xml
|
679
|
-
- spec/data/records-api-search-p3.xml
|
680
|
-
- spec/data/records-api-search-p4.xml
|
681
|
-
- spec/data/records-api-search-p5.xml
|
682
|
-
- spec/data/records-api-search-p6.xml
|
683
|
-
- spec/data/records-api-search-p7.xml
|
684
|
-
- spec/data/records-api-search.xml
|
685
|
-
- spec/data/records-manual-search.xml
|
686
|
-
- spec/spec_helper.rb
|
687
|
-
- test/profile/table_from_records_profile.rb
|
625
|
+
test_files: []
|
@@ -1,38 +0,0 @@
|
|
1
|
-
module BerkeleyLibrary
|
2
|
-
module Util
|
3
|
-
# TODO: Move this to `berkeley_library-util`
|
4
|
-
module Files
|
5
|
-
class << self
|
6
|
-
include Files
|
7
|
-
end
|
8
|
-
|
9
|
-
def file_exists?(path)
|
10
|
-
(path.respond_to?(:exist?) && path.exist?) ||
|
11
|
-
(path.respond_to?(:to_str) && File.exist?(path))
|
12
|
-
end
|
13
|
-
|
14
|
-
def parent_exists?(path)
|
15
|
-
path.respond_to?(:parent) && path.parent.exist? ||
|
16
|
-
path.respond_to?(:to_str) && Pathname.new(path).parent.exist?
|
17
|
-
end
|
18
|
-
|
19
|
-
# Returns true if `obj` is close enough to an IO object for Nokogiri
|
20
|
-
# to parse as one.
|
21
|
-
#
|
22
|
-
# @param obj [Object] the object that might be an IO
|
23
|
-
# @see https://github.com/sparklemotion/nokogiri/blob/v1.11.1/lib/nokogiri/xml/sax/parser.rb#L81 Nokogiri::XML::SAX::Parser#parse
|
24
|
-
def reader_like?(obj)
|
25
|
-
obj.respond_to?(:read) && obj.respond_to?(:close)
|
26
|
-
end
|
27
|
-
|
28
|
-
# Returns true if `obj` is close enough to an IO object for Nokogiri
|
29
|
-
# to write to.
|
30
|
-
#
|
31
|
-
# @param obj [Object] the object that might be an IO
|
32
|
-
def writer_like?(obj)
|
33
|
-
obj.respond_to?(:write) && obj.respond_to?(:close)
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|