lib/metanorma/generic/front.rb in metanorma-generic-2.5.2 vs lib/metanorma/generic/front.rb in metanorma-generic-2.5.3

- old
+ new

@@ -20,12 +20,11 @@ def relaton_relations Array(configuration.relations) || [] end def metadata_committee(node, xml) - return unless node.attr("committee") - + node.attr("committee") or return xml.editorialgroup do |a| a.committee node.attr("committee"), **attr_code(type: node.attr("committee-type")) i = 2 while node.attr("committee_#{i}") @@ -71,12 +70,11 @@ EXT_STRUCT = %w(_output _attribute _list).freeze def metadata_ext_hash(node, ext, hash) hash.each do |k, v| - next if EXT_STRUCT.include?(k) || (!v.is_a?(Hash) && !node.attr(k)) - + EXT_STRUCT.include?(k) || (!v.is_a?(Hash) && !node.attr(k)) and next if v.is_a?(Hash) && v["_list"] csv_split(node.attr(k), ",").each do |val| metadata_ext_hash1(k, val, ext, v, node) end else @@ -84,16 +82,14 @@ end end end def metadata_ext_hash1(key, value, ext, hash, node) - return if hash.is_a?(Hash) && hash["_attribute"] - - is_hash = hash.is_a?(Hash) && - !hash.keys.reject { |n| EXT_STRUCT.include?(n) }.empty? - return if !is_hash && (value.nil? || value.empty?) - - name = hash.is_a?(Hash) ? (hash["_output"] || key) : key + h = hash.is_a?(Hash) + h && hash["_attribute"] and return + is_hash = h && !hash.keys.reject { |n| EXT_STRUCT.include?(n) }.empty? + !is_hash && (value.nil? || value.empty?) and return + name = h ? (hash["_output"] || key) : key ext.send name, **attr_code(metadata_ext_attrs(hash, node)) do |e| is_hash ? metadata_ext_hash(node, e, hash) : (e << value) end end