tomlrb 1.0.2 → 1.0.3

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: 752cc47c45ecffc6b2c80ec8ff41ba2bec5481d6
4
- data.tar.gz: de853f73c1ce4b01827c642ae894ad21d0ddc2a7
3
+ metadata.gz: 38bbb338f065b9b460b975285aeecad0e7bdf691
4
+ data.tar.gz: cd43529b21ee755922200f9ea492a84c1bb2f315
5
5
  SHA512:
6
- metadata.gz: 3a16252642e7a281b696cb44f008d00bb85ecd2a7d50986ffa9e8eec710588a3bcde859285a3e954b9bd850b0a6d2750a975c94c53a07067c2b5cb48218bea5d
7
- data.tar.gz: 65ef3514b3fe8f93c9cfc3f535401f9340e57a2910a5b2afdf13d7d8ad578eefb739bc1b9e637215fcfede56e76496d22c4ee1cde134d0a4f67a78409d954c60
6
+ metadata.gz: a90025b382ec0cc530029b423f17a698b524333981907ca0559f5c37192bb7e9594df1af57f32c11adcbca04adb1423b4eaeb671ec1ec4803029542b24e88315
7
+ data.tar.gz: 82429533f65caaabbfdc21df7fe4800e34047e5b0680541501c39e1954ec713179abd61cf12b83a7a773072af142387963c16f1198b51723100204bd3fa73951
data/README.md CHANGED
@@ -7,10 +7,9 @@ A Racc based [TOML](https://github.com/toml-lang/toml) parser supporting the 0.4
7
7
 
8
8
  ## TODO
9
9
 
10
- * Error handling
10
+ * YARD documentation
11
11
  * Better tests
12
12
  * Dumper
13
- * Refactoring
14
13
 
15
14
  ## Installation
16
15
 
@@ -7,12 +7,18 @@ require "tomlrb/parser"
7
7
  require "tomlrb/handler"
8
8
 
9
9
  module Tomlrb
10
+ class ParseError < StandardError; end
10
11
 
11
12
  def self.parse(string_or_io, **options)
12
13
  io = string_or_io.is_a?(String) ? StringIO.new(string_or_io) : string_or_io
13
14
  scanner = Scanner.new(io)
14
15
  parser = Parser.new(scanner, options)
15
- handler = parser.parse
16
+ begin
17
+ handler = parser.parse
18
+ rescue Racc::ParseError => e
19
+ raise ParseError.new(e.message)
20
+ end
21
+
16
22
  handler.output
17
23
  end
18
24
 
@@ -6,6 +6,7 @@ module Tomlrb
6
6
  @output = {}
7
7
  @current = @output
8
8
  @stack = []
9
+ @array_names = []
9
10
  @symbolize_keys = options[:symbolize_keys]
10
11
  end
11
12
 
@@ -28,7 +29,14 @@ module Tomlrb
28
29
 
29
30
  def deal_with_array_of_tables(identifiers, is_array_of_tables)
30
31
  identifiers.map!{|n| n.gsub("\"", '')}
31
- last_identifier = identifiers.pop if is_array_of_tables
32
+ stringified_identifier = identifiers.join('.')
33
+
34
+ if is_array_of_tables
35
+ @array_names << stringified_identifier
36
+ last_identifier = identifiers.pop
37
+ elsif @array_names.include?(stringified_identifier)
38
+ raise ParseError.new('Cannot define a normal table with the same name as an already established array')
39
+ end
32
40
 
33
41
  yield(identifiers)
34
42
 
@@ -56,7 +64,6 @@ module Tomlrb
56
64
  def end_(type)
57
65
  array = []
58
66
  while (value = @stack.pop) != [type]
59
- raise if value.nil?
60
67
  array.unshift(value)
61
68
  end
62
69
  array
@@ -1,3 +1,3 @@
1
1
  module Tomlrb
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
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.2
4
+ version: 1.0.3
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-20 00:00:00.000000000 Z
11
+ date: 2015-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler