tomlrb 1.0.3 → 1.1.0
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.
- checksums.yaml +4 -4
- data/README.md +5 -1
- data/lib/tomlrb/generated_parser.rb +1 -1
- data/lib/tomlrb/parser.y +1 -1
- data/lib/tomlrb/scanner.rb +7 -2
- data/lib/tomlrb/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86c658a15f370e29296822096361be88b381124e
|
4
|
+
data.tar.gz: bcdc56e5d754afb1b3ee02d01737a8ecf0744435
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbea9023660e2807b5d90088f31027e2e3454fb07beb0893decbb3b81e6c4a65811c828cc0788c6bd7c613d7f82982803ec76e9cdd0f4a5d800e540d9cbfb752
|
7
|
+
data.tar.gz: 671eabff02c17040c061e12322281180c7ced933773f855534f03997e78e30ef1c91dfbcddb3e21d2cfab293f8de854761e61d92caf898d710799e3339709c8b
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[](https://codeclimate.com/github/fbernier/tomlrb) [](https://travis-ci.org/fbernier/tomlrb) [](http://badge.fury.io/rb/tomlrb)
|
4
4
|
|
5
|
-
A Racc based [TOML](https://github.com/toml-lang/toml) parser supporting the 0.4.0 version of the spec.
|
5
|
+
A Racc based [TOML](https://github.com/toml-lang/toml) Ruby parser supporting the 0.4.0 version of the spec.
|
6
6
|
|
7
7
|
|
8
8
|
## TODO
|
@@ -43,6 +43,10 @@ Tomlrb.load_file('my_file', symbolize_keys: true)
|
|
43
43
|
|
44
44
|
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.
|
45
45
|
|
46
|
+
Do not forget to regenerate the parser when you modify rules in the `parser.y` file using `rake compile`.
|
47
|
+
|
48
|
+
Run the tests using `rake test`.
|
49
|
+
|
46
50
|
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).
|
47
51
|
|
48
52
|
## Contributing
|
data/lib/tomlrb/parser.y
CHANGED
@@ -82,7 +82,7 @@ rule
|
|
82
82
|
| INTEGER { result = val[0].to_i }
|
83
83
|
| TRUE { result = true }
|
84
84
|
| FALSE { result = false }
|
85
|
-
| DATETIME { result = Time.
|
85
|
+
| DATETIME { result = Time.new(*val[0])}
|
86
86
|
;
|
87
87
|
string
|
88
88
|
: STRING_MULTI { result = StringUtils.replace_escaped_chars(StringUtils.multiline_replacements(val[0])) }
|
data/lib/tomlrb/scanner.rb
CHANGED
@@ -9,7 +9,7 @@ module Tomlrb
|
|
9
9
|
STRING_MULTI = /"{3}([\s\S]*?"{3})/m
|
10
10
|
STRING_LITERAL = /(['])(?:\\?.)*?\1/
|
11
11
|
STRING_LITERAL_MULTI = /'{3}([\s\S]*?'{3})/m
|
12
|
-
DATETIME = /(-?\d{4})-(\d{2})-(\d{2})(?:t|\s)(\d{2}):(\d{2}):(\d{2}
|
12
|
+
DATETIME = /(-?\d{4})-(\d{2})-(\d{2})(?:t|\s)(\d{2}):(\d{2}):(\d{2}(?:\.\d+)?)?(z|[-+]\d{2}:\d{2})/i
|
13
13
|
FLOAT = /[+-]?(?:[0-9_]+\.[0-9_]*|\.[0-9_]+|\d+(?=[eE]))(?:[eE][+-]?[0-9_]+)?/
|
14
14
|
INTEGER = /[+-]?\d(_?\d)*/
|
15
15
|
TRUE = /true/
|
@@ -25,7 +25,7 @@ module Tomlrb
|
|
25
25
|
case
|
26
26
|
when @ss.scan(SPACE) then next_token
|
27
27
|
when @ss.scan(COMMENT) then next_token
|
28
|
-
when
|
28
|
+
when @ss.scan(DATETIME) then process_datetime
|
29
29
|
when text = @ss.scan(STRING_MULTI) then [:STRING_MULTI, text[3..-4]]
|
30
30
|
when text = @ss.scan(STRING_BASIC) then [:STRING_BASIC, text[1..-2]]
|
31
31
|
when text = @ss.scan(STRING_LITERAL_MULTI) then [:STRING_LITERAL_MULTI, text[3..-4]]
|
@@ -40,5 +40,10 @@ module Tomlrb
|
|
40
40
|
[x, x]
|
41
41
|
end
|
42
42
|
end
|
43
|
+
|
44
|
+
def process_datetime
|
45
|
+
args = [ @ss[1], @ss[2], @ss[3], @ss[4], @ss[5], @ss[6].to_f, @ss[7].gsub('Z', '+00:00') ]
|
46
|
+
[:DATETIME, args]
|
47
|
+
end
|
43
48
|
end
|
44
49
|
end
|
data/lib/tomlrb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tomlrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francois Bernier
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|