jm / toml

Parse TOML. Like a bawss.
MIT License
151 stars 37 forks source link

parsing breaks on multi-line strings #54

Open RichMorin opened 5 years ago

RichMorin commented 5 years ago

This gem is breaking for me when I try to parse a multi-line string. For example:

irb(main):020:0> text = <<EOT
irb(main):021:0" [foo]
irb(main):022:0" 
irb(main):023:0"   bar = '''
irb(main):024:0" baz
irb(main):025:0" '''
irb(main):026:0" EOT
=> "[foo]\n\n  bar = '''\nbaz\n'''\n"
irb(main):027:0> TOML.load(text)
NoMethodError: undefined method `ascii_tree' for nil:NilClass
from /Library/Ruby/Gems/2.3.0/gems/toml-0.2.0/lib/toml/parser.rb:12:in
      `rescue in initialize'
from /Library/Ruby/Gems/2.3.0/gems/toml-0.2.0/lib/toml/parser.rb:9:in `initialize'
from /Library/Ruby/Gems/2.3.0/gems/toml-0.2.0/lib/toml.rb:19:in `new'
from /Library/Ruby/Gems/2.3.0/gems/toml-0.2.0/lib/toml.rb:19:in `load'
from (irb):27
from /usr/bin/irb:11:in `<main>'

The problem occurs with either ''' or """ strings and with both load and load_file. Here is some environment info:

$ gem list | grep toml
toml (0.2.0)
$ ruby -v
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin17]
mkarklinsScout commented 4 years ago

@RichMorin did you ever solve the problem?

RichMorin commented 4 years ago

no, sorry.