Sha256: 2c92703aa8a32b834af8acd80e3ce8534e53d583636fedb8daa86a39e14f730c
Contents?: true
Size: 1.44 KB
Versions: 5
Compression:
Stored size: 1.44 KB
Contents
#!/usr/bin/env ruby # ------------------------------------------------------------ # Global setup # Don't buffer stdout or stderr $stdout.sync = true $stderr.sync = true # ------------------------------------------------------------ # Dependencies # Require gems require 'bundler/setup' # Require lib directory unless $LOAD_PATH.include?((lib_path = File.expand_path('../lib', __dir__))) puts "Adding #{lib_path} to $LOAD_PATH" $LOAD_PATH.unshift(lib_path) end require 'berkeley_library/alma' # ------------------------------------------------------------ # Configuration # Configure Alma URLs etc. BerkeleyLibrary::Alma::Config.default! # Set log level BerkeleyLibrary::Logging.logger.level = Logger::Severity::WARN # ------------------------------------------------------------ # Utility methods # Read raw IDs from STDIN def raw_ids @raw_ids ||= Enumerator.new do |y| $stdin.each_line(chomp: true) do |ln| y << ln.strip end end end # Read control field 001 from MARC record for specified record ID def id_001_for(record_id) return unless record_id return unless (marc_record = record_id.get_marc_record) return unless (cf_001 = marc_record['001']) cf_001.value end # ------------------------------------------------------------ # Main program raw_ids.each do |raw_id| record_id = BerkeleyLibrary::Alma::RecordId.parse(raw_id) canonical_id = id_001_for(record_id) puts [raw_id, record_id, canonical_id].join("\t") end
Version data entries
5 entries across 5 versions & 1 rubygems