Skip to content

Commit

Permalink
AVRO-415. Fix Ruby to work with Ruby 1.8.6.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/hadoop/avro/trunk@910701 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
cutting committed Feb 16, 2010
1 parent 89d56e9 commit dff585b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Expand Up @@ -481,6 +481,8 @@ Trunk (unreleased changes)

AVRO-407. Fix a bug in the Java data file reader. (Scott Carey via cutting)

AVRO-415. Fix Ruby to work with Ruby 1.8.6.

Avro 1.2.0 (14 October 2009)

INCOMPATIBLE CHANGES
Expand Down
2 changes: 1 addition & 1 deletion README.txt
Expand Up @@ -12,7 +12,7 @@ The following packages must be installed before Avro can be built:
- Python: 2.5 or greater, python-setuptools for dist target
- C: gcc, autoconf, automake, libtool, asciidoc
- C++: g++, flex, bison, libboost-dev
- Ruby: ruby, gem, rake, echoe, jajl-ruby
- Ruby: ruby 1.86 or greater, gem, rake, echoe, jajl-ruby
- Apache Ant 1.7
- Apache Forrest 0.8 (for documentation, requires Java 1.5)

Expand Down
7 changes: 4 additions & 3 deletions lang/ruby/lib/avro/io.rb
Expand Up @@ -552,9 +552,10 @@ def write_map(writers_schema, datum, encoder)
end

def write_union(writers_schema, datum, encoder)
index_of_schema = writers_schema.schemas.
find_index{|e| Schema.validate(e, datum) }
unless index_of_schema
index_of_schema = -1
found = writers_schema.schemas.
find{|e| index_of_schema += 1; found = Schema.validate(e, datum) }
unless found # Because find_index doesn't exist in 1.8.6
raise AvroTypeError.new(writers_schema, datum)
end
encoder.write_long(index_of_schema)
Expand Down
2 changes: 1 addition & 1 deletion lang/ruby/lib/avro/schema.rb
Expand Up @@ -287,7 +287,7 @@ def initialize(schemas, names=nil)
ns_type = new_schema.type
if VALID_TYPES.include?(ns_type) &&
!NAMED_TYPES.include?(ns_type) &&
schema_objects.map(&:type).include?(ns_type)
schema_objects.map{|o| o.type }.include?(ns_type)
raise SchemaParseError, "#{ns_type} is already in Union"
elsif ns_type == 'union'
raise SchemaParseError, "Unions cannot contain other unions"
Expand Down

0 comments on commit dff585b

Please sign in to comment.