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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 38bbb338f065b9b460b975285aeecad0e7bdf691
4
- data.tar.gz: cd43529b21ee755922200f9ea492a84c1bb2f315
3
+ metadata.gz: 86c658a15f370e29296822096361be88b381124e
4
+ data.tar.gz: bcdc56e5d754afb1b3ee02d01737a8ecf0744435
5
5
  SHA512:
6
- metadata.gz: a90025b382ec0cc530029b423f17a698b524333981907ca0559f5c37192bb7e9594df1af57f32c11adcbca04adb1423b4eaeb671ec1ec4803029542b24e88315
7
- data.tar.gz: 82429533f65caaabbfdc21df7fe4800e34047e5b0680541501c39e1954ec713179abd61cf12b83a7a773072af142387963c16f1198b51723100204bd3fa73951
6
+ metadata.gz: fbea9023660e2807b5d90088f31027e2e3454fb07beb0893decbb3b81e6c4a65811c828cc0788c6bd7c613d7f82982803ec76e9cdd0f4a5d800e540d9cbfb752
7
+ data.tar.gz: 671eabff02c17040c061e12322281180c7ced933773f855534f03997e78e30ef1c91dfbcddb3e21d2cfab293f8de854761e61d92caf898d710799e3339709c8b
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Code Climate](https://codeclimate.com/github/fbernier/tomlrb/badges/gpa.svg)](https://codeclimate.com/github/fbernier/tomlrb) [![Build Status](https://travis-ci.org/fbernier/tomlrb.svg)](https://travis-ci.org/fbernier/tomlrb) [![Gem Version](https://badge.fury.io/rb/tomlrb.svg)](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
@@ -416,7 +416,7 @@ module_eval(<<'.,.,', 'parser.y', 83)
416
416
 
417
417
  module_eval(<<'.,.,', 'parser.y', 84)
418
418
  def _reduce_43(val, _values, result)
419
- result = Time.parse(val[0])
419
+ result = Time.new(*val[0])
420
420
  result
421
421
  end
422
422
  .,.,
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.parse(val[0]) }
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])) }
@@ -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})(?:\.(\d+))?(z|[-+]\d{2}:\d{2})/i
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 text = @ss.scan(DATETIME) then [:DATETIME, text]
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
@@ -1,3 +1,3 @@
1
1
  module Tomlrb
2
- VERSION = "1.0.3"
2
+ VERSION = "1.1.0"
3
3
  end
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.3
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-22 00:00:00.000000000 Z
11
+ date: 2015-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler