neo4jr-simple 0.1.0 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +6 -0
- data/README.rdoc +9 -4
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/bin/neosh +8 -0
- data/lib/jars/graph-algo-0.2-20090815.182816-1.jar +0 -0
- data/lib/jars/jta-1.1.jar +0 -0
- data/lib/jars/neo-1.0-b10.jar +0 -0
- data/lib/jars/{shell-1.0-b9.jar → shell-1.0-b10.jar} +0 -0
- data/lib/neo4jr/cli.rb +8 -0
- data/lib/neo4jr/configuration.rb +1 -1
- data/lib/neo4jr/db.rb +1 -0
- data/lib/neo4jr/direction.rb +8 -0
- data/lib/neo4jr/node_extension.rb +7 -17
- data/lib/neo4jr/property_container_extension.rb +26 -0
- data/lib/neo4jr/relationship_extension.rb +10 -0
- data/lib/neo4jr/returnable_evaluator.rb +7 -0
- data/lib/neo4jr/version.rb +1 -1
- data/lib/neo4jr-simple.rb +11 -5
- data/neo4jr-simple.gemspec +17 -8
- data/spec/direction_spec.rb +7 -0
- data/spec/functional_example_spec.rb +16 -20
- data/spec/{node_extension_spec.rb → property_container_extension_spec.rb} +1 -2
- data/spec/spec_helper.rb +1 -4
- data/spec/test-imdb-database/tm_tx_log.1 +0 -0
- metadata +18 -11
- data/lib/jars/jta-1_1.jar +0 -0
- data/lib/jars/neo-1.0-b9.jar +0 -0
data/.gitignore
CHANGED
data/README.rdoc
CHANGED
@@ -21,8 +21,9 @@ A simple, ready to go JRuby wrapper for the Neo4j graph database engine which pr
|
|
21
21
|
|
22
22
|
== Getting Started
|
23
23
|
|
24
|
+
* {gem install neo4jr-simple} [http://gemcutter.org/gems/neo4jr-simple]
|
25
|
+
* {Neo4j API Docs} [http://api.neo4j.org/current/org/neo4j/api/core/package-summary.html]
|
24
26
|
* functional_example_spec includes examples of basic operations in neo4j like creating, retrieving and updating nodes along with simple traversal examples.
|
25
|
-
* Neo4j API: http://api.neo4j.org/current/org/neo4j/api/core/package-summary.html
|
26
27
|
|
27
28
|
Basic Node creation:
|
28
29
|
|
@@ -47,12 +48,14 @@ Traverse Database from a node:
|
|
47
48
|
return_when = Neo4jr::ReturnableEvaluator::ALL
|
48
49
|
relationships = Neo4jr::RelationshipType.outgoing(:acted_in)
|
49
50
|
|
50
|
-
traverser = philip_seymour_hoffman.traverse(order, stop_when, return_when,
|
51
|
+
traverser = philip_seymour_hoffman.traverse(order, stop_when, return_when, relationships)
|
51
52
|
traverser.each do |node|
|
52
53
|
#...
|
53
54
|
end
|
54
55
|
end
|
55
56
|
|
57
|
+
Use command line shell to query and modify the graph:
|
58
|
+
neosh -path <path_to_neo_db>
|
56
59
|
|
57
60
|
== Contributors
|
58
61
|
|
@@ -61,7 +64,9 @@ Traverse Database from a node:
|
|
61
64
|
* GitHub : https://github.com/mdeiters
|
62
65
|
* LinkedIn : http://www.linkedin.com/in/matthewdeiters
|
63
66
|
* Blog : http://www.theagiledeveloper.com
|
64
|
-
|
65
|
-
|
67
|
+
|
68
|
+
====Heinrich Klobuczek
|
69
|
+
* GitHub : https://github.com/klobuczek
|
70
|
+
* LinkedIn : http://www.linkedin.com/pub/heinrich-klobuczek/0/a71/39b
|
66
71
|
|
67
72
|
Copyright (c) 2009 Matthew Deiters. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -6,7 +6,7 @@ begin
|
|
6
6
|
Jeweler::Tasks.new do |gem|
|
7
7
|
gem.name = "neo4jr-simple"
|
8
8
|
gem.summary = %Q{A simple, ready to go JRuby wrapper for the Neo4j graph database engine.}
|
9
|
-
gem.description = %Q{Nothing more then Neo4j and Ruby goodness}
|
9
|
+
gem.description = %Q{A simple, ready to go JRuby wrapper for the Neo4j graph database engine. Nothing more then Neo4j and Ruby goodness}
|
10
10
|
gem.email = "matthew_deiters@mckinsey.com"
|
11
11
|
gem.homepage = "http://github.com/mdeiters/neo4jr-simple"
|
12
12
|
gem.authors = ["Matthew Deiters"]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
data/bin/neosh
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/neo4jr/cli.rb
ADDED
data/lib/neo4jr/configuration.rb
CHANGED
data/lib/neo4jr/db.rb
CHANGED
data/lib/neo4jr/direction.rb
CHANGED
@@ -3,5 +3,13 @@ module Neo4jr
|
|
3
3
|
OUTGOING = org.neo4j.api.core.Direction::OUTGOING
|
4
4
|
INCOMING = org.neo4j.api.core.Direction::INCOMING
|
5
5
|
BOTH = org.neo4j.api.core.Direction::BOTH
|
6
|
+
|
7
|
+
def self.from_string(value)
|
8
|
+
case value.upcase
|
9
|
+
when 'BOTH': return BOTH
|
10
|
+
when 'OUTGOING': return OUTGOING
|
11
|
+
when 'INCOMING': return INCOMING
|
12
|
+
end
|
13
|
+
end
|
6
14
|
end
|
7
15
|
end
|
@@ -1,22 +1,12 @@
|
|
1
|
-
|
2
|
-
org.neo4j.api.core.Node.java_class.ruby_class.class_eval do
|
1
|
+
org.neo4j.api.core.Node.java_class.ruby_class.class_eval do
|
3
2
|
|
4
3
|
def id
|
5
4
|
getId
|
6
5
|
end
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
def [](arg)
|
12
|
-
get_property(arg.to_s)
|
13
|
-
end
|
14
|
-
|
15
|
-
# Example:
|
16
|
-
# node[:name] = 'Matt'
|
17
|
-
#
|
18
|
-
def []=(arg, value)
|
19
|
-
set_property(arg.to_s, value)
|
6
|
+
|
7
|
+
def to_hash
|
8
|
+
extra_values = {:node_id => self.getId, :kind => 'Node'}
|
9
|
+
properties.merge extra_values
|
20
10
|
end
|
21
|
-
|
22
|
-
end
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# Extends the Node class with a hash style accessor methods to the node's properties
|
2
|
+
org.neo4j.api.core.PropertyContainer.java_class.ruby_class.class_eval do
|
3
|
+
|
4
|
+
# Example:
|
5
|
+
# node[:name] #=> 'Matt'
|
6
|
+
#
|
7
|
+
def [](arg)
|
8
|
+
get_property(arg.to_s)
|
9
|
+
end
|
10
|
+
|
11
|
+
# Example:
|
12
|
+
# node[:name] = 'Matt'
|
13
|
+
#
|
14
|
+
def []=(arg, value)
|
15
|
+
set_property(arg.to_s, value)
|
16
|
+
end
|
17
|
+
|
18
|
+
def properties
|
19
|
+
properties = {}
|
20
|
+
propertyKeys.each do |property|
|
21
|
+
properties[property] = self[property]
|
22
|
+
end
|
23
|
+
properties
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
org.neo4j.api.core.Relationship.java_class.ruby_class.class_eval do
|
2
|
+
|
3
|
+
def to_hash
|
4
|
+
extra_values = {:node_id => self.getId, :kind => 'Relationship'}
|
5
|
+
extra_values['type'] = self.getType.name
|
6
|
+
extra_values['to'] = self.getEndNode.id
|
7
|
+
properties.merge extra_values
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
data/lib/neo4jr/version.rb
CHANGED
data/lib/neo4jr-simple.rb
CHANGED
@@ -1,18 +1,24 @@
|
|
1
1
|
include Java
|
2
2
|
|
3
|
-
module
|
4
|
-
require 'jars/neo-1.0-
|
5
|
-
require 'jars/shell-1.0-
|
6
|
-
require 'jars/jta-
|
3
|
+
module Neo4jr
|
4
|
+
require 'jars/neo-1.0-b10.jar'
|
5
|
+
require 'jars/shell-1.0-b10.jar'
|
6
|
+
require 'jars/jta-1.1.jar'
|
7
|
+
require 'jars/graph-algo-0.2-20090815.182816-1.jar'
|
8
|
+
|
9
|
+
AllSimplePaths = org.neo4j.graphalgo.AllSimplePaths
|
7
10
|
end
|
8
11
|
|
9
12
|
require 'neo4jr/configuration'
|
10
13
|
require 'neo4jr/db'
|
11
14
|
require 'neo4jr/relationship_type'
|
12
15
|
require 'neo4jr/node_extension'
|
16
|
+
require 'neo4jr/relationship_extension'
|
17
|
+
require 'neo4jr/property_container_extension'
|
13
18
|
require 'neo4jr/traverser_extension'
|
14
19
|
require 'neo4jr/returnable_evaluator'
|
15
20
|
require 'neo4jr/stop_evaluator'
|
16
21
|
require 'neo4jr/order'
|
17
22
|
require 'neo4jr/direction'
|
18
|
-
require 'neo4jr/version'
|
23
|
+
require 'neo4jr/version'
|
24
|
+
require 'neo4jr/cli'
|
data/neo4jr-simple.gemspec
CHANGED
@@ -5,13 +5,15 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{neo4jr-simple}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Matthew Deiters"]
|
12
|
-
s.date = %q{2009-12-
|
13
|
-
s.
|
12
|
+
s.date = %q{2009-12-23}
|
13
|
+
s.default_executable = %q{neosh}
|
14
|
+
s.description = %q{A simple, ready to go JRuby wrapper for the Neo4j graph database engine. Nothing more then Neo4j and Ruby goodness}
|
14
15
|
s.email = %q{matthew_deiters@mckinsey.com}
|
16
|
+
s.executables = ["neosh"]
|
15
17
|
s.extra_rdoc_files = [
|
16
18
|
"LICENSE",
|
17
19
|
"README.rdoc"
|
@@ -23,15 +25,20 @@ Gem::Specification.new do |s|
|
|
23
25
|
"README.rdoc",
|
24
26
|
"Rakefile",
|
25
27
|
"VERSION",
|
26
|
-
"
|
27
|
-
"lib/jars/
|
28
|
-
"lib/jars/
|
28
|
+
"bin/neosh",
|
29
|
+
"lib/jars/graph-algo-0.2-20090815.182816-1.jar",
|
30
|
+
"lib/jars/jta-1.1.jar",
|
31
|
+
"lib/jars/neo-1.0-b10.jar",
|
32
|
+
"lib/jars/shell-1.0-b10.jar",
|
29
33
|
"lib/neo4jr-simple.rb",
|
34
|
+
"lib/neo4jr/cli.rb",
|
30
35
|
"lib/neo4jr/configuration.rb",
|
31
36
|
"lib/neo4jr/db.rb",
|
32
37
|
"lib/neo4jr/direction.rb",
|
33
38
|
"lib/neo4jr/node_extension.rb",
|
34
39
|
"lib/neo4jr/order.rb",
|
40
|
+
"lib/neo4jr/property_container_extension.rb",
|
41
|
+
"lib/neo4jr/relationship_extension.rb",
|
35
42
|
"lib/neo4jr/relationship_type.rb",
|
36
43
|
"lib/neo4jr/returnable_evaluator.rb",
|
37
44
|
"lib/neo4jr/stop_evaluator.rb",
|
@@ -39,8 +46,9 @@ Gem::Specification.new do |s|
|
|
39
46
|
"lib/neo4jr/version.rb",
|
40
47
|
"neo4jr-simple.gemspec",
|
41
48
|
"spec/db_spec.rb",
|
49
|
+
"spec/direction_spec.rb",
|
42
50
|
"spec/functional_example_spec.rb",
|
43
|
-
"spec/
|
51
|
+
"spec/property_container_extension_spec.rb",
|
44
52
|
"spec/returnable_evaluator_spec.rb",
|
45
53
|
"spec/spec.opts",
|
46
54
|
"spec/spec_helper.rb",
|
@@ -76,8 +84,9 @@ Gem::Specification.new do |s|
|
|
76
84
|
s.summary = %q{A simple, ready to go JRuby wrapper for the Neo4j graph database engine.}
|
77
85
|
s.test_files = [
|
78
86
|
"spec/db_spec.rb",
|
87
|
+
"spec/direction_spec.rb",
|
79
88
|
"spec/functional_example_spec.rb",
|
80
|
-
"spec/
|
89
|
+
"spec/property_container_extension_spec.rb",
|
81
90
|
"spec/returnable_evaluator_spec.rb",
|
82
91
|
"spec/spec_helper.rb",
|
83
92
|
"spec/stop_evaluator_spec.rb"
|
@@ -10,28 +10,24 @@ describe "Neo4j Working Examples" do
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
node_id
|
13
|
+
it 'cruds nodes' do
|
14
|
+
node_id = nil
|
15
|
+
#CREATES
|
16
|
+
Neo4jr::DB.execute do |neo|
|
17
|
+
node = neo.createNode
|
18
|
+
node[:name] = 'Deiters, Matt'
|
19
|
+
node_id = node.getId
|
22
20
|
end
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
21
|
+
|
22
|
+
#UPDATES
|
23
|
+
node = Neo4jr::DB.getNodeById(node_id)
|
24
|
+
node[:name].should == 'Deiters, Matt'
|
25
|
+
|
26
|
+
#DELETES
|
27
|
+
Neo4jr::DB.execute do |neo|
|
28
|
+
node = neo.getNodeById(node_id)
|
29
|
+
node.delete
|
29
30
|
end
|
30
|
-
|
31
|
-
it 'can later read the node' do
|
32
|
-
node = Neo4jr::DB.getNodeById(node_id)
|
33
|
-
node[:name].should == 'Deiters, Matt'
|
34
|
-
end
|
35
31
|
end
|
36
32
|
|
37
33
|
it 'can traverse a node using the raw API' do
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
|
-
describe '
|
3
|
+
describe 'property container extension' do
|
4
4
|
|
5
5
|
it "adds [] read accessor method for properties" do
|
6
6
|
tom_hanks = Neo4jr::DB.instance.getNodeById(893)
|
@@ -14,5 +14,4 @@ describe 'node extension' do
|
|
14
14
|
tom_hanks[:testing].should == '123'
|
15
15
|
end
|
16
16
|
end
|
17
|
-
|
18
17
|
end
|
data/spec/spec_helper.rb
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neo4jr-simple
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Deiters
|
@@ -9,8 +9,8 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-12-
|
13
|
-
default_executable:
|
12
|
+
date: 2009-12-23 00:00:00 -08:00
|
13
|
+
default_executable: neosh
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: 1.2.9
|
24
24
|
version:
|
25
|
-
description: Nothing more then Neo4j and Ruby goodness
|
25
|
+
description: A simple, ready to go JRuby wrapper for the Neo4j graph database engine. Nothing more then Neo4j and Ruby goodness
|
26
26
|
email: matthew_deiters@mckinsey.com
|
27
|
-
executables:
|
28
|
-
|
27
|
+
executables:
|
28
|
+
- neosh
|
29
29
|
extensions: []
|
30
30
|
|
31
31
|
extra_rdoc_files:
|
@@ -38,15 +38,20 @@ files:
|
|
38
38
|
- README.rdoc
|
39
39
|
- Rakefile
|
40
40
|
- VERSION
|
41
|
-
-
|
42
|
-
- lib/jars/
|
43
|
-
- lib/jars/
|
41
|
+
- bin/neosh
|
42
|
+
- lib/jars/graph-algo-0.2-20090815.182816-1.jar
|
43
|
+
- lib/jars/jta-1.1.jar
|
44
|
+
- lib/jars/neo-1.0-b10.jar
|
45
|
+
- lib/jars/shell-1.0-b10.jar
|
44
46
|
- lib/neo4jr-simple.rb
|
47
|
+
- lib/neo4jr/cli.rb
|
45
48
|
- lib/neo4jr/configuration.rb
|
46
49
|
- lib/neo4jr/db.rb
|
47
50
|
- lib/neo4jr/direction.rb
|
48
51
|
- lib/neo4jr/node_extension.rb
|
49
52
|
- lib/neo4jr/order.rb
|
53
|
+
- lib/neo4jr/property_container_extension.rb
|
54
|
+
- lib/neo4jr/relationship_extension.rb
|
50
55
|
- lib/neo4jr/relationship_type.rb
|
51
56
|
- lib/neo4jr/returnable_evaluator.rb
|
52
57
|
- lib/neo4jr/stop_evaluator.rb
|
@@ -54,8 +59,9 @@ files:
|
|
54
59
|
- lib/neo4jr/version.rb
|
55
60
|
- neo4jr-simple.gemspec
|
56
61
|
- spec/db_spec.rb
|
62
|
+
- spec/direction_spec.rb
|
57
63
|
- spec/functional_example_spec.rb
|
58
|
-
- spec/
|
64
|
+
- spec/property_container_extension_spec.rb
|
59
65
|
- spec/returnable_evaluator_spec.rb
|
60
66
|
- spec/spec.opts
|
61
67
|
- spec/spec_helper.rb
|
@@ -113,8 +119,9 @@ specification_version: 3
|
|
113
119
|
summary: A simple, ready to go JRuby wrapper for the Neo4j graph database engine.
|
114
120
|
test_files:
|
115
121
|
- spec/db_spec.rb
|
122
|
+
- spec/direction_spec.rb
|
116
123
|
- spec/functional_example_spec.rb
|
117
|
-
- spec/
|
124
|
+
- spec/property_container_extension_spec.rb
|
118
125
|
- spec/returnable_evaluator_spec.rb
|
119
126
|
- spec/spec_helper.rb
|
120
127
|
- spec/stop_evaluator_spec.rb
|
data/lib/jars/jta-1_1.jar
DELETED
Binary file
|
data/lib/jars/neo-1.0-b9.jar
DELETED
Binary file
|