yb66 / tickle

Natural language parser for recurring events

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error undefined method `year'

dodomarocgenex opened this issue · comments

I am trying to run a .rb file with the provided examples, but I get this error:

/Users/UserName/.rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/tickle-1.1.0/lib/tickle/tickle.rb:265:in next_appropriate_year': undefined method year' for nil:NilClass (NoMethodError)

Does it have to do with ruby version?

Hi,

It's a possibility. I've not run it with 2.4 on my machine as I only installed 2.4 a couple of hours ago :) It seems to have last run on Travis with 2.2.5.

Have you tried using the release candidate? v2.0.0.rc1

I will update the Travis file and give 2.4 a try too.

Regards,
iain

I've just installed 2.4 too
Do functions with default values need () in this Ruby version?

I just ran the tests for v1.1.0 with ruby 2.4 and they passed. Running the examples.rb file, which I hadn't noticed existed tbh, throws up an error. There's barely anything in it though.

Is there a particular example that's not working for you?

iain

None of them works 😔

Hmmm. All the ones I’ve tried in IRB from the README* work for me. Can you try these and see if you get the same results?

irb(main):010:0> Tickle.parse('3 months', {:until=>"2010-10-09 00:00:00 -0400"})
=> {:next=>2017-06-12 04:00:04 +0100, :expression=>"3 months", :starting=>2017-03-12 03:00:04 +0000, :until=>nil}
irb(main):011:0> Tickle.parse('every week starting this wednesday ends May 13th')
=> {:next=>2017-03-15 12:00:00 +0000, :expression=>"week", :starting=>2017-03-15 12:00:00 +0000, :until=>2017-05-13 12:00:00 +0100}
irb(main):012:0> Tickle.parse('every other day starting May 13')
=> {:next=>2017-05-13 12:00:00 +0100, :expression=>"other day", :starting=>2017-05-13 12:00:00 +0100, :until=>nil}

* that don’t have silly syntax errors like missing double quotes. Note to self to fix those.

iain

Running the examples you've given works just fine in irb, I'm going to look into my .rb file again

Trying to to run a simple .rb containing this code:

require 'tickle'

Tickle.parse('starting tomorrow and ending one week from now')

using the command ruby file.rb in the terminal on MacOS Sierra

Gives this error message:

/usr/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/UserName/Desktop/file.rb
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/universal-darwin16/rbconfig.rb:213: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
/Library/Ruby/Gems/2.0.0/gems/tickle-1.1.0/lib/tickle/tickle.rb:265:in `next_appropriate_year': undefined method `year' for nil:NilClass (NoMethodError)
	from /Library/Ruby/Gems/2.0.0/gems/tickle-1.1.0/lib/tickle/tickle.rb:208:in `normalize_us_holidays'
	from /Library/Ruby/Gems/2.0.0/gems/tickle-1.1.0/lib/tickle/tickle.rb:176:in `pre_filter'
	from /Library/Ruby/Gems/2.0.0/gems/tickle-1.1.0/lib/tickle/tickle.rb:130:in `scan_expression'
	from /Library/Ruby/Gems/2.0.0/gems/tickle-1.1.0/lib/tickle/tickle.rb:54:in `parse'
	from /Users/UserName/Desktop/file.rb:3:in `<top (required)>'
	from -e:1:in `load'
	from -e:1:in `<main>'

Process finished with exit code 1

setting the default ruby version doesn't help either

rvm --default use 2.4

I've pushed a branch called debugging-with-pry to make it more convenient to debug. Just call env DEBUG=1 bin/pry (if you've installed pry via --binstubs) and then set break points where you like, e.g.

break lib/tickle/tickle.rb:130
break lib/tickle/tickle.rb:176
break lib/tickle/tickle.rb:208
break lib/tickle/tickle.rb:265

They are the ones I'm using right now.

iain

I've made a change to next_appropriate_year and pushed it to the debug branch. It appears to bring back the right answer and it passes the tests (which doesn't say a lot, the specs on the rc branch are far more comprehensive).

Let me know if it works for you.

iain

@start was nil in 1.1.0, I'll run some test on the debugging branch