Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fbernier/tomlrb
A Racc based TOML parser
https://github.com/fbernier/tomlrb
lalr1 parser racc ruby toml
Last synced: 5 days ago
JSON representation
A Racc based TOML parser
- Host: GitHub
- URL: https://github.com/fbernier/tomlrb
- Owner: fbernier
- License: mit
- Created: 2015-04-09T01:03:13.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-12-16T02:54:15.000Z (18 days ago)
- Last Synced: 2024-12-24T10:00:26.362Z (10 days ago)
- Topics: lalr1, parser, racc, ruby, toml
- Language: Ruby
- Homepage:
- Size: 237 KB
- Stars: 68
- Watchers: 4
- Forks: 17
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Tomlrb
[![Code Climate](https://codeclimate.com/github/fbernier/tomlrb/badges/gpa.svg)](https://codeclimate.com/github/fbernier/tomlrb)
[![Gem Version](https://badge.fury.io/rb/tomlrb.svg)](http://badge.fury.io/rb/tomlrb)
[![Build status](https://github.com/fbernier/tomlrb/workflows/ci/badge.svg)](https://github.com/fbernier/tomlrb/actions)
A Racc based [TOML](https://github.com/toml-lang/toml) Ruby parser supporting the 1.0.0 version of the spec.## TODO
* Dumper
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'tomlrb'
```And then execute:
$ bundle
Or install it yourself as:
$ gem install tomlrb
## Usage
```ruby
Tomlrb.parse("[toml]\na = [\"array\", 123]")
```or
```ruby
Tomlrb.load_file('my_file', symbolize_keys: true)
```## Benchmark
You can run the benchmark against the only other v0.5.0 compliant parser to my knowledge with `ruby benchmarks/bench.rb`.
Here are the results on my machine:
```
Warming up --------------------------------------
emancu/toml-rb 1.000 i/100ms
fbernier/tomlrb 33.000 i/100ms
Calculating -------------------------------------
emancu/toml-rb 15.597 (± 6.4%) i/s - 78.000 in 5.020321s
fbernier/tomlrb 348.307 (± 5.2%) i/s - 1.749k in 5.034878sComparison:
fbernier/tomlrb: 348.3 i/s
emancu/toml-rb: 15.6 i/s - 22.33x (± 0.00) slower```
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
Do not forget to regenerate the parser when you modify rules in the `parser.y` file using `rake compile`.
Run the tests using `rake test`.
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
## Contributing
1. Fork it ( https://github.com/[my-github-username]/tomlrb/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request## Thanks
Thanks to [@jpbougie](https://github.com/jpbougie) for the crash course on the Chomsky hierarchy and general tips.