Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: pangloss/pacer-dex
base: 9565d9158f
...
head fork: pangloss/pacer-dex
compare: d067e894be
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
Commits on Sep 20, 2012
@pangloss Fix loading outside of rubygems 729ce63
Commits on Sep 21, 2012
@pangloss Add a Dex encoder d067e89
View
8 lib/pacer-dex.rb
@@ -1,9 +1,15 @@
+require 'pacer' unless defined? Pacer
+
+lib_path = File.expand_path(File.join(File.dirname(__FILE__), '../lib'))
+$:.unshift lib_path unless $:.any? { |path| path == lib_path }
+
require 'pacer-dex/version'
+
if Pacer::Dex::ENABLED
- require 'pacer'
require Pacer::Dex::JAR
require 'pacer-dex/graph'
+ require 'pacer-dex/encoder'
else
puts "Dex has been disabled."
puts
View
77 lib/pacer-dex/encoder.rb
@@ -0,0 +1,77 @@
+require 'java'
+require 'yaml'
+
+module Pacer::Dex
+ # This encoder was originally part of pacer-neo4j. It uses native data where
+ # Neo4j could and for everything else it uses (slow (but easy))
+ # human-readable YAML encoding.
+ class Encoder
+ def self.encode_property(value)
+ case value
+ when nil
+ nil
+ when String
+ value = value.strip
+ value = nil if value == ''
+ value
+ when Fixnum
+ value.to_java :int
+ when Float
+ value.to_java :double
+ when Bignum
+ value.to_yaml
+ 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
+ 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
+ end
+ end
+ end
+end
View
2  lib/pacer-dex/graph.rb
@@ -17,7 +17,7 @@ def dex(path)
g.blueprints_graph.shutdown
Pacer.open_graphs[path] = nil
end
- PacerGraph.new(Pacer::YamlEncoder, open, shutdown)
+ PacerGraph.new(Pacer::Dex::Encoder, open, shutdown)
end
end
end
View
2  lib/pacer-dex/version.rb
@@ -4,7 +4,7 @@ module Dex
if not defined? ENABLED
ENABLED = ENV_JAVA['java.runtime.version'] =~ /^1\.6\./
end
- VERSION = "2.0.0"
+ VERSION = "2.0.2"
JAR = "pacer-dex-#{ VERSION }-standalone.jar"
JAR_PATH = "lib/#{ JAR }"
BLUEPRINTS_VERSION = "2.1.0"
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.0</gem.version>
+ <gem.version>2.0.1</gem.version>
<blueprints.version>2.1.0</blueprints.version>
<pipes.version>2.1.0</pipes.version>
</properties>

No commit comments for this range

Something went wrong with that request. Please try again.