Skip to content

Commit

Permalink
adding relationship types
Browse files Browse the repository at this point in the history
  • Loading branch information
maxdemarzi committed Jun 14, 2013
1 parent 6db5b23 commit 739befe
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ Some of this functionality is shown here, but all of it is explained in the foll
* [Node relationships](https://github.com/maxdemarzi/neography/wiki/Node-relationships) - Create and get relationships between nodes.
* [Relationship](https://github.com/maxdemarzi/neography/wiki/Relationships) - Get and delete relationships.
* [Relationship properties](https://github.com/maxdemarzi/neography/wiki/Relationship-properties) - Create, get and delete relationship properties.
* [Relationship types](https://github.com/maxdemarzi/neography/wiki/Relationship-types) - List relationship types.
* [Node indexes](https://github.com/maxdemarzi/neography/wiki/Node-indexes) - List and create node indexes. Add, remove, get and search nodes in indexes.
* [Relationship indexes](https://github.com/maxdemarzi/neography/wiki/Relationship-indexes) - List and create relationships indexes. Add, remove, get and search relationships in indexes.
* [Auto indexes](https://github.com/maxdemarzi/neography/wiki/Auto-indexes) - Get, set and remove auto indexes.
Expand Down
8 changes: 8 additions & 0 deletions lib/neography/rest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
require 'neography/rest/relationship_properties'
require 'neography/rest/relationship_indexes'
require 'neography/rest/relationship_auto_indexes'
require 'neography/rest/relationship_types'
require 'neography/rest/cypher'
require 'neography/rest/gremlin'
require 'neography/rest/extensions'
Expand Down Expand Up @@ -55,6 +56,7 @@ def initialize(options = ENV['NEO4J_URL'] || {})
@relationship_properties = RelationshipProperties.new(@connection)
@relationship_indexes = RelationshipIndexes.new(@connection)
@relationship_auto_indexes = RelationshipAutoIndexes.new(@connection)
@relationship_types = RelationshipTypes.new(@connection)

@cypher = Cypher.new(@connection)
@gremlin = Gremlin.new(@connection)
Expand All @@ -63,6 +65,12 @@ def initialize(options = ENV['NEO4J_URL'] || {})
@clean = Clean.new(@connection)
end

# meta-data

def list_relationship_types
@relationship_types.list
end

# nodes

def get_root
Expand Down
14 changes: 14 additions & 0 deletions lib/neography/rest/relationship_types.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Neography
class Rest
class RelationshipTypes < Properties
extend Neography::Rest::Paths

add_path :all, "/relationship/types"

def list
@connection.get(all_path)
end

end
end
end
18 changes: 18 additions & 0 deletions spec/integration/rest_relationship_types_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require 'spec_helper'

describe Neography::Rest do
before(:each) do
@neo = Neography::Rest.new
end

describe "list relationship types" do
it "can get a listing of relationship types" do
new_node1 = @neo.create_node
new_node2 = @neo.create_node
new_relationship = @neo.create_relationship("friends", new_node1, new_node2)
rel_types = @neo.list_relationship_types
rel_types.should_not be_nil
rel_types.should include("friends")
end
end
end
16 changes: 16 additions & 0 deletions spec/unit/rest/relationship_types_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require 'spec_helper'

module Neography
class Rest
describe RelationshipTypes do

let(:connection) { stub(:configuration => "http://configuration") }
subject { RelationshipTypes.new(connection) }

it "lists all relationship types" do
connection.should_receive(:get).with("/relationship/types")
subject.list
end
end
end
end

0 comments on commit 739befe

Please sign in to comment.