pacer-neo4j 1.0.7.1-java

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ target/*
6
+ lib/*.jar
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in pacer-graph.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # Neo4J Graph Database Adapter for Pacer
2
+
3
+ [Pacer](https://github.com/pangloss/pacer) is a
4
+ [JRuby](http://jruby.org) graph traversal framework built on the
5
+ [Tinkerpop](http://www.tinkerpop.com) stack.
6
+
7
+ This plugin enables full [Neo4J](http://neo4j.org) graph support in Pacer.
8
+
9
+
10
+ ## Usage
11
+
12
+ Here is how you open a Neo4J graph in Pacer.
13
+
14
+ require 'pacer'
15
+ require 'pacer-neo4j'
16
+
17
+ # Graph will be created if it doesn't exist
18
+ graph = Pacer.neo4j 'path/to/graph'
19
+
20
+ All other operations are identical across graph implementations (except
21
+ where certain features are not supported). See Pacer's documentation for
22
+ more information.
23
+
data/Rakefile ADDED
@@ -0,0 +1,29 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ file 'pom.xml' => 'lib/pacer-neo4j/version.rb' do
5
+ pom = File.read 'pom.xml'
6
+ when_writing('Update pom.xml version number') do
7
+ open 'pom.xml', 'w' do |f|
8
+ pom.each_line do |line|
9
+ line.sub!(%r{<gem.version>.*</gem.version>}, "<gem.version>#{ Pacer::Neo4j::VERSION }</gem.version>")
10
+ line.sub!(%r{<blueprints.version>.*</blueprints.version>}, "<blueprints.version>#{ Pacer::Neo4j::BLUEPRINTS_VERSION }</blueprints.version>")
11
+ line.sub!(%r{<pipes.version>.*</pipes.version>}, "<pipes.version>#{ Pacer::Neo4j::PIPES_VERSION }</pipes.version>")
12
+ f << line
13
+ end
14
+ end
15
+ end
16
+ end
17
+
18
+ file Pacer::Neo4j::JAR_PATH => 'pom.xml' do
19
+ when_writing("Execute 'mvn package' task") do
20
+ system('mvn clean package')
21
+ end
22
+ end
23
+
24
+ task :note do
25
+ puts "NOTE: touch lib/pacer-neo4j/version.rb to force everything to rebuild"
26
+ end
27
+
28
+ task :build => [:note, Pacer::Neo4j::JAR_PATH]
29
+ task :install => [:note, Pacer::Neo4j::JAR_PATH]
@@ -0,0 +1,36 @@
1
+ require 'yaml'
2
+
3
+ module Pacer
4
+ Neo4jEdge = com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jEdge
5
+
6
+ # Extend the java class imported from blueprints.
7
+ class Neo4jEdge
8
+ include Pacer::Core::Graph::EdgesRoute
9
+ include ElementMixin
10
+ include EdgeMixin
11
+
12
+ def in_vertex(extensions = nil)
13
+ v = inVertex
14
+ v.graph = graph
15
+ if extensions.is_a? Enumerable
16
+ v.add_extensions extensions
17
+ elsif extensions
18
+ v.add_extensions [extensions]
19
+ else
20
+ v
21
+ end
22
+ end
23
+
24
+ def out_vertex(extensions = nil)
25
+ v = outVertex
26
+ v.graph = graph
27
+ if extensions.is_a? Enumerable
28
+ v.add_extensions extensions
29
+ elsif extensions
30
+ v.add_extensions [extensions]
31
+ else
32
+ v
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,117 @@
1
+ require 'yaml'
2
+
3
+ module Pacer
4
+ Neo4jGraph = com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jGraph
5
+ Neo4jElement = com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jElement
6
+
7
+ # Add 'static methods' to the Pacer namespace.
8
+ class << self
9
+ # Return a graph for the given path. Will create a graph if none exists at
10
+ # that location. (The graph is only created if data is actually added to it).
11
+ #
12
+ # If the graph is opened from a path, it will be registered to be closed by
13
+ # Ruby's at_exit callback, but if an already open graph is given, it will
14
+ # not.
15
+ def neo4j(path_or_graph, args = nil)
16
+ if path_or_graph.is_a? String
17
+ path = File.expand_path(path_or_graph)
18
+ Pacer.starting_graph(self, path) do
19
+ if args
20
+ Neo4jGraph.new(path, args.to_hash_map)
21
+ else
22
+ Neo4jGraph.new(path)
23
+ end
24
+ end
25
+ else
26
+ # Don't register the new graph so that it won't be automatically closed.
27
+ Neo4jGraph.new(path_or_graph)
28
+ end
29
+ end
30
+ end
31
+
32
+
33
+ # Extend the java class imported from blueprints.
34
+ class Neo4jGraph
35
+ include GraphMixin
36
+ include GraphIndicesMixin
37
+ include GraphTransactionsMixin
38
+ include ManagedTransactionsMixin
39
+ include Pacer::Core::Route
40
+ include Pacer::Core::Graph::GraphRoute
41
+ include Pacer::Core::Graph::GraphIndexRoute
42
+
43
+ # Override to return an enumeration-friendly array of vertices.
44
+ def get_vertices
45
+ getVertices.to_route(:graph => self, :element_type => :vertex)
46
+ end
47
+
48
+ # Override to return an enumeration-friendly array of edges.
49
+ def get_edges
50
+ getEdges.to_route(:graph => self, :element_type => :edge)
51
+ end
52
+
53
+ def element_class
54
+ Neo4jElement
55
+ end
56
+
57
+ def vertex_class
58
+ Neo4jVertex
59
+ end
60
+
61
+ def edge_class
62
+ Neo4jEdge
63
+ end
64
+
65
+ def sanitize_properties(props)
66
+ pairs = props.map do |name, value|
67
+ [name, encode_property(value)]
68
+ end
69
+ Hash[pairs]
70
+ end
71
+
72
+ def encode_property(value)
73
+ case value
74
+ when nil
75
+ nil
76
+ when String
77
+ value = value.strip
78
+ value = nil if value == ''
79
+ value
80
+ when Numeric
81
+ if value.is_a? Bignum
82
+ value.to_yaml
83
+ else
84
+ value
85
+ end
86
+ else
87
+ value.to_yaml
88
+ end
89
+ end
90
+
91
+ if 'x'.to_yaml[0, 5] == '%YAML'
92
+ def decode_property(value)
93
+ if value.is_a? String and value[0, 5] == '%YAML'
94
+ YAML.load(value)
95
+ else
96
+ value
97
+ end
98
+ end
99
+ else
100
+ def decode_property(value)
101
+ if value.is_a? String and value[0, 3] == '---'
102
+ YAML.load(value)
103
+ else
104
+ value
105
+ end
106
+ end
107
+ end
108
+
109
+ def supports_circular_edges?
110
+ false
111
+ end
112
+
113
+ def supports_custom_element_ids?
114
+ false
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,45 @@
1
+ require 'yaml'
2
+
3
+ module Pacer
4
+ import com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jIndex
5
+ import com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jAutomaticIndex
6
+
7
+ class Neo4jIndex
8
+ include IndexMixin
9
+ JVertex = com.tinkerpop.blueprints.pgm.Vertex.java_class.to_java
10
+ JEdge = com.tinkerpop.blueprints.pgm.Edge.java_class.to_java
11
+ JNeo4jVertex = com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jVertex.java_class.to_java
12
+ JNeo4jEdge = com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jEdge.java_class.to_java
13
+
14
+ def index_class
15
+ et = getIndexClass
16
+ if et == JVertex
17
+ JNeo4jVertex
18
+ elsif et == JEdge
19
+ JNeo4jEdge
20
+ else
21
+ et
22
+ end
23
+ end
24
+ end
25
+
26
+
27
+ class Neo4jAutomaticIndex
28
+ include IndexMixin
29
+ JVertex = com.tinkerpop.blueprints.pgm.Vertex.java_class.to_java
30
+ JEdge = com.tinkerpop.blueprints.pgm.Edge.java_class.to_java
31
+ JNeo4jVertex = com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jVertex.java_class.to_java
32
+ JNeo4jEdge = com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jEdge.java_class.to_java
33
+
34
+ def index_class
35
+ et = getIndexClass
36
+ if et == JVertex
37
+ JNeo4jVertex
38
+ elsif et == JEdge
39
+ JNeo4jEdge
40
+ else
41
+ et
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,43 @@
1
+ class RSpec::GraphRunner
2
+ module Neo4j
3
+ def all(usage_style = :read_write, indices = true, &block)
4
+ super
5
+ neo4j(usage_style, indices, &block)
6
+ end
7
+
8
+ def neo4j(usage_style = :read_write, indices = true, &block)
9
+ for_graph('neo4j', usage_style, indices, true, neo_graph, neo_graph2, neo_graph_no_indices, block)
10
+ end
11
+
12
+ protected
13
+
14
+ def neo_graph
15
+ return @neo_graph if @neo_graph
16
+ path1 = File.expand_path('tmp/spec.neo4j')
17
+ dir = Pathname.new(path1)
18
+ dir.rmtree if dir.exist?
19
+ @neo_graph = Pacer.neo4j(path1)
20
+ end
21
+
22
+ def neo_graph2
23
+ return @neo_graph2 if @neo_graph2
24
+ path2 = File.expand_path('tmp/spec.neo4j.2')
25
+ dir = Pathname.new(path2)
26
+ dir.rmtree if dir.exist?
27
+ @neo_graph2 = Pacer.neo4j(path2)
28
+ end
29
+
30
+ def neo_graph_no_indices
31
+ return @neo_graph_no_indices if @neo_graph_no_indices
32
+ path3 = File.expand_path('tmp/spec_no_indices.neo4j')
33
+ dir = Pathname.new(path3)
34
+ dir.rmtree if dir.exist?
35
+ @neo_graph_no_indices = Pacer.neo4j(path3)
36
+ @neo_graph_no_indices.drop_index :vertices
37
+ @neo_graph_no_indices.drop_index :edges
38
+ @neo_graph_no_indices
39
+ end
40
+ end
41
+
42
+ include Neo4j
43
+ end
@@ -0,0 +1,9 @@
1
+ module Pacer
2
+ module Neo4j
3
+ VERSION = "1.0.7.1"
4
+ JAR = "pacer-neo4j-#{ VERSION }-standalone.jar"
5
+ JAR_PATH = "lib/#{ JAR }"
6
+ BLUEPRINTS_VERSION = "1.0"
7
+ PIPES_VERSION = "0.8"
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ require 'yaml'
2
+
3
+ module Pacer
4
+ Neo4jVertex = com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jVertex
5
+ # Extend the java class imported from blueprints.
6
+ class Neo4jVertex
7
+ include Pacer::Core::Graph::VerticesRoute
8
+ include ElementMixin
9
+ include VertexMixin
10
+ end
11
+ end
@@ -0,0 +1,10 @@
1
+ require 'pacer-neo4j/version'
2
+
3
+ require 'pacer'
4
+ require Pacer::Neo4j::JAR
5
+
6
+ require 'pacer-neo4j/vertex'
7
+ require 'pacer-neo4j/edge'
8
+ require 'pacer-neo4j/index'
9
+ require 'pacer-neo4j/graph'
10
+ require 'pacer-neo4j/rspec' if defined? RSpec
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "pacer-neo4j/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "pacer-neo4j"
7
+ s.version = Pacer::Neo4j::VERSION
8
+ s.platform = 'java'
9
+ s.authors = ["Darrick Wiebe"]
10
+ s.email = ["darrick@innatesoftware.com"]
11
+ s.homepage = "http://neo4j.org"
12
+ s.summary = %q{Neo4J jars and related code for Pacer}
13
+ s.description = s.summary
14
+
15
+ s.add_dependency 'pacer', '>= 0.8.5'
16
+
17
+ s.rubyforge_project = "pacer-neo4j"
18
+
19
+ s.files = `git ls-files`.split("\n") + [Pacer::Neo4j::JAR_PATH]
20
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ s.require_paths = ["lib"]
22
+ end
@@ -0,0 +1,22 @@
1
+ <assembly>
2
+ <id>standalone</id>
3
+ <formats>
4
+ <format>jar</format>
5
+ </formats>
6
+ <includeBaseDirectory>false</includeBaseDirectory>
7
+
8
+ <fileSets>
9
+ <fileSet>
10
+ <directory>target/classes</directory>
11
+ <outputDirectory>/</outputDirectory>
12
+ </fileSet>
13
+ </fileSets>
14
+
15
+ <dependencySets>
16
+ <dependencySet>
17
+ <outputDirectory>/</outputDirectory>
18
+ <unpack>true</unpack>
19
+ <scope>runtime</scope>
20
+ </dependencySet>
21
+ </dependencySets>
22
+ </assembly>
data/pom.xml ADDED
@@ -0,0 +1,116 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project xmlns="http://maven.apache.org/POM/4.0.0"
3
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5
+ <modelVersion>4.0.0</modelVersion>
6
+ <groupId>com.tinkerpop.pacer</groupId>
7
+ <artifactId>pacer-neo4j</artifactId>
8
+ <!-- NOTE: the following properties are automatically updated based on the values in lib/pacer-neo4j/version.rb -->
9
+ <properties>
10
+ <gem.version>1.0.7.1</gem.version>
11
+ <blueprints.version>1.0</blueprints.version>
12
+ <pipes.version>0.8</pipes.version>
13
+ </properties>
14
+ <!-- NOTE: the following properties are automatically updated based on the values in lib/pacer-neo4j/version.rb -->
15
+ <version>${gem.version}</version>
16
+ <packaging>pom</packaging>
17
+ <url>https://github.com/pangloss/pacer</url>
18
+ <name>Pacer Neo4J dependencies and related code.</name>
19
+ <description>
20
+ </description>
21
+ <inceptionYear>2011</inceptionYear>
22
+ <developers>
23
+ <developer>
24
+ <name>Darrick Wiebe</name>
25
+ <email>darrick@innatesoftware.com</email>
26
+ <url>http://github.com/pangloss</url>
27
+ </developer>
28
+ </developers>
29
+ <dependencies>
30
+ <dependency>
31
+ <groupId>com.tinkerpop.blueprints</groupId>
32
+ <artifactId>blueprints-neo4j-graph</artifactId>
33
+ <version>${blueprints.version}</version>
34
+ </dependency>
35
+ </dependencies>
36
+
37
+ <repositories>
38
+ <repository>
39
+ <id>tinkerpop-repository</id>
40
+ <name>TinkerPop Maven2 Repository</name>
41
+ <url>http://tinkerpop.com/maven2</url>
42
+ <snapshots>
43
+ <enabled>true</enabled>
44
+ <updatePolicy>always</updatePolicy>
45
+ </snapshots>
46
+ </repository>
47
+ </repositories>
48
+
49
+ <distributionManagement>
50
+ <repository>
51
+ <id>tinkerpop-repository</id>
52
+ <name>TinkerPop Maven2 Repository</name>
53
+ <url>ftp://ftp.tinkerpop.com:21/public/maven2/</url>
54
+ </repository>
55
+ </distributionManagement>
56
+
57
+ <build>
58
+ <directory>${basedir}/target</directory>
59
+ <finalName>${project.artifactId}-${project.version}</finalName>
60
+ <resources>
61
+ <resource>
62
+ <directory>${basedir}/src/main/resources
63
+ </directory>
64
+ </resource>
65
+ </resources>
66
+ <testResources>
67
+ <testResource>
68
+ <directory>${basedir}/src/test/resources
69
+ </directory>
70
+ </testResource>
71
+ </testResources>
72
+ <plugins>
73
+ <plugin>
74
+ <artifactId>maven-compiler-plugin</artifactId>
75
+ <configuration>
76
+ <source>1.6</source>
77
+ <target>1.6</target>
78
+ </configuration>
79
+ </plugin>
80
+ <plugin>
81
+ <artifactId>maven-assembly-plugin</artifactId>
82
+ <version>2.2-beta-4</version>
83
+ <executions>
84
+ <execution>
85
+ <phase>package</phase>
86
+ <goals>
87
+ <goal>attached</goal>
88
+ </goals>
89
+ </execution>
90
+ </executions>
91
+ <configuration>
92
+ <descriptors>
93
+ <descriptor>pom/standalone.xml</descriptor>
94
+ </descriptors>
95
+ <finalName>${project.artifactId}-${project.version}</finalName>
96
+ <outputDirectory>lib</outputDirectory>
97
+ <workDirectory>target/assembly/work</workDirectory>
98
+ <tarLongFileMode>warn</tarLongFileMode>
99
+ </configuration>
100
+ </plugin>
101
+ <plugin>
102
+ <groupId>org.apache.maven.plugins</groupId>
103
+ <artifactId>maven-javadoc-plugin</artifactId>
104
+ <version>2.6.1</version>
105
+ </plugin>
106
+ </plugins>
107
+ <extensions>
108
+ <extension>
109
+ <groupId>org.apache.maven.wagon</groupId>
110
+ <artifactId>wagon-ftp</artifactId>
111
+ <version>1.0-alpha-6</version>
112
+ </extension>
113
+ </extensions>
114
+ </build>
115
+
116
+ </project>
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pacer-neo4j
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 1.0.7.1
6
+ platform: java
7
+ authors:
8
+ - Darrick Wiebe
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-15 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: pacer
16
+ version_requirements: &2056 !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ! '>='
19
+ - !ruby/object:Gem::Version
20
+ version: 0.8.5
21
+ none: false
22
+ requirement: *2056
23
+ prerelease: false
24
+ type: :runtime
25
+ description: Neo4J jars and related code for Pacer
26
+ email:
27
+ - darrick@innatesoftware.com
28
+ executables: []
29
+ extensions: []
30
+ extra_rdoc_files: []
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - README.md
35
+ - Rakefile
36
+ - lib/pacer-neo4j.rb
37
+ - lib/pacer-neo4j/edge.rb
38
+ - lib/pacer-neo4j/graph.rb
39
+ - lib/pacer-neo4j/index.rb
40
+ - lib/pacer-neo4j/rspec.rb
41
+ - lib/pacer-neo4j/version.rb
42
+ - lib/pacer-neo4j/vertex.rb
43
+ - pacer-neo4j.gemspec
44
+ - pom.xml
45
+ - pom/standalone.xml
46
+ - lib/pacer-neo4j-1.0.7.1-standalone.jar
47
+ homepage: http://neo4j.org
48
+ licenses: []
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ none: false
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ none: false
65
+ requirements: []
66
+ rubyforge_project: pacer-neo4j
67
+ rubygems_version: 1.8.15
68
+ signing_key:
69
+ specification_version: 3
70
+ summary: Neo4J jars and related code for Pacer
71
+ test_files: []
72
+ has_rdoc:
73
+ ...