neo4jr-simple 0.1.8 → 0.2.0
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/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
@@ -16,5 +16,12 @@ org.neo4j.kernel.EmbeddedGraphDatabase.java_class.ruby_class.class_eval do
|
|
16
16
|
def find_node_by_identifier(identifier_value)
|
17
17
|
Neo4jr::Indexer.find_node_by_identifier(identifier_value)
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
|
+
def find_node(value)
|
21
|
+
find_node_by_identifier(value) || begin
|
22
|
+
node_id = value.to_f
|
23
|
+
getNodeById(node_id) if node_id > 0
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
20
27
|
end
|
@@ -1,8 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
# end
|
1
|
+
org.neo4j.kernel.impl.core.IntArrayIterator.java_class.ruby_class.class_eval do
|
2
|
+
|
3
|
+
def hashify_objects
|
4
|
+
map{|object| object.to_hash }
|
5
|
+
end
|
6
|
+
|
7
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe org.neo4j.kernel.EmbeddedGraphDatabase do
|
4
|
+
|
5
|
+
it 'first finds nodes by the value if it has been indexed' do
|
6
|
+
node_expected = nil
|
7
|
+
identifier = Neo4jr::DB.execute do |neo|
|
8
|
+
node_1 = neo.create_node()
|
9
|
+
node_expected = neo.create_node('identifier' => node_1.getId)
|
10
|
+
node_1.getId
|
11
|
+
end
|
12
|
+
|
13
|
+
Neo4jr::DB.execute do |neo|
|
14
|
+
found_node = neo.find_node(identifier)
|
15
|
+
node_expected.getId.should == found_node.getId
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'finds nodes by node id when nothing with the identifier' do
|
20
|
+
node_expected = nil
|
21
|
+
identifier = Neo4jr::DB.execute do |neo|
|
22
|
+
node_expected = neo.create_node()
|
23
|
+
node_expected.getId
|
24
|
+
end
|
25
|
+
|
26
|
+
Neo4jr::DB.execute do |neo|
|
27
|
+
found_node = neo.find_node(identifier)
|
28
|
+
node_expected.getId.should == found_node.getId
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should not attempt to getnodes by id if identifier is not a number' do
|
33
|
+
Neo4jr::DB.execute do |neo|
|
34
|
+
neo.find_node('some_string').should be_nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -1,5 +1,13 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
3
|
describe 'IntArrayIterartor' do
|
4
|
+
|
5
|
+
it 'can convert relationships into a hash' do
|
6
|
+
Neo4jr::DB.execute do |neo|
|
7
|
+
philip_seymour_hoffman = neo.getNodeById(1102)
|
8
|
+
relationships = philip_seymour_hoffman.getRelationships
|
9
|
+
lambda{relationships.hashify_objects}.should_not raise_error
|
10
|
+
end
|
11
|
+
end
|
4
12
|
|
5
13
|
end
|
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.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Deiters
|
@@ -105,6 +105,7 @@ test_files:
|
|
105
105
|
- VERSION
|
106
106
|
- spec/db_spec.rb
|
107
107
|
- spec/direction_spec.rb
|
108
|
+
- spec/embedded_graph_database_spec.rb
|
108
109
|
- spec/functional_example_spec.rb
|
109
110
|
- spec/indexer_spec.rb
|
110
111
|
- spec/int_array_iterator_extension_spec.rb
|