toml 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -6,6 +6,12 @@ This is far superior to YAML and JSON because it doesn't suck. Really it doesn'
6
6
 
7
7
  ## Usage
8
8
 
9
+ Add to your Gemfile:
10
+
11
+ ```ruby
12
+ gem "toml", "~> 0.0.3"
13
+ ```
14
+
9
15
  It's simple, really.
10
16
 
11
17
  ```ruby
@@ -32,6 +38,26 @@ TOML.load_file("my_file.toml")
32
38
  # => {"whatever" => "keys"}
33
39
  ```
34
40
 
41
+ 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.
42
+
43
+ ```ruby
44
+ hash = {
45
+ "integer" => 1,
46
+ "float" => 3.14159,
47
+ "true" => true,
48
+ "false" => false,
49
+ "string" => "hi",
50
+ "array" => [[1], [2], [3]],
51
+ "key" => {
52
+ "group" => {
53
+ "value" => "lol"
54
+ }
55
+ }
56
+ }
57
+ doc = TOML::Generator.new(hash).body
58
+ # doc will be a string containing a proper TOML document.
59
+ ```
60
+
35
61
  ## Contributors
36
62
 
37
63
  Written by Jeremy McAnally (@jm) and Dirk Gadsden (@dirk) based on TOML from Tom Preston-Werner (@mojombo).
@@ -14,7 +14,7 @@ require 'toml/generator'
14
14
  # require 'toml/monkey_patch
15
15
 
16
16
  module TOML
17
- VERSION = '0.0.3'
17
+ VERSION = '0.0.4'
18
18
 
19
19
  def self.load(content)
20
20
  Parser.new(content).parsed
@@ -42,6 +42,10 @@ module TOML
42
42
  rule(:string => simple(:s)) {
43
43
  Transformer.parse_string(s.to_s)
44
44
  }
45
+ rule(:string => sequence(:s)) {
46
+ raise "Unexpected string-sequence: #{s.inspect}" unless s.empty?
47
+ ""
48
+ }
45
49
  rule(:datetime => simple(:d)) { DateTime.iso8601(d) }
46
50
  rule(:true => simple(:b)) { true }
47
51
  rule(:false => simple(:b)) { false }
@@ -7,6 +7,7 @@ false = false
7
7
  [strings]
8
8
  # String
9
9
  string = "string\n\t\"string"
10
+ empty = ""
10
11
 
11
12
  [ints]
12
13
  simple = 42
@@ -10,9 +10,10 @@ class TestParser < MiniTest::Unit::TestCase
10
10
  filepath = File.join(File.dirname(__FILE__), 'spec.toml')
11
11
  @doc = TOML::Parser.new(File.read(filepath)).parsed
12
12
  end
13
-
13
+
14
14
  def test_string
15
15
  assert_equal "string\n\t\"string", @doc["strings"]["string"]
16
+ assert_equal "", @doc["strings"]["empty"]
16
17
  end
17
18
 
18
19
  def test_integer
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'toml'
16
- s.version = '0.0.3'
17
- s.date = '2013-03-06'
16
+ s.version = '0.0.4'
17
+ s.date = '2013-03-28'
18
18
 
19
19
  ## Make sure your summary is short. The description may be as long
20
20
  ## as you like.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-03-06 00:00:00.000000000 Z
13
+ date: 2013-03-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: parslet