jm / toml

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

Parse error for any file / content with Ruby 1.9.3-p392 & toml v0.0.2 #9

Closed stevenhaddox closed 11 years ago

stevenhaddox commented 11 years ago
$ bundle show toml
Resolving dependencies...
/Users/steven/.rvm/gems/ruby-1.9.3-p392/gems/toml-0.0.2
$ cat config/support.toml
pub_key_path = "$HOME/id_dsa.pub"
$ b ruby -e "require 'toml';TOML.load('config/support.toml');"
/Users/steven/.rvm/gems/ruby-1.9.3-p392/gems/parslet-1.5.0/lib/parslet/cause.rb:63:in `raise': Extra input after last repetition at line 1 char 1. (Parslet::ParseFailed)
    from /Users/steven/.rvm/gems/ruby-1.9.3-p392/gems/parslet-1.5.0/lib/parslet/atoms/base.rb:46:in `parse'
    from /Users/steven/.rvm/gems/ruby-1.9.3-p392/gems/toml-0.0.2/lib/toml/parser.rb:9:in `initialize'
    from /Users/steven/.rvm/gems/ruby-1.9.3-p392/gems/toml-0.0.2/lib/toml.rb:16:in `new'
    from /Users/steven/.rvm/gems/ruby-1.9.3-p392/gems/toml-0.0.2/lib/toml.rb:16:in `load'
    from -e:1:in `<main>'
jm commented 11 years ago

Try adding a newline to the end of the file. I think that's fixed on master?

dirk commented 11 years ago

If it wouldn't be too much trouble, could you show me what your (sanitized for anything sensitive) config/support.toml file looks like? Thanks!

It may be the trailing-newline bug like @jm said.

stevenhaddox commented 11 years ago

@jm @dirk: Literally the line that it output from cat:

$ cat config/support.toml
pub_key_path = "$HOME/id_dsa.pub"

I added in the newline to try it out and still got the same error. Thanks for working on this and for such fast responses ;)

stevenhaddox commented 11 years ago

@jm is there a way to point to a gem's git repo from within a gemspec? I don't know that one off-hand...

jm commented 11 years ago

I don't think so but you can add extra deps to the Gemfile for testing maybe?

dirk commented 11 years ago

Okay. I'm unable to replicate this on master with ruby 1.9.3p374. May have been fixed since v0.0.2.

@stevenhaddox: Unfortunately no. (Cite: StackOverflow)

@jm Want to bump it to v0.0.3 and push to Rubygems? There aren't any problems on master HEAD to my knowledge.

jm commented 11 years ago

Just pushed a new version; pull it down and give it a shot!

stevenhaddox commented 11 years ago

@jm @dirk: thanks. I'll follow-up momentarily.

stevenhaddox commented 11 years ago

Apparently I'm really good at breaking things...

SUPPORT (centos_chef_solo) $ bundle show toml
Resolving dependencies...
/Users/steven/.rvm/gems/ruby-1.9.3-p392/gems/toml-0.0.3
SUPPORT (centos_chef_solo) $ cat config/support.toml
pub_key_path = "$HOME/id_dsa.pub"

SUPPORT (centos_chef_solo) $ b ruby -e "require 'toml';TOML.load('config/support.toml');"
Failed to match sequence (ALL_SPACE (KEY_GROUP / KEY_VALUE / COMMENT_LINE){0, } ALL_SPACE) at line 1 char 1.
`- Don't know what to do with "config/sup" at line 1 char 1.
/Users/steven/.rvm/gems/ruby-1.9.3-p392/gems/toml-0.0.3/lib/toml/parser.rb:21:in `initialize': undefined method `each' for nil:NilClass (NoMethodError)
    from /Users/steven/.rvm/gems/ruby-1.9.3-p392/gems/toml-0.0.3/lib/toml.rb:20:in `new'
    from /Users/steven/.rvm/gems/ruby-1.9.3-p392/gems/toml-0.0.3/lib/toml.rb:20:in `load'
    from -e:1:in `<main>'
SUPPORT (centos_chef_solo) $ b ruby -e "require 'toml';TOML::Parser(\"key='value'\").parsed;"
-e:1:in `<main>': undefined method `Parser' for TOML:Module (NoMethodError)
stevenhaddox commented 11 years ago

Also, there's quite a few gems in this project. I'm going to try it in a blank gemset and see if it makes a difference there...

dirk commented 11 years ago

Ah. You're going to want to do TOML.load_file instead of TOML.load (load expects a string to be parsed). Also, do TOML::Parser.new(...).parsed (just need that pesky little .new in there). Hope that works!

stevenhaddox commented 11 years ago

@dirk: do'h. I could've sworn I had that right. #fail

Thanks. Seems to work awesome now (even without the extra newline). Sorry if I cause a release over a mental parsing error :confounded:

dirk commented 11 years ago

No worries! Glad to help. :smile: