Module: Metanorma::Compile::Flavor

Included in:
Metanorma::Compile
Defined in:
lib/metanorma/compile/flavor.rb

Instance Method Summary collapse

Instance Method Details

#load_flavor(stdtype) ⇒ void

This method returns an undefined value.

Load the flavor gem for the given standard type

Parameters:

  • stdtype (Symbol)

    the standard type



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/metanorma/compile/flavor.rb', line 9

def load_flavor(stdtype)
  new_stdtype = taste2flavor(stdtype)
  flavor = stdtype2flavor_gem(new_stdtype)
  @registry.supported_backends.include? new_stdtype or
    Util.log("[metanorma] Info: Loading `#{flavor}` gem "\
             "for standard type `#{stdtype}`.", :info)
  require_flavor(flavor)
  @registry.supported_backends.include? new_stdtype or
    Util.log("[metanorma] Error: The `#{flavor}` gem does not "\
             "support the standard type #{stdtype}. Exiting.", :fatal)
end

#stdtype2flavor_gem(stdtype) ⇒ String

Convert the standard type to the flavor gem name

Parameters:

  • stdtype (Symbol)

    the standard type

Returns:

  • (String)

    the flavor gem name



31
32
33
# File 'lib/metanorma/compile/flavor.rb', line 31

def stdtype2flavor_gem(stdtype)
  "metanorma-#{stdtype}"
end

#taste2flavor(stdtype) ⇒ Object



21
22
23
24
25
26
# File 'lib/metanorma/compile/flavor.rb', line 21

def taste2flavor(stdtype)
  stdtype = stdtype.to_sym
  tastes = Metanorma::TasteRegister.instance.aliases
  tastes[stdtype] and stdtype = tastes[stdtype].to_sym
  stdtype
end