Module: Lutaml::Model::Toml

Defined in:
lib/lutaml/model/toml.rb

Constant Summary collapse

Document =
::Lutaml::Toml::Adapter::Document
Mapping =
::Lutaml::Toml::Adapter::Mapping
MappingRule =
::Lutaml::Toml::Adapter::MappingRule
Transform =
::Lutaml::Toml::Adapter::Transform

Class Method Summary collapse

Class Method Details

.detect_toml_adapterObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/lutaml/model/toml.rb', line 19

def self.detect_toml_adapter
  return nil if Lutaml::Model.opal?

  # teptris 0.2.12+ parses ~3x and dumps ~8x faster than tomlib
  # and ships prebuilts for every platform (mingw-ucrt restored
  # in 0.2.4+) — native TOML on Windows retires the tomlib
  # segfault workaround (previously pure-Ruby toml-rb only).
  return :teptris if Lutaml::Model::Utils.safe_load("teptris", :Teptris)

  # tomlib segfaults on Windows when parsing invalid TOML
  if !Lutaml::Model::RuntimeCompatibility.windows? &&
      Lutaml::Model::Utils.safe_load("tomlib", :Tomlib)
    return :tomlib
  end

  return :toml_rb if Lutaml::Model::Utils.safe_load("toml-rb", :TomlRb)

  nil
end