lib/relaton/db.rb in relaton-0.2.6 vs lib/relaton/db.rb in relaton-0.3.0

- old
+ new

@@ -51,10 +51,17 @@ std = standard_class(code) or return nil end check_bibliocache(code, year, opts, std) end + def fetched(key) + return @local_db.fetched key if @local_db + return @db.fetched key if @db + + "" + end + # The document identifier class corresponding to the given code def docid_type(code) stdclass = standard_class(code) or return [nil, code] prefix, code = strip_id_wrapper(code, stdclass) [@registry.processors[stdclass].idtype, code] @@ -69,13 +76,12 @@ end @db[key] end # @param key [String] - # @param value [Hash] - # @option value [Date] "fetched" - # @option value [IsoBibItem::IsoBibliographicItem] "bib" + # @param value [String] Bibitem xml serialisation. + # @option value [String] Bibitem xml serialisation. def save_entry(key, value) @db.nil? || (@db[key] = value) @local_db.nil? || (@local_db[key] = value) end @@ -162,9 +168,10 @@ # @param opts [Hash] # @param stdclass [Symbol] # @return [Hash] def new_bib_entry(code, year, opts, stdclass) bib = @registry.processors[stdclass].get(code, year, opts) + bib = bib.to_xml if bib.respond_to? :to_xml bib = "not_found #{Date.today}" if bib.nil? || bib.empty? bib end # if cached reference is undated, expire it after 60 days