module TomlRB

def self.dump(hash)

Returns a TomlRB string representing the hash.


# => "title = \"wow!\"\n[awesome]\nothers = false\nyou = true\n"
TomlRB.dump(hash)

}
}
"others"=>false
"you"=>true,
"awesome"=> {
"title"=>"wow!",
hash = {

# => "simple = true\n"
TomlRB.dump(title: 'TomlRB dump')

Examples


hash - Ruby Hash to be dumped into *TomlRB*

Public: Returns a *TomlRB* string from a Ruby Hash.
def self.dump(hash)
  Dumper.new(hash).toml_str
end

def self.load_file(path, symbolize_keys: false)

Raises Errno::EACCES if the file cannot be accessed.
Raises Errno::ENOENT if the file cannot be found.
Raises ParseError if the content has invalid TomlRB.
Raises ValueOverwriteError if a key is overwritten.
Returns a Ruby hash representation of the content.


# => {group: {}}
TomlRB.load_file('/tmp/simple.toml', symbolize_keys: true)

# => {"group"=>{}}
TomlRB.load_file('/tmp/simple.toml')

Examples


:symbolize_keys - true|false (optional).
path - TomlRB File path

Public: Returns a hash from a *TomlRB* file.
def self.load_file(path, symbolize_keys: false)
  TomlRB.parse(File.read(path), symbolize_keys: symbolize_keys)
end

def self.parse(content, symbolize_keys: false)

Raises ParseError if the content has invalid TomlRB.
Raises ValueOverwriteError if a key is overwritten.
Returns a Ruby hash representation of the content according to TomlRB spec.


# => {title: "TomlRB parser"}
TomlRB.parse('title = "TomlRB parser"', symbolize_keys: true)

# => {group: {}}
TomlRB.parse('[group]', symbolize_keys: true)

# => {"title"=>"TomlRB parser"}
TomlRB.parse('title = "TomlRB parser"')

# => {"group"=>{}}
TomlRB.parse('[group]')

Examples


:symbolize_keys - true | false (default: false).
content - TomlRB string to be parsed.

Public: Returns a hash from *TomlRB* content.
def self.parse(content, symbolize_keys: false)
  Parser.new(content, symbolize_keys: symbolize_keys).hash
end