neo4jr-simple 0.1.0 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -19,3 +19,9 @@ rdoc
19
19
  pkg
20
20
 
21
21
  ## PROJECT::SPECIFIC
22
+
23
+ ##Netbeans
24
+ nbproject
25
+
26
+ ##Rubymine
27
+ .idea
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, relationships_of_type)
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
- == Copyright
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.0
1
+ 0.1.3
data/bin/neosh ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ $LOAD_PATH << File.expand_path(File.dirname(__FILE__) + "/../lib")
5
+ require 'neo4jr-simple.rb'
6
+
7
+
8
+ Neo4jr::CLI.execute(ARGV)
Binary file
Binary file
data/lib/neo4jr/cli.rb ADDED
@@ -0,0 +1,8 @@
1
+ module Neo4jr
2
+ class CLI
3
+ def self.execute arguments=[]
4
+ org.neo4j.util.shell.StartClient.main arguments.to_java(:String)
5
+ end
6
+ end
7
+ end
8
+
@@ -2,7 +2,7 @@ module Neo4jr
2
2
  class Configuration
3
3
  class << self
4
4
  def database_path
5
- @database_path ||= 'tmp-neo4j-db'
5
+ @database_path ||= Dir.mktmpdir #Dir.tmpdir + '/tmp-neo4j-db'
6
6
  end
7
7
 
8
8
  def database_path=(value)
data/lib/neo4jr/db.rb CHANGED
@@ -4,6 +4,7 @@ module Neo4jr
4
4
  def instance
5
5
  @neo ||= begin
6
6
  neo = org.neo4j.api.core.EmbeddedNeo.new(Configuration.database_path)
7
+ neo.enable_remote_shell
7
8
  at_exit do
8
9
  neo.shutdown
9
10
  end
@@ -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
- # Extends the Node class with a hash style accessor methods to the node's properties
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
- # Example:
9
- # node[:name] #=> 'Matt'
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
@@ -24,6 +24,13 @@ module Neo4jr
24
24
  end
25
25
  instance
26
26
  end
27
+
28
+ def self.everything
29
+ self.when do |position|
30
+ true
31
+ end
32
+ end
33
+
27
34
  end
28
35
 
29
36
  Return = ReturnableEvaluator
@@ -1,3 +1,3 @@
1
1
  module Neo4jr
2
- VERSION = File.read('VERSION') unless defined?(Neo4jr::VERSION)
2
+ VERSION = File.read(File.expand_path(File.dirname(__FILE__) + "/../../VERSION")) unless defined?(Neo4jr::VERSION)
3
3
  end
data/lib/neo4jr-simple.rb CHANGED
@@ -1,18 +1,24 @@
1
1
  include Java
2
2
 
3
- module Neo4j
4
- require 'jars/neo-1.0-b9.jar'
5
- require 'jars/shell-1.0-b9.jar'
6
- require 'jars/jta-1_1.jar'
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'
@@ -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.0"
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-18}
13
- s.description = %q{Nothing more then Neo4j and Ruby goodness}
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
- "lib/jars/jta-1_1.jar",
27
- "lib/jars/neo-1.0-b9.jar",
28
- "lib/jars/shell-1.0-b9.jar",
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/node_extension_spec.rb",
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/node_extension_spec.rb",
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"
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Neo4jr::Direction do
4
+ it 'can convert from string to type' do
5
+ Neo4jr::Direction.from_string('both').should == Neo4jr::Direction::BOTH
6
+ end
7
+ end
@@ -10,28 +10,24 @@ describe "Neo4j Working Examples" do
10
10
  end
11
11
  end
12
12
 
13
- describe 'cruding a node' do
14
- let(:node_id) do
15
- node_id = nil
16
- Neo4jr::DB.execute do |neo|
17
- node = neo.createNode
18
- node[:name] = 'Deiters, Matt'
19
- node_id = node.getId
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
- after :each do
25
- Neo4jr::DB.execute do |neo|
26
- node = neo.getNodeById(node_id)
27
- node.delete
28
- end
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 'node extension' do
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
@@ -9,7 +9,4 @@ puts Neo4jr::DB
9
9
 
10
10
  Spec::Runner.configure do |config|
11
11
 
12
- end
13
-
14
-
15
-
12
+ end
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.0
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-18 00:00:00 -08:00
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
- - lib/jars/jta-1_1.jar
42
- - lib/jars/neo-1.0-b9.jar
43
- - lib/jars/shell-1.0-b9.jar
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/node_extension_spec.rb
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/node_extension_spec.rb
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
Binary file