Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

toml_empty

Package Overview
Dependencies
Maintainers
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

toml_empty

  • 0.3.0
  • Rubygems
  • Socket score

Version published
Maintainers
3
Created
Source

Fork

This repo is a fork of toml.

The main modification is that it allows empty group to be generated (in toml gem, they are read, but not saved)

If you have a group with no value like this:

[group.with.no.value]

[otherkey]
key = value

It will be managed correctly (load and save)

TOML

A Ruby parser for TOML, built on parslet.

This is far superior to YAML and JSON because it doesn't suck. Really it doesn't.

Gem Version

Usage

Install this library:

gem "toml_empty", "~> 0.3.0"

It's simple, really.

content = <<-TOML

# Hello, this is an example.
[things]
other = "things"
what = 900000

TOML

parser = TOML::Parser.new(content).parsed
# => { "things" => { "other" => "things", "what" => 900000 } }

You can also use the same API as YAML if you'd like:

TOML.load("thing = 9")
# => {"thing" => 9}

TOML.load_file("my_file.toml")
# => {"whatever" => "keys"}

In case a syntax error occurs, the parser will raise a Parslet::ParseFailed exception.

There's also a beta feature for generating a TOML file from a Ruby hash. Please note this will likely not give beautiful output right now.

hash = {
  "integer" => 1,
  "float" => 3.14159,
  "true" => true,
  "false" => false,
  "string" => "hi",
  "array" => [[1], [2], [3]],
  "key" => {
    "group" => {
      "value" => "lol"
    }
  }
}
doc = TOML::Generator.new(hash).body
# doc will be a string containing a proper TOML document.

Contributors

Written by Jeremy McAnally (@jm) and Dirk Gadsden (@dirk) based on TOML from Tom Preston-Werner (@mojombo).

FAQs

Package last updated on 27 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc