Module: Relaton::Iec
- Defined in:
- lib/relaton/iec.rb,
lib/relaton/iec/hit.rb,
lib/relaton/iec/util.rb,
lib/relaton/iec/version.rb,
lib/relaton/iec/item_data.rb,
lib/relaton/iec/model/ext.rb,
lib/relaton/iec/processor.rb,
lib/relaton/iec/model/item.rb,
lib/relaton/iec/data_parser.rb,
lib/relaton/iec/bibliography.rb,
lib/relaton/iec/data_fetcher.rb,
lib/relaton/iec/model/bibdata.rb,
lib/relaton/iec/model/bibitem.rb,
lib/relaton/iec/model/doctype.rb,
lib/relaton/iec/hit_collection.rb,
lib/relaton/iec/model/relation.rb,
lib/relaton/iec/model/item_base.rb,
lib/relaton/iec/model/stage_name.rb,
lib/relaton/iec/model/docidentifier.rb
Defined Under Namespace
Modules: Util Classes: Bibdata, Bibitem, Bibliography, DataFetcher, DataParser, Docidentifier, Doctype, Ext, Hit, HitCollection, Item, ItemBase, ItemData, Processor, Relation, StageName
Constant Summary collapse
- INDEXFILE =
"index-v1".freeze
- VERSION =
"2.1.0".freeze
Class Method Summary collapse
- .code_to_urn(code, lang = nil) ⇒ String?
-
.grammar_hash ⇒ String
Returns hash of XML reammar.
-
.urn_to_code(urn) ⇒ Array<String>?
Urn & language.
Class Method Details
.code_to_urn(code, lang = nil) ⇒ String?
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/relaton/iec.rb', line 38 def code_to_urn(code, lang = nil) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength rest = code.downcase.sub(%r{ (?<head>[^\s]+)\s (?<type>is|ts|tr|pas|srd|guide|tec|wp)?(?(<type>)\s) (?<pnum>[\d-]+)\s? (?<_dd>:)?(?(<_dd>)(?<date>[\d-]+)\s?) }x, "") m = $~ return unless m[:head] && m[:pnum] deliv = /cmv|csv|exv|prv|rlv|ser/.match(code.downcase).to_s urn = ["urn", "iec", "std", m[:head].split("/").join("-"), m[:pnum], m[:date], m[:type], deliv, lang] (urn + ajunct_to_urn(rest)).join ":" end |
.grammar_hash ⇒ String
Returns hash of XML reammar
28 29 30 31 32 33 |
# File 'lib/relaton/iec.rb', line 28 def grammar_hash # gem_path = File.expand_path "..", __dir__ # grammars_path = File.join gem_path, "grammars", "*" # grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join Digest::MD5.hexdigest Relaton::Iec::VERSION + Relaton::Iso::VERSION + Relaton::Bib::VERSION # grammars end |
.urn_to_code(urn) ⇒ Array<String>?
Returns urn & language.
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/relaton/iec.rb', line 55 def urn_to_code(urn) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity fields = urn.upcase.split ":" return if fields.size < 5 head, num, date, type, deliv, lang = fields[3, 8] code = head.gsub("-", "/") code += " #{type}" unless type.nil? || type.empty? code += " #{num}" code += ":#{date}" unless date.nil? || date.empty? code += ajanct_to_code(fields[9..-1]) code += " #{deliv}" unless deliv.nil? || deliv.empty? [code, lang&.downcase] end |