Class: RelatonCalconnect::CcBibliography
- Inherits:
-
Object
- Object
- RelatonCalconnect::CcBibliography
- Defined in:
- lib/relaton_calconnect/cc_bibliography.rb
Class Method Summary collapse
- .get(ref, year = nil, opts = {}) ⇒ RelatonCalconnect::CcBibliographicItem
- .search(text, year = nil, _opts = {}) ⇒ RelatonCalconnect::HitCollection
Class Method Details
.get(ref, year = nil, opts = {}) ⇒ RelatonCalconnect::CcBibliographicItem
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/relaton_calconnect/cc_bibliography.rb', line 21 def get(ref, year = nil, opts = {}) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength code = ref if year.nil? /^(?<code1>[^\s]+(?:\s\w+)?\s[\d-]+):?(?<year1>\d{4})?/ =~ ref unless code1.nil? code = code1 year = year1 end end Util.info "Fetching from Relaton repository ...", key: ref result = search(code, year, opts) || (return nil) ret = bib_results_filter(result, year) if ret[:ret] Util.info "Found: `#{ret[:ret].docidentifier.first.id}`", key: ref ret[:ret] else Util.info "No found.", key: ref fetch_ref_err(code, year, ret[:years]) end end |
.search(text, year = nil, _opts = {}) ⇒ RelatonCalconnect::HitCollection
6 7 8 9 10 |
# File 'lib/relaton_calconnect/cc_bibliography.rb', line 6 def search(text, year = nil, _opts = {}) HitCollection.new text, year rescue Faraday::ConnectionFailed raise RelatonBib::RequestError, "Could not access https://standards.calconnect.org" end |