diff --git a/README.md b/README.md index 983a8ad..fbf7f8e 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/lib/neography/rest.rb b/lib/neography/rest.rb index 6e17452..dba6afb 100644 --- a/lib/neography/rest.rb +++ b/lib/neography/rest.rb @@ -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' @@ -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) @@ -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 diff --git a/lib/neography/rest/relationship_types.rb b/lib/neography/rest/relationship_types.rb new file mode 100644 index 0000000..e98c977 --- /dev/null +++ b/lib/neography/rest/relationship_types.rb @@ -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 diff --git a/spec/integration/rest_relationship_types_spec.rb b/spec/integration/rest_relationship_types_spec.rb new file mode 100644 index 0000000..277c5bf --- /dev/null +++ b/spec/integration/rest_relationship_types_spec.rb @@ -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 \ No newline at end of file diff --git a/spec/unit/rest/relationship_types_spec.rb b/spec/unit/rest/relationship_types_spec.rb new file mode 100644 index 0000000..19f7cc0 --- /dev/null +++ b/spec/unit/rest/relationship_types_spec.rb @@ -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