tomlrb 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +14 -0
- data/bin/console +11 -0
- data/bin/setup +6 -0
- data/lib/tomlrb.rb +15 -0
- data/lib/tomlrb/generated_parser.rb +250 -0
- data/lib/tomlrb/handler.rb +42 -0
- data/lib/tomlrb/parser.rb +19 -0
- data/lib/tomlrb/parser.y +57 -0
- data/lib/tomlrb/scanner.rb +35 -0
- data/lib/tomlrb/version.rb +3 -0
- data/sample.toml +47 -0
- data/tomlrb.gemspec +27 -0
- metadata +131 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 964937589a25e9d489b243ba7f3edcab01457109
|
4
|
+
data.tar.gz: d08b833542655d0a081ef58d0dc806d1de26d0c8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cfc1badba22d110b9f11d03900bff83b0e65adbba81c8242d714a26649caefdae7719fe10e086f7aa7c96283f493a56675363678c94d278bef8547b3fd23c70a
|
7
|
+
data.tar.gz: 4e8b36708b34f8781aab4d70aab87d4642ae553b6e430b7f35ac193b9cdc2a409e2f83d5bf45e6a99634c0cadfb3c02bb1d5c5c1d1180c2af337fccc7436ef14
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Francois Bernier
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Tomlrb
|
2
|
+
|
3
|
+
A racc based [toml](https://github.com/toml-lang/toml) parser. It's still a work in progress so it doesn't support the full spec yet.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'tomlrb'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install tomlrb
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
Tomlrb.parse("[toml]\na = [\"array\", 123]")
|
25
|
+
```
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
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.
|
30
|
+
|
31
|
+
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).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
1. Fork it ( https://github.com/[my-github-username]/tomlrb/fork )
|
36
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require 'rake/testtask'
|
3
|
+
|
4
|
+
Rake::TestTask.new do |t|
|
5
|
+
t.libs << "test"
|
6
|
+
t.test_files = FileList['test/test*.rb']
|
7
|
+
t.verbose = true
|
8
|
+
end
|
9
|
+
|
10
|
+
task default: [:test]
|
11
|
+
|
12
|
+
task :compile do
|
13
|
+
sh 'racc lib/tomlrb/parser.y -o lib/tomlrb/generated_parser.rb'
|
14
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "tomlrb"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
require "pry"
|
11
|
+
Pry.start
|
data/bin/setup
ADDED
data/lib/tomlrb.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require "tomlrb/version"
|
2
|
+
require "tomlrb/generated_parser"
|
3
|
+
require "tomlrb/scanner"
|
4
|
+
require "tomlrb/parser"
|
5
|
+
require "tomlrb/handler"
|
6
|
+
|
7
|
+
module Tomlrb
|
8
|
+
def self.parse(string_or_io)
|
9
|
+
io = string_or_io.is_a?(String) ? StringIO.new(string_or_io) : string_or_io
|
10
|
+
scanner = Scanner.new(io)
|
11
|
+
parser = Parser.new(scanner)
|
12
|
+
handler = parser.parse
|
13
|
+
handler.result
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,250 @@
|
|
1
|
+
#
|
2
|
+
# DO NOT MODIFY!!!!
|
3
|
+
# This file is automatically generated by Racc 1.4.12
|
4
|
+
# from Racc grammer file "".
|
5
|
+
#
|
6
|
+
|
7
|
+
require 'racc/parser.rb'
|
8
|
+
module Tomlrb
|
9
|
+
class GeneratedParser < Racc::Parser
|
10
|
+
##### State transition tables begin ###
|
11
|
+
|
12
|
+
racc_action_table = [
|
13
|
+
8, 7, 7, 30, 31, 7, 11, 5, 5, 25,
|
14
|
+
24, 21, 22, 23, 15, 27, 25, 24, 21, 22,
|
15
|
+
23, 15, 27, 25, 24, 21, 22, 23, 15, 12,
|
16
|
+
13 ]
|
17
|
+
|
18
|
+
racc_action_check = [
|
19
|
+
1, 0, 1, 28, 28, 5, 6, 0, 1, 14,
|
20
|
+
14, 14, 14, 14, 14, 14, 31, 31, 31, 31,
|
21
|
+
31, 31, 31, 11, 11, 11, 11, 11, 11, 8,
|
22
|
+
10 ]
|
23
|
+
|
24
|
+
racc_action_pointer = [
|
25
|
+
-1, 0, nil, nil, nil, 3, -5, nil, 29, nil,
|
26
|
+
21, 20, nil, nil, 6, nil, nil, nil, nil, nil,
|
27
|
+
nil, nil, nil, nil, nil, nil, nil, nil, -6, nil,
|
28
|
+
nil, 13, nil ]
|
29
|
+
|
30
|
+
racc_action_default = [
|
31
|
+
-25, -25, -2, -3, -4, -25, -25, -24, -25, -1,
|
32
|
+
-25, -18, 33, -5, -18, -11, -13, -14, -15, -16,
|
33
|
+
-17, -19, -20, -21, -22, -23, -6, -7, -25, -8,
|
34
|
+
-9, -18, -10 ]
|
35
|
+
|
36
|
+
racc_goto_table = [
|
37
|
+
26, 2, 9, 1, 10, 16, 29, nil, nil, nil,
|
38
|
+
nil, nil, nil, nil, nil, nil, nil, 32 ]
|
39
|
+
|
40
|
+
racc_goto_check = [
|
41
|
+
8, 2, 2, 1, 5, 9, 10, nil, nil, nil,
|
42
|
+
nil, nil, nil, nil, nil, nil, nil, 8 ]
|
43
|
+
|
44
|
+
racc_goto_pointer = [
|
45
|
+
nil, 3, 1, nil, nil, -1, nil, nil, -14, -6,
|
46
|
+
-22, nil, nil, nil, nil ]
|
47
|
+
|
48
|
+
racc_goto_default = [
|
49
|
+
nil, nil, nil, 3, 4, 6, 18, 14, nil, 28,
|
50
|
+
nil, nil, 17, 19, 20 ]
|
51
|
+
|
52
|
+
racc_reduce_table = [
|
53
|
+
0, 0, :racc_error,
|
54
|
+
2, 13, :_reduce_none,
|
55
|
+
1, 13, :_reduce_none,
|
56
|
+
1, 14, :_reduce_none,
|
57
|
+
1, 14, :_reduce_none,
|
58
|
+
3, 15, :_reduce_5,
|
59
|
+
2, 18, :_reduce_none,
|
60
|
+
1, 20, :_reduce_7,
|
61
|
+
2, 20, :_reduce_none,
|
62
|
+
1, 22, :_reduce_9,
|
63
|
+
2, 22, :_reduce_none,
|
64
|
+
1, 19, :_reduce_11,
|
65
|
+
1, 23, :_reduce_none,
|
66
|
+
3, 16, :_reduce_13,
|
67
|
+
1, 21, :_reduce_14,
|
68
|
+
1, 21, :_reduce_none,
|
69
|
+
1, 24, :_reduce_none,
|
70
|
+
1, 24, :_reduce_none,
|
71
|
+
0, 26, :_reduce_none,
|
72
|
+
1, 26, :_reduce_19,
|
73
|
+
1, 26, :_reduce_20,
|
74
|
+
1, 26, :_reduce_21,
|
75
|
+
1, 26, :_reduce_none,
|
76
|
+
1, 25, :_reduce_none,
|
77
|
+
1, 17, :_reduce_none ]
|
78
|
+
|
79
|
+
racc_reduce_n = 25
|
80
|
+
|
81
|
+
racc_shift_n = 33
|
82
|
+
|
83
|
+
racc_token_table = {
|
84
|
+
false => 0,
|
85
|
+
:error => 1,
|
86
|
+
:IDENTIFIER => 2,
|
87
|
+
:STRING => 3,
|
88
|
+
:DATETIME => 4,
|
89
|
+
:NUMBER => 5,
|
90
|
+
:TRUE => 6,
|
91
|
+
:FALSE => 7,
|
92
|
+
"[" => 8,
|
93
|
+
"]" => 9,
|
94
|
+
"," => 10,
|
95
|
+
"=" => 11 }
|
96
|
+
|
97
|
+
racc_nt_base = 12
|
98
|
+
|
99
|
+
racc_use_result_var = true
|
100
|
+
|
101
|
+
Racc_arg = [
|
102
|
+
racc_action_table,
|
103
|
+
racc_action_check,
|
104
|
+
racc_action_default,
|
105
|
+
racc_action_pointer,
|
106
|
+
racc_goto_table,
|
107
|
+
racc_goto_check,
|
108
|
+
racc_goto_default,
|
109
|
+
racc_goto_pointer,
|
110
|
+
racc_nt_base,
|
111
|
+
racc_reduce_table,
|
112
|
+
racc_token_table,
|
113
|
+
racc_shift_n,
|
114
|
+
racc_reduce_n,
|
115
|
+
racc_use_result_var ]
|
116
|
+
|
117
|
+
Racc_token_to_s_table = [
|
118
|
+
"$end",
|
119
|
+
"error",
|
120
|
+
"IDENTIFIER",
|
121
|
+
"STRING",
|
122
|
+
"DATETIME",
|
123
|
+
"NUMBER",
|
124
|
+
"TRUE",
|
125
|
+
"FALSE",
|
126
|
+
"\"[\"",
|
127
|
+
"\"]\"",
|
128
|
+
"\",\"",
|
129
|
+
"\"=\"",
|
130
|
+
"$start",
|
131
|
+
"expressions",
|
132
|
+
"expression",
|
133
|
+
"table",
|
134
|
+
"assignment",
|
135
|
+
"identifier",
|
136
|
+
"array",
|
137
|
+
"start_array",
|
138
|
+
"array_continued",
|
139
|
+
"value",
|
140
|
+
"array_next",
|
141
|
+
"end_array",
|
142
|
+
"scalar",
|
143
|
+
"string",
|
144
|
+
"literal" ]
|
145
|
+
|
146
|
+
Racc_debug_parser = false
|
147
|
+
|
148
|
+
##### State transition tables end #####
|
149
|
+
|
150
|
+
# reduce 0 omitted
|
151
|
+
|
152
|
+
# reduce 1 omitted
|
153
|
+
|
154
|
+
# reduce 2 omitted
|
155
|
+
|
156
|
+
# reduce 3 omitted
|
157
|
+
|
158
|
+
# reduce 4 omitted
|
159
|
+
|
160
|
+
module_eval(<<'.,.,', 'parser.y', 14)
|
161
|
+
def _reduce_5(val, _values, result)
|
162
|
+
@handler.set_context(val[1])
|
163
|
+
result
|
164
|
+
end
|
165
|
+
.,.,
|
166
|
+
|
167
|
+
# reduce 6 omitted
|
168
|
+
|
169
|
+
module_eval(<<'.,.,', 'parser.y', 21)
|
170
|
+
def _reduce_7(val, _values, result)
|
171
|
+
@handler.end_array
|
172
|
+
result
|
173
|
+
end
|
174
|
+
.,.,
|
175
|
+
|
176
|
+
# reduce 8 omitted
|
177
|
+
|
178
|
+
module_eval(<<'.,.,', 'parser.y', 23)
|
179
|
+
def _reduce_9(val, _values, result)
|
180
|
+
@handler.end_array
|
181
|
+
result
|
182
|
+
end
|
183
|
+
.,.,
|
184
|
+
|
185
|
+
# reduce 10 omitted
|
186
|
+
|
187
|
+
module_eval(<<'.,.,', 'parser.y', 26)
|
188
|
+
def _reduce_11(val, _values, result)
|
189
|
+
@handler.start_array
|
190
|
+
result
|
191
|
+
end
|
192
|
+
.,.,
|
193
|
+
|
194
|
+
# reduce 12 omitted
|
195
|
+
|
196
|
+
module_eval(<<'.,.,', 'parser.y', 30)
|
197
|
+
def _reduce_13(val, _values, result)
|
198
|
+
@handler.assign(val[0])
|
199
|
+
result
|
200
|
+
end
|
201
|
+
.,.,
|
202
|
+
|
203
|
+
module_eval(<<'.,.,', 'parser.y', 34)
|
204
|
+
def _reduce_14(val, _values, result)
|
205
|
+
@handler.push(val[0])
|
206
|
+
result
|
207
|
+
end
|
208
|
+
.,.,
|
209
|
+
|
210
|
+
# reduce 15 omitted
|
211
|
+
|
212
|
+
# reduce 16 omitted
|
213
|
+
|
214
|
+
# reduce 17 omitted
|
215
|
+
|
216
|
+
# reduce 18 omitted
|
217
|
+
|
218
|
+
module_eval(<<'.,.,', 'parser.y', 44)
|
219
|
+
def _reduce_19(val, _values, result)
|
220
|
+
n = val[0]; result = n.count('.') > 0 ? n.to_f : n.to_i
|
221
|
+
result
|
222
|
+
end
|
223
|
+
.,.,
|
224
|
+
|
225
|
+
module_eval(<<'.,.,', 'parser.y', 45)
|
226
|
+
def _reduce_20(val, _values, result)
|
227
|
+
result = true
|
228
|
+
result
|
229
|
+
end
|
230
|
+
.,.,
|
231
|
+
|
232
|
+
module_eval(<<'.,.,', 'parser.y', 46)
|
233
|
+
def _reduce_21(val, _values, result)
|
234
|
+
result = false
|
235
|
+
result
|
236
|
+
end
|
237
|
+
.,.,
|
238
|
+
|
239
|
+
# reduce 22 omitted
|
240
|
+
|
241
|
+
# reduce 23 omitted
|
242
|
+
|
243
|
+
# reduce 24 omitted
|
244
|
+
|
245
|
+
def _reduce_none(val, _values, result)
|
246
|
+
val[0]
|
247
|
+
end
|
248
|
+
|
249
|
+
end # class GeneratedParser
|
250
|
+
end # module Tomlrb
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Tomlrb
|
2
|
+
class Handler
|
3
|
+
attr_reader :stack
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@output = Hash.new {|h, k| h[k] = {} }
|
7
|
+
@current = @output
|
8
|
+
@stack = []
|
9
|
+
end
|
10
|
+
|
11
|
+
def set_context(name)
|
12
|
+
@current = @output[name]
|
13
|
+
@context = name
|
14
|
+
end
|
15
|
+
|
16
|
+
def assign(k)
|
17
|
+
@current[k] = @stack.pop
|
18
|
+
end
|
19
|
+
|
20
|
+
def start_array
|
21
|
+
push [:array]
|
22
|
+
end
|
23
|
+
|
24
|
+
def end_array
|
25
|
+
array = []
|
26
|
+
while (value = @stack.pop) != [:array]
|
27
|
+
raise if value.nil?
|
28
|
+
array.unshift(value)
|
29
|
+
end
|
30
|
+
push(array)
|
31
|
+
end
|
32
|
+
|
33
|
+
def push(o)
|
34
|
+
@stack << o
|
35
|
+
end
|
36
|
+
|
37
|
+
def result
|
38
|
+
@output
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Tomlrb::Parser < Tomlrb::GeneratedParser
|
2
|
+
attr_reader :handler
|
3
|
+
|
4
|
+
def initialize(tokenizer, handler = Tomlrb::Handler.new)
|
5
|
+
@tokenizer = tokenizer
|
6
|
+
@handler = handler
|
7
|
+
@yydebug = true
|
8
|
+
super()
|
9
|
+
end
|
10
|
+
|
11
|
+
def next_token
|
12
|
+
@tokenizer.next_token
|
13
|
+
end
|
14
|
+
|
15
|
+
def parse
|
16
|
+
do_parse
|
17
|
+
handler
|
18
|
+
end
|
19
|
+
end
|
data/lib/tomlrb/parser.y
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
class Tomlrb::GeneratedParser
|
2
|
+
token IDENTIFIER STRING DATETIME NUMBER TRUE FALSE
|
3
|
+
rule
|
4
|
+
expressions
|
5
|
+
: expressions expression
|
6
|
+
| expression
|
7
|
+
;
|
8
|
+
|
9
|
+
expression
|
10
|
+
: table
|
11
|
+
| assignment
|
12
|
+
;
|
13
|
+
|
14
|
+
table
|
15
|
+
: '[' identifier ']' { @handler.set_context(val[1]) }
|
16
|
+
;
|
17
|
+
|
18
|
+
array
|
19
|
+
: start_array array_continued
|
20
|
+
;
|
21
|
+
|
22
|
+
array_continued : ']' { @handler.end_array }
|
23
|
+
| value array_next;
|
24
|
+
array_next : ']' { @handler.end_array }
|
25
|
+
| ',' array_continued;
|
26
|
+
|
27
|
+
start_array : '[' { @handler.start_array }
|
28
|
+
end_array : ']'
|
29
|
+
|
30
|
+
assignment
|
31
|
+
: identifier '=' value { @handler.assign(val[0]) }
|
32
|
+
;
|
33
|
+
|
34
|
+
value
|
35
|
+
: scalar { @handler.push(val[0]) }
|
36
|
+
| array
|
37
|
+
;
|
38
|
+
|
39
|
+
scalar
|
40
|
+
: string
|
41
|
+
| literal
|
42
|
+
;
|
43
|
+
|
44
|
+
literal
|
45
|
+
| NUMBER { n = val[0]; result = n.count('.') > 0 ? n.to_f : n.to_i }
|
46
|
+
| TRUE { result = true }
|
47
|
+
| FALSE { result = false }
|
48
|
+
| DATETIME
|
49
|
+
;
|
50
|
+
|
51
|
+
string
|
52
|
+
: STRING
|
53
|
+
;
|
54
|
+
|
55
|
+
identifier:
|
56
|
+
: IDENTIFIER
|
57
|
+
;
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'strscan'
|
2
|
+
|
3
|
+
module Tomlrb
|
4
|
+
class Scanner
|
5
|
+
IDENTIFIER = /\w+/
|
6
|
+
SPACES = /\A\s+/
|
7
|
+
STRING_SINGLE = /"[^"]*"/
|
8
|
+
STRING_MULTI = /"[^"]*"/
|
9
|
+
DATETIME = /(-?\d{4})-(\d{2})-(\d{2})(?:t|\s)(\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?(z|[-+]\d{2}:\d{2})/i
|
10
|
+
NUMBER = /[0-9]+(?:\.[0-9]+)?/
|
11
|
+
TRUE = /true/
|
12
|
+
FALSE = /false/
|
13
|
+
|
14
|
+
def initialize(io)
|
15
|
+
@ss = StringScanner.new(io.read)
|
16
|
+
end
|
17
|
+
|
18
|
+
def next_token
|
19
|
+
return if @ss.eos?
|
20
|
+
|
21
|
+
case
|
22
|
+
when @ss.scan(SPACES) then next_token
|
23
|
+
when text = @ss.scan(DATETIME) then [:DATETIME, text]
|
24
|
+
when text = @ss.scan(STRING_SINGLE) then [:STRING, text[1..-2]]
|
25
|
+
when text = @ss.scan(NUMBER) then [:NUMBER, text]
|
26
|
+
when text = @ss.scan(TRUE) then [:TRUE, text]
|
27
|
+
when text = @ss.scan(FALSE) then [:FALSE, text]
|
28
|
+
when text = @ss.scan(IDENTIFIER) then [:IDENTIFIER, text]
|
29
|
+
else
|
30
|
+
x = @ss.getch
|
31
|
+
[x, x]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/sample.toml
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# This is a TOML document. Boom.
|
2
|
+
|
3
|
+
title = "TOML Example"
|
4
|
+
|
5
|
+
[owner]
|
6
|
+
name = "Tom Preston-Werner"
|
7
|
+
organization = "GitHub"
|
8
|
+
bio = "GitHub Cofounder & CEO\nLikes tater tots and beer."
|
9
|
+
dob = 1979-05-27T07:32:00Z # First class dates? Why not?
|
10
|
+
|
11
|
+
[database]
|
12
|
+
server = "192.168.1.1"
|
13
|
+
ports = [ 8001, 8001, 8002 ]
|
14
|
+
connection_max = 5000
|
15
|
+
enabled = true
|
16
|
+
|
17
|
+
[servers]
|
18
|
+
|
19
|
+
# You can indent as you please. Tabs or spaces. TOML don't care.
|
20
|
+
[servers.alpha]
|
21
|
+
ip = "10.0.0.1"
|
22
|
+
dc = "eqdc10"
|
23
|
+
|
24
|
+
[servers.beta]
|
25
|
+
ip = "10.0.0.2"
|
26
|
+
dc = "eqdc10"
|
27
|
+
country = "中国" # This should be parsed as UTF-8
|
28
|
+
|
29
|
+
[clients]
|
30
|
+
data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it
|
31
|
+
|
32
|
+
# Line breaks are OK when inside arrays
|
33
|
+
hosts = [
|
34
|
+
"alpha",
|
35
|
+
"omega"
|
36
|
+
]
|
37
|
+
|
38
|
+
# Products
|
39
|
+
|
40
|
+
[[products]]
|
41
|
+
name = "Hammer"
|
42
|
+
sku = 738594937
|
43
|
+
|
44
|
+
[[products]]
|
45
|
+
name = "Nail"
|
46
|
+
sku = 284758393
|
47
|
+
color = "gray"
|
data/tomlrb.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'tomlrb/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "tomlrb"
|
8
|
+
spec.version = Tomlrb::VERSION
|
9
|
+
spec.authors = ["Francois Bernier"]
|
10
|
+
spec.email = ["frankbernier@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{A racc based toml parser}
|
13
|
+
spec.description = %q{A racc based toml parser}
|
14
|
+
spec.homepage = ""
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "pry"
|
25
|
+
spec.add_development_dependency "pry-byebug"
|
26
|
+
spec.add_development_dependency "racc"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tomlrb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Francois Bernier
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.9'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry-byebug
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: racc
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: A racc based toml parser
|
84
|
+
email:
|
85
|
+
- frankbernier@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".travis.yml"
|
92
|
+
- Gemfile
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- bin/console
|
97
|
+
- bin/setup
|
98
|
+
- lib/tomlrb.rb
|
99
|
+
- lib/tomlrb/generated_parser.rb
|
100
|
+
- lib/tomlrb/handler.rb
|
101
|
+
- lib/tomlrb/parser.rb
|
102
|
+
- lib/tomlrb/parser.y
|
103
|
+
- lib/tomlrb/scanner.rb
|
104
|
+
- lib/tomlrb/version.rb
|
105
|
+
- sample.toml
|
106
|
+
- tomlrb.gemspec
|
107
|
+
homepage: ''
|
108
|
+
licenses:
|
109
|
+
- MIT
|
110
|
+
metadata: {}
|
111
|
+
post_install_message:
|
112
|
+
rdoc_options: []
|
113
|
+
require_paths:
|
114
|
+
- lib
|
115
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
requirements: []
|
126
|
+
rubyforge_project:
|
127
|
+
rubygems_version: 2.4.5
|
128
|
+
signing_key:
|
129
|
+
specification_version: 4
|
130
|
+
summary: A racc based toml parser
|
131
|
+
test_files: []
|