Module: Metanorma::Util
- Defined in:
- lib/metanorma/util/util.rb,
lib/metanorma/util/worker_pool.rb,
lib/metanorma/util/fontist_helper.rb
Defined Under Namespace
Classes: FontistHelper, WorkersPool
Class Method Summary
collapse
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(message, type = :info)
log_types = Metanorma.configuration.logs.map(&:to_s) || []
if log_types.include?(type.to_s)
puts(message)
end
if type == :fatal
exit(1)
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
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
|