lib/relaton/db.rb in relaton-0.5.10 vs lib/relaton/db.rb in relaton-0.5.11
- old
+ new
@@ -95,11 +95,14 @@
processor.defaultprefix.match(code)
end
allowed = @registry.processors.reduce([]) do |m, (_k, v)|
m << v.prefix
end
- warn "#{code} does not have a recognised prefix: #{allowed.join(', ')}"
+ warn <<~WARN
+ #{code} does not have a recognised prefix: #{allowed.join(', ')}.
+ See https://github.com/relaton/relaton/ for instructions on prefixing and wrapping document identifiers to disambiguate them.
+ WARN
end
# TODO: i18n
# Fofmat ID
# @param code [String]
@@ -108,11 +111,11 @@
# @param stdClass [Symbol]
# @return [Array<String>] docid and code
def std_id(code, year, opts, stdclass)
prefix, code = strip_id_wrapper(code, stdclass)
ret = code
- ret += ":#{year}" if year
+ ret += (stdclass == :relaton_gb ? "-" : ":") + year if year
ret += " (all parts)" if opts[:all_parts]
["#{prefix}(#{ret.strip})", code]
end
# Find prefix and clean code
@@ -173,10 +176,10 @@
# @param db [Relaton::DbCache,`NilClass]
# @param id [String] docid
# @return [String]
def new_bib_entry(code, year, opts, stdclass, **args)
bib = @registry.processors[stdclass].get(code, year, opts)
- bib_id = bib&.docidentifier&.first&.id&.sub(%r{(?<=\d)-(?=\d{4})}, ":")
+ bib_id = bib&.docidentifier&.first&.id
# when docid doesn't match bib's id then return a reference to bib's id
if args[:db] && args[:id] && bib_id && args[:id] !~ %r{\(#{bib_id}\)}
bid = std_id(bib.docidentifier.first.id, nil, {}, stdclass).first
args[:db][bid] ||= bib_entry bib