Class: Relaton::Db
- Inherits:
-
Object
- Object
- Relaton::Db
- Defined in:
- lib/relaton/db.rb
Constant Summary collapse
- SUPPORTED_GEMS =
%w[ isobib rfcbib gbbib ].freeze
Instance Method Summary collapse
-
#fetch(code, year = nil, opts = {}) ⇒ String
The class of reference requested is determined by the prefix of the code: GB Standard for gbbib, IETF for rfcbib, ISO or IEC or IEV for isobib.
-
#initialize(global_cache, local_cache) ⇒ Db
constructor
A new instance of Db.
- #register_gems ⇒ Object
- #save ⇒ Object
Constructor Details
#initialize(global_cache, local_cache) ⇒ Db
Returns a new instance of Db.
9 10 11 12 13 14 15 16 |
# File 'lib/relaton/db.rb', line 9 def initialize(global_cache, local_cache) @bibdb = open_cache_biblio(global_cache) @local_bibdb = open_cache_biblio(local_cache) @bibdb_name = global_cache @local_bibdb_name = local_cache register_gems @registry = Relaton::Registry.instance end |
Instance Method Details
#fetch(code, year = nil, opts = {}) ⇒ String
The class of reference requested is determined by the prefix of the code: GB Standard for gbbib, IETF for rfcbib, ISO or IEC or IEV for isobib
36 37 38 39 |
# File 'lib/relaton/db.rb', line 36 def fetch(code, year = nil, opts = {}) stdclass = standard_class(code) or return nil check_bibliocache(code, year, opts, stdclass) end |
#register_gems ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/relaton/db.rb', line 18 def register_gems puts "[relaton] detecting backends:" SUPPORTED_GEMS.each do |b| puts b begin require b rescue LoadError puts "[relaton] backend #{b} not present" end end end |
#save ⇒ Object
41 42 43 44 |
# File 'lib/relaton/db.rb', line 41 def save save_cache_biblio(@bibdb, @bibdb_name) save_cache_biblio(@local_bibdb, @local_bibdb_name) end |