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 +4 -4
 - data/README.md +1 -2
 - data/lib/tomlrb.rb +7 -1
 - data/lib/tomlrb/handler.rb +9 -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: 38bbb338f065b9b460b975285aeecad0e7bdf691
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: cd43529b21ee755922200f9ea492a84c1bb2f315
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: a90025b382ec0cc530029b423f17a698b524333981907ca0559f5c37192bb7e9594df1af57f32c11adcbca04adb1423b4eaeb671ec1ec4803029542b24e88315
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 82429533f65caaabbfdc21df7fe4800e34047e5b0680541501c39e1954ec713179abd61cf12b83a7a773072af142387963c16f1198b51723100204bd3fa73951
         
     | 
    
        data/README.md
    CHANGED
    
    
    
        data/lib/tomlrb.rb
    CHANGED
    
    | 
         @@ -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 
     | 
    
         
            -
                 
     | 
| 
      
 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 
     | 
    
         | 
    
        data/lib/tomlrb/handler.rb
    CHANGED
    
    | 
         @@ -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 
     | 
    
         
            -
                   
     | 
| 
      
 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
         
     | 
    
        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.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- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-04-22 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     |