#!/usr/bin/env ruby begin # This should work if (1) the gem is installed, or # (2) we're in development and used `bundle exec` require 'berkeley_library/tind' require 'berkeley_library/alma' rescue LoadError # If we're in development, `require 'bundler/setup'` # is roughly equivalent to `bundle exec` require 'bundler/setup' require 'berkeley_library/tind' require 'berkeley_library/alma' end def setup BerkeleyLibrary::TIND::Mapping::AlmaBase.collection_parameter_hash = { '336' => ['Image'], '852' => ['East Asian Library'], '980' => ['pre_1912'], '982' => ['Pre 1912 Chinese Materials - short name', 'Pre 1912 Chinese Materials - long name'], '991' => [] } BerkeleyLibrary::TIND::Mapping::AlmaBase.is_035_from_mms_id = true BerkeleyLibrary::TIND::Mapping::AlmaBase.is_barcode = false end def additional_tind_fields txt = 'v001_0064' url = 'https://digitalassets.lib.berkeley.edu/pre1912ChineseMaterials/ucb/ready/991032333019706532/991032333019706532_v001_0064.jpg' fft = BerkeleyLibrary::TIND::Mapping::TindField.f_fft(url, txt) f = ::MARC::DataField.new('998', ' ', ' ', ['a', 'fake-value']) [fft] << f end ############## Use this, when creating a TIND record from each Alma record ############ # alma_id = '991085821143406532' # alma_id_bad = '99108582114340653' # a bad alma_id # alma_id_not_qualified = '991084606989706532' # Host historical record barcode = 'C084093187' id = barcode setup BerkeleyLibrary::Alma::Config.default! alma_single_tind = BerkeleyLibrary::TIND::Mapping::AlmaSingleTIND.new tind_record = alma_single_tind.record(id, additional_tind_fields) alma_single_tind.save_tind_record_to_file(id, tind_record, 'tmp/test_single.xml')