fl00r/pickup

Errors when running under ruby 1.8.7

Closed this issue · 3 comments

The shared host where I tried to deploy the app is still running ruby 1.8.7. I got the following when I tried to require the gem:

/home/maciakl/.gems/gems/pickup-0.0.9/lib/pickup.rb:19: syntax error, unexpected ':', expecting ')'
...ppedList.new(list, func, uniq: uniq, key_func: key_func, wei...
                              ^
/home/maciakl/.gems/gems/pickup-0.0.9/lib/pickup.rb:19: syntax error, unexpected ':', expecting '='
...t, func, uniq: uniq, key_func: key_func, weight_func: weight...
                              ^
/home/maciakl/.gems/gems/pickup-0.0.9/lib/pickup.rb:19: syntax error, unexpected ':', expecting '='
...y_func: key_func, weight_func: weight_func)
                              ^
/home/maciakl/.gems/gems/pickup-0.0.9/lib/pickup.rb:108: syntax error, unexpected ':', expecting ')'
...ew(@list, func, max, key_func: @key_func, weight_func: weigh...
                              ^
/home/maciakl/.gems/gems/pickup-0.0.9/lib/pickup.rb:108: syntax error, unexpected ':', expecting '='
..._func: @key_func, weight_func: weight_func).each do |item|
                              ^ (SyntaxError)

Output of ruby -v on the server:

ruby 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux]

It works flawlessly on Ruby 2.1 though.

Hi!
Ruby 1.8.7 is very old stuff. There are some syntax incompatibilities between 1.8 and newer branches. One of them is a Hash syntax:

# < 1.9
hash = { :a => 1, :b => 2 }
# >= 1.9
hash = { a: 1, b: 2 }

Actually 1.9 supports both of them. This particular gem is written with 1.9 Hash syntax (because it is recommended), so it doesn't work in 1.8.7. Sorry.

Ah, ok. That's what I thought. Thanks.

Hey, would you mind updating the Ruby dependency value on the gem page and in the gem spec? Right now it says >=0 which means it will install on 1.8 just fine, but then blow up as soon as you try to use it. Might be a good idea to put 1.9 as a Ruby dependency just so that people know not to use it on lower versions. :)

Fair enough. Done. Thank you