neocities / neocities-ruby

The Neocities Gem - A CLI and library for using the Neocities web site API.
https://neocities.org
52 stars 14 forks source link

avoid parsing nil value in info #11

Closed galaktor closed 5 years ago

galaktor commented 6 years ago

I kept getting this on a new site, presumably because it was never updated.

$ neocities info my_site
/Users/me/.rbenv/versions/2.4.4/lib/ruby/2.4.0/time.rb:367:in `_parse': no implicit conversion of nil into String (TypeError)
    from /Users/me/.rbenv/versions/2.4.4/lib/ruby/2.4.0/time.rb:367:in `parse'
    from /Users/me/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/neocities-0.0.9/lib/neocities/cli.rb:115:in `block in info'
    from /Users/me/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/neocities-0.0.9/lib/neocities/cli.rb:114:in `each'
    from /Users/me/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/neocities-0.0.9/lib/neocities/cli.rb:114:in `info'
    from /Users/me/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/neocities-0.0.9/lib/neocities/cli.rb:77:in `run'
    from /Users/me/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/neocities-0.0.9/bin/neocities:4:in `<top (required)>'
    from /Users/me/.rbenv/versions/2.4.4/bin/neocities:23:in `load'
    from /Users/me/.rbenv/versions/2.4.4/bin/neocities:23:in `<main>'

Happened on ruby 2.3, 2.4 and 2.5.

This PR avoids invoking Time.parse when v is nil.

kyledrake commented 5 years ago

Thank you!