Avro
  1. Avro
  2. AVRO-415

Allow Ruby implementation to work with older versions of Ruby

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.3.0
    • Component/s: ruby
    • Labels:
      None
    • Hadoop Flags:
      Reviewed

      Description

      On Mac OS X Leopard with Ruby 1.8.6, running "rake test" results in:

      $ rake test
      (in /Users/hammer/codebox/avro-trunk/lang/ruby)
      /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -Ilib:ext:bin:test "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake/rake_test_loader.rb" "test/test_help.rb" "test/test_io.rb" "test/test_protocol.rb"
      ./lib/avro/schema.rb:290:in `initialize': wrong argument type Symbol (expected Proc) (TypeError)
      from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `each_with_index'
      from ./lib/avro/schema.rb:274:in `each'
      from ./lib/avro/schema.rb:274:in `each_with_index'
      from ./lib/avro/schema.rb:274:in `initialize'
      from ./lib/avro/schema.rb:72:in `new'
      from ./lib/avro/schema.rb:72:in `real_parse'
      from ./lib/avro/schema.rb:372:in `initialize'
      from ./lib/avro/schema.rb:170:in `new'
      ... 16 levels...
      from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake/rake_test_loader.rb:5:in `load'
      from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake/rake_test_loader.rb:5
      from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake/rake_test_loader.rb:5:in `each'
      from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake/rake_test_loader.rb:5
      rake aborted!
      Command failed with status (1): [/System/Library/Frameworks/Ruby.framework/...]

      (See full trace by running task with --trace)

      1. 187onanundercoverproc.patch
        0.6 kB
        Jeff Hodges
      2. AVRO-415.patch
        1 kB
        Jeff Hodges

        Activity

        Hide
        Jeff Hammerbacher added a comment -

        From Jeff Hodges:

        Ah! I wrote schema_objects.map(&:type). The Symbol#to_proc thing (the
        "&:type") is only supported in ruby 1.8.7 (and later) and any ruby
        that loads activesupport. I'll send up a patch tomorrow.

        Show
        Jeff Hammerbacher added a comment - From Jeff Hodges: Ah! I wrote schema_objects.map(&:type). The Symbol#to_proc thing (the "&:type") is only supported in ruby 1.8.7 (and later) and any ruby that loads activesupport. I'll send up a patch tomorrow.
        Hide
        Jeff Hodges added a comment -

        Cause it's a 187 on an undercover proc.

        Show
        Jeff Hodges added a comment - Cause it's a 187 on an undercover proc.
        Hide
        Jeff Hodges added a comment -

        (Going forward, there are good reasons not to support 1.8.6 is a bad idea, but let's get some install base first.)

        Show
        Jeff Hodges added a comment - (Going forward, there are good reasons not to support 1.8.6 is a bad idea, but let's get some install base first.)
        Hide
        Jeff Hammerbacher added a comment -

        After applying the patch, I get a new error:

        $ rake test
        (in /Users/hammer/codebox/avro-trunk/lang/ruby)
        /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -Ilib:ext:bin:test "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake/rake_test_loader.rb" "test/test_help.rb" "test/test_io.rb" "test/test_protocol.rb" 
        Loaded suite /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake/rake_test_loader
        Started
        ...........E.........E...
        Finished in 0.219321 seconds.
        
          1) Error:
        test_lisp(TestIO):
        NoMethodError: undefined method `find_index' for #<Array:0x5e6000>
            ./lib/avro/io.rb:555:in `write_union'
            ./lib/avro/io.rb:517:in `write_data'
            ./lib/avro/io.rb:566:in `write_record'
            ./lib/avro/io.rb:565:in `each'
            ./lib/avro/io.rb:565:in `write_record'
            ./lib/avro/io.rb:518:in `write_data'
            ./lib/avro/io.rb:495:in `write'
            ./test/test_io.rb:301:in `checkser'
            ./test/test_io.rb:290:in `check'
            ./test/test_io.rb:290:in `times'
            ./test/test_io.rb:290:in `check'
            ./test/test_io.rb:117:in `test_lisp'
        
          2) Error:
        test_union(TestIO):
        NoMethodError: undefined method `find_index' for #<Array:0x382a5c>
            ./lib/avro/io.rb:555:in `write_union'
            ./lib/avro/io.rb:517:in `write_data'
            ./lib/avro/io.rb:495:in `write'
            ./test/test_io.rb:301:in `checkser'
            ./test/test_io.rb:290:in `check'
            ./test/test_io.rb:290:in `times'
            ./test/test_io.rb:290:in `check'
            ./test/test_io.rb:102:in `test_union'
        
        25 tests, 538 assertions, 0 failures, 2 errors
        rake aborted!
        Command failed with status (1): [/System/Library/Frameworks/Ruby.framework/...]
        
        (See full trace by running task with --trace)
        
        Show
        Jeff Hammerbacher added a comment - After applying the patch, I get a new error: $ rake test (in /Users/hammer/codebox/avro-trunk/lang/ruby) /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -Ilib:ext:bin:test "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake/rake_test_loader.rb" "test/test_help.rb" "test/test_io.rb" "test/test_protocol.rb" Loaded suite /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake/rake_test_loader Started ...........E.........E... Finished in 0.219321 seconds. 1) Error: test_lisp(TestIO): NoMethodError: undefined method `find_index' for #<Array:0x5e6000> ./lib/avro/io.rb:555:in `write_union' ./lib/avro/io.rb:517:in `write_data' ./lib/avro/io.rb:566:in `write_record' ./lib/avro/io.rb:565:in `each' ./lib/avro/io.rb:565:in `write_record' ./lib/avro/io.rb:518:in `write_data' ./lib/avro/io.rb:495:in `write' ./test/test_io.rb:301:in `checkser' ./test/test_io.rb:290:in `check' ./test/test_io.rb:290:in `times' ./test/test_io.rb:290:in `check' ./test/test_io.rb:117:in `test_lisp' 2) Error: test_union(TestIO): NoMethodError: undefined method `find_index' for #<Array:0x382a5c> ./lib/avro/io.rb:555:in `write_union' ./lib/avro/io.rb:517:in `write_data' ./lib/avro/io.rb:495:in `write' ./test/test_io.rb:301:in `checkser' ./test/test_io.rb:290:in `check' ./test/test_io.rb:290:in `times' ./test/test_io.rb:290:in `check' ./test/test_io.rb:102:in `test_union' 25 tests, 538 assertions, 0 failures, 2 errors rake aborted! Command failed with status (1): [/System/Library/Frameworks/Ruby.framework/...] (See full trace by running task with --trace)
        Hide
        Jeff Hammerbacher added a comment -

        Also, while I don't want to stifle any attempts at humor, it's useful if your patches are named after the ticket (e.g. AVRO-415.patch).

        Show
        Jeff Hammerbacher added a comment - Also, while I don't want to stifle any attempts at humor, it's useful if your patches are named after the ticket (e.g. AVRO-415 .patch).
        Hide
        Jeff Hodges added a comment -

        1.8.6 also doesn't have find_index which makes for lameness. This subsumes the earlier patch. Also, kills joy.

        Show
        Jeff Hodges added a comment - 1.8.6 also doesn't have find_index which makes for lameness. This subsumes the earlier patch. Also, kills joy.
        Hide
        Jeff Hammerbacher added a comment -

        Huzzah, "rake test" passes! Thanks, Jeff. +1

        Show
        Jeff Hammerbacher added a comment - Huzzah, "rake test" passes! Thanks, Jeff. +1
        Hide
        Jeff Hammerbacher added a comment -

        (p.s. we've backported an entire application from Python 2.5 to Python 2.4, so it's good to catch these things now)

        Show
        Jeff Hammerbacher added a comment - (p.s. we've backported an entire application from Python 2.5 to Python 2.4, so it's good to catch these things now)
        Hide
        Doug Cutting added a comment -

        I just committed this. Thanks, Jeff!

        Show
        Doug Cutting added a comment - I just committed this. Thanks, Jeff!

          People

          • Assignee:
            Jeff Hodges
            Reporter:
            Jeff Hammerbacher
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development