Method: Metanorma::Compile#validate_type

Defined in:
lib/metanorma/compile.rb

#validate_type(options) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/metanorma/compile.rb', line 60

def validate_type(options)
  unless options[:type]
    Util.log("[metanorma] Error: Please specify a standard type: #{@registry.supported_backends}.", :error)
    return nil
  end
  stdtype = options[:type].to_sym
  unless @registry.supported_backends.include? stdtype
    Util.log("[metanorma] Info: Loading `metanorma-#{stdtype}` gem for standard type `#{stdtype}`.", :info)
  end
  begin
    require "metanorma-#{stdtype}"
    Util.log("[metanorma] Info: gem `metanorma-#{stdtype}` loaded.", :info)
  rescue LoadError
    Util.log("[metanorma] Error: loading gem `metanorma-#{stdtype}` failed. Exiting.", :error)
    return false
  end
  unless @registry.supported_backends.include? stdtype
    Util.log("[metanorma] Error: The `metanorma-#{stdtype}` gem still doesn't support `#{stdtype}`. Exiting.", :error)
    return false
  end
  true
end