Module: Metanorma::Util
- Defined in:
- lib/metanorma/util/util.rb
Class Method Summary collapse
- .log(message, type = :info) ⇒ Object
- .recursive_string_keys(hash) ⇒ Object
- .sort_extensions_execution(ext) ⇒ Object
-
.sort_extensions_execution_ord(ext) ⇒ Object
dependency ordering.
Class Method Details
.log(message, type = :info) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/metanorma/util/util.rb', line 4 def log(, type = :info) log_types = Metanorma.configuration.logs.map(&:to_s) || [] if log_types.include?(type.to_s) puts() end if type == :fatal abort end end |
.recursive_string_keys(hash) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/metanorma/util/util.rb', line 33 def recursive_string_keys(hash) case hash when Hash then hash.map do |k, v| [k.to_s, recursive_string_keys(v)] end.to_h when Enumerable then hash.map { |v| recursive_string_keys(v) } else hash end end |
.sort_extensions_execution(ext) ⇒ Object
27 28 29 30 31 |
# File 'lib/metanorma/util/util.rb', line 27 def sort_extensions_execution(ext) ext.sort do |a, b| sort_extensions_execution_ord(a) <=> sort_extensions_execution_ord(b) end end |
.sort_extensions_execution_ord(ext) ⇒ Object
dependency ordering
17 18 19 20 21 22 23 24 25 |
# File 'lib/metanorma/util/util.rb', line 17 def sort_extensions_execution_ord(ext) case ext when :xml then 0 when :rxl then 1 when :presentation then 2 else 99 end end |