<commit_before>![Ptolemy](https://raw.github.com/natansh/ptolemy/master/ptolemy.jpg)

[![Build Status](https://travis-ci.org/natansh/ptolemy.png?branch=master)](https://travis-ci.org/natansh/ptolemy)
[![Gem Version](https://badge.fury.io/rb/ptolemy.png)](http://badge.fury.io/rb/ptolemy)

=======

Ptolemy is a simple TOML parser.<commit_msg>Expanded README.<commit_after>![Ptolemy](https://raw.github.com/natansh/ptolemy/master/ptolemy.jpg)

[![Build Status](https://travis-ci.org/natansh/ptolemy.png?branch=master)](https://travis-ci.org/natansh/ptolemy)
[![Gem Version](https://badge.fury.io/rb/ptolemy.png)](http://badge.fury.io/rb/ptolemy)

===
Ptolemy is a simple TOML parser for Ruby, based on Treetop. It is useful for parsing the [TOML Format](https://github.com/mojombo/toml).

Ptolemy currently supports version [0.1.0](https://github.com/mojombo/toml/blob/master/versions/toml-v0.1.0.md) of TOML.

Installation
---

# Bundler
Add this to your `Gemfile`

    gem 'ptolemy', '~> 0.0.2'

And then run

    bundle install

# Manual
You can install it manually using

    gem install ptolemy

Usage
---
* `Ptolemy.parse` can parse a string in TOML format.

  ```ruby
  data = <<END
  # This is an example TOML input
  [group]
  string = "hello"
  integer = 0
  END

  Ptolemy.parse(data)

  # => {"group"=>{"string"=>"hello", "integer"=>0}}

  ```
* `Ptolemy.parse_file` can read from a UTF-8 encoded file directly.

  ```ruby
  filename = 'example.toml'
  Ptolemy.parse_file(filename)
  ```

Test Suite
---
Ptolemy has a fairly exhaustive test suite built on `rspec` and can
successfully parse the specification file and hard example given
in the TOML specification.

You can run the test suite by running `rake`.
{'fraction_non_alphanumeric': 0.15979081929110983, 'fraction_numerical': 0.006972690296339338, 'mean_word_length': 4.079646017699115, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4164969', 'n_tokens_mistral': 668, 'n_tokens_neox': 655, 'n_words': 143}