Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Dex doesn't support array properties. Improve YAML.

Tried using Marshal.dump but Dex does not like binary data.
  • Loading branch information...
commit d5964abef8eadfe16aef2fdec453a5dbf6acfbfa 1 parent d067e89
@pangloss authored
Showing with 16 additions and 48 deletions.
  1. +15 −47 lib/pacer-dex/encoder.rb
  2. +1 −1  pom.xml
View
62 lib/pacer-dex/encoder.rb
@@ -15,63 +15,31 @@ def self.encode_property(value)
value = nil if value == ''
value
when Fixnum
- value.to_java :int
+ value.to_java :int rescue dump value
when Float
value.to_java :double
when Bignum
- value.to_yaml
+ dump value
when true, false
value.to_java :boolean
- when Array
- if value.length == 0
- value_type = Fixnum
- else
- value_type = value.first.class
- value_type = TrueClass if value_type == FalseClass
- value.each do |v|
- if value_type != v.class or (value == true or value == false and value_type == TrueClass)
- value_type = nil
- break
- end
- end
- end
- case value_type
- when Fixnum
- value.to_java :int
- when Float
- value.to_java :double
- when TrueClass
- value.to_java :boolean
- when String
- value.to_java :string
- else
- value.to_yaml
- end
else
- value.to_yaml
+ dump value
end
end
- if 'x'.to_yaml[0, 5] == '%YAML'
- def self.decode_property(value)
- if value.is_a? String and value[0, 5] == '%YAML'
- YAML.load(value)
- elsif value.is_a? ArrayJavaProxy
- value.to_a
- else
- value
- end
- end
- else
- def self.decode_property(value)
- if value.is_a? String and value[0, 3] == '---'
- YAML.load(value)
- elsif value.is_a? ArrayJavaProxy
- value.to_a
- else
- value
- end
+ def self.decode_property(value)
+ if value.is_a? String and value[0, 1] == ' '
+ YAML.load(value[1...-1])
+ else
+ value
end
end
+
+ private
+
+ def self.dump(value)
+ # Leading space signifies a binary. It would otherwise be stripped.
+ " #{ YAML.dump value }"
+ end
end
end
View
2  pom.xml
@@ -7,7 +7,7 @@
<artifactId>pacer-dex</artifactId>
<!-- NOTE: the following properties are automatically updated based on the values in lib/pacer-neo4j/version.rb -->
<properties>
- <gem.version>2.0.1</gem.version>
+ <gem.version>2.0.2</gem.version>
<blueprints.version>2.1.0</blueprints.version>
<pipes.version>2.1.0</pipes.version>
</properties>
Please sign in to comment.
Something went wrong with that request. Please try again.