lib/iev/term_builder.rb in iev-0.3.4 vs lib/iev/term_builder.rb in iev-0.3.5

- old
+ new

@@ -1,15 +1,13 @@ # frozen_string_literal: true # (c) Copyright 2020 Ribose Inc. # -require "pp" - -module IEV +module Iev class TermBuilder - include CLI::UI + include Cli::Ui include Utilities using DataConversions def initialize(data) @data = data @@ -119,11 +117,11 @@ Note\s*\d+\sto\sentry: | Note&nbsp;\d+\sto\sentry: | Note\s*\d+\sto\sthe\sentry: | Note\sto\sentry\s*\d+: | Note\s*\d+?\sà\sl['’]article: | - <NOTE\/?>?\s*\d?\s+.*?– | + <NOTE/?>?\s*\d?\s+.*?– | NOTE(?:\s+-)? | Note\s+\d+\s– | Note&nbsp;\d+\s ) ) @@ -135,13 +133,13 @@ definition_arr = [] # here array for consistent interface next_part_arr = definition_arr remaining_str = find_value_for("DEFINITION") - while md = remaining_str&.match(slicer_rx) + while (md = remaining_str&.match(slicer_rx)) next_part = md.pre_match - next_part.sub!(/^\[:Ex(a|e)mple\]/, "Ex\\1mple") + next_part.sub!(/^\[:Ex(a|e)mple\]/, 'Ex\\1mple') next_part_arr.push(next_part) next_part_arr = md[:example] ? @examples : @notes # 112-03-17 # supplements the name of a quantity, especially for a component in a # system, to indicate the quotient of that quantity by the total @@ -155,14 +153,14 @@ # above will capture it as an example and will add an empty `Note` # and put the rest in an `Example`. So In this case we will replace # the `Example` with `[:Example]` and revert it in the next iteration # so it will not be caught by the regex. remaining_str = md.post_match - remaining_str.sub!(/^Ex(a|e)mple/, "[:Ex\\1mple]") if md[:note] + remaining_str.sub!(/^Ex(a|e)mple/, '[:Ex\\1mple]') if md[:note] end - remaining_str&.sub!(/^\[:Ex(a|e)mple\]/, "Ex\\1mple") + remaining_str&.sub!(/^\[:Ex(a|e)mple\]/, 'Ex\\1mple') next_part_arr.push(remaining_str) @definition = definition_arr.first @definition = nil if @definition&.empty? end @@ -206,37 +204,36 @@ raw_term = find_value_for("SYMBOLE") raw_term && build_symbol_designation(raw_term) end def extract_definition_value - if @definition - IEV::Converter.mathml_to_asciimath( - replace_newlines(parse_anchor_tag(@definition, term_domain)), - ).strip - end + return unless @definition + + Iev::Converter.mathml_to_asciimath( + replace_newlines(parse_anchor_tag(@definition, term_domain)), + ).strip end def extract_examples @examples.map do |str| - IEV::Converter.mathml_to_asciimath( + Iev::Converter.mathml_to_asciimath( replace_newlines(parse_anchor_tag(str, term_domain)), ).strip end end def extract_notes @notes.map do |str| - IEV::Converter.mathml_to_asciimath( + Iev::Converter.mathml_to_asciimath( replace_newlines(parse_anchor_tag(str, term_domain)), ).strip end end def extract_entry_status case find_value_for("STATUS").downcase when "standard" then "valid" - else nil end end def extract_classification classification_val = find_value_for("SYNONYM1STATUS") @@ -273,11 +270,11 @@ end private def build_expression_designation(raw_term, attribute_data:, status:) - term = IEV::Converter.mathml_to_asciimath( + term = Iev::Converter.mathml_to_asciimath( parse_anchor_tag(raw_term, term_domain), ) term_attributes = TermAttrsParser.new(attribute_data.to_s) statuses = { @@ -297,10 +294,10 @@ "plurality" => term_attributes.plurality, }.compact end def build_symbol_designation(raw_term) - term = IEV::Converter.mathml_to_asciimath( + term = Iev::Converter.mathml_to_asciimath( parse_anchor_tag(raw_term, term_domain), ) { "type" => "symbol",