Module: IsoDoc::Iso::Init
- Included in:
- HtmlConvert, PresentationXMLConvert, WordConvert
- Defined in:
- lib/isodoc/iso/init.rb
Instance Method Summary collapse
- #amd?(_docxml) ⇒ Boolean
- #bibrenderer(options = {}) ⇒ Object
- #clausedelim ⇒ Object
- #i18n_conditional_set(old, new) ⇒ Object
- #i18n_init(lang, script, locale, i18nyaml = nil) ⇒ Object
- #metadata_init(lang, script, locale, i18n) ⇒ Object
- #requirements_processor ⇒ Object
- #std_docid_semantic(id) ⇒ Object
- #std_docid_semantic1(id) ⇒ Object
- #std_docid_semantic_full(ident) ⇒ Object
- #update_i18n(docxml) ⇒ Object
- #xref_init(lang, script, _klass, i18n, options) ⇒ Object
Instance Method Details
#amd?(_docxml) ⇒ Boolean
43 44 45 |
# File 'lib/isodoc/iso/init.rb', line 43 def amd?(_docxml) %w(amendment technical-corrigendum).include? @doctype end |
#bibrenderer(options = {}) ⇒ Object
38 39 40 41 |
# File 'lib/isodoc/iso/init.rb', line 38 def bibrenderer( = {}) ::Relaton::Render::Iso::General.new(.merge(language: @lang, i18nhash: @i18n.get)) end |
#clausedelim ⇒ Object
47 48 49 |
# File 'lib/isodoc/iso/init.rb', line 47 def clausedelim "" end |
#i18n_conditional_set(old, new) ⇒ Object
33 34 35 36 |
# File 'lib/isodoc/iso/init.rb', line 33 def i18n_conditional_set(old, new) @i18n.get[new] or return @i18n.set(old, @i18n.get[new]) end |
#i18n_init(lang, script, locale, i18nyaml = nil) ⇒ Object
18 19 20 21 |
# File 'lib/isodoc/iso/init.rb', line 18 def i18n_init(lang, script, locale, i18nyaml = nil) @i18n = I18n.new(lang, script, locale: locale, i18nyaml: i18nyaml || @i18nyaml) end |
#metadata_init(lang, script, locale, i18n) ⇒ Object
9 10 11 |
# File 'lib/isodoc/iso/init.rb', line 9 def (lang, script, locale, i18n) @meta = Metadata.new(lang, script, locale, i18n) end |
#requirements_processor ⇒ Object
51 52 53 |
# File 'lib/isodoc/iso/init.rb', line 51 def requirements_processor ::Metanorma::Requirements::Iso end |
#std_docid_semantic(id) ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/isodoc/iso/init.rb', line 55 def std_docid_semantic(id) id.nil? and return nil ret = Nokogiri::XML.fragment(id) ret.traverse do |x| x.text? or next x.replace(std_docid_semantic1(x.text)) end to_xml(ret) end |
#std_docid_semantic1(id) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/isodoc/iso/init.rb', line 65 def std_docid_semantic1(id) ids = id.split(/(\p{Zs})/) agency?(ids[0].sub(%r{^([^/]+)/.*$}, "\\1")) or return id ids.map! do |i| if %w(GUIDE TR TS DIR).include?(i) "<span class='stddocNumber'>#{i}</span>" elsif /\p{Zs}/.match?(i) then i else std_docid_semantic_full(i) end end.join.gsub(%r{</span>(\p{Zs}+)<}, "\\1</span><") end |
#std_docid_semantic_full(ident) ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/isodoc/iso/init.rb', line 77 def std_docid_semantic_full(ident) ident .sub(/^([^0-9]+)(\p{Zs}|$)/, "<span class='stdpublisher'>\\1</span>\\2") .sub(/([0-9]+)/, "<span class='stddocNumber'>\\1</span>") .sub(/-([0-9]+)/, "-<span class='stddocPartNumber'>\\1</span>") .sub(/:([0-9]{4})(?!\d)/, ":<span class='stdyear'>\\1</span>") end |
#update_i18n(docxml) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/isodoc/iso/init.rb', line 23 def update_i18n(docxml) @docscheme = docxml.at(ns("//presentation-metadata[name" \ "[text() = 'document-scheme']]/value"))&.text || "2024" %w(1951 1972).include?(@docscheme) and i18n_conditional_set("reference_number", "reference_number_abbrev") %w(1951).include?(@docscheme) and i18n_conditional_set("edition_ordinal", "edition_ordinal_old") end |
#xref_init(lang, script, _klass, i18n, options) ⇒ Object
13 14 15 16 |
# File 'lib/isodoc/iso/init.rb', line 13 def xref_init(lang, script, _klass, i18n, ) html = HtmlConvert.new(language: lang, script: script) @xrefs = Xref.new(lang, script, html, i18n, ) end |