From 0d17d0a11b5013b3b8d338981e097742c1cb7793 Mon Sep 17 00:00:00 2001 From: Max De Marzi Date: Wed, 27 Jun 2012 10:04:41 -0500 Subject: [PATCH] adding multiple ways to remove a node from an index --- Gemfile.lock | 3 +-- lib/neography/rest.rb | 14 +++++++++----- spec/integration/rest_batch_spec.rb | 13 +++++++++---- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2a32a47..1283996 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - neography (0.0.26) + neography (0.0.28) httparty (>= 0.8.1) json oj @@ -17,7 +17,6 @@ GEM multi_json (~> 1.0) multi_xml json (1.7.3) - json (1.7.3-java) multi_json (1.3.6) multi_xml (0.5.1) net-http-spy (0.2.1) diff --git a/lib/neography/rest.rb b/lib/neography/rest.rb index 4bf8ea4..9d3d113 100644 --- a/lib/neography/rest.rb +++ b/lib/neography/rest.rb @@ -474,13 +474,17 @@ def get_batch(args) {:method => "POST", :to => @cypher_path, :body => {:query => args[1]}} end when :remove_node_from_index - {:method => "DELETE", :to => "/index/node/#{args[1]}/#{args[2]}/#{args[3]}/#{get_id(args[4])}" } - when :delete_node - {:method => "DELETE", :to => "/node/#{get_id(args[1])}"} - else + case args.size + when 5 then {:method => "DELETE", :to => "/index/node/#{args[1]}/#{args[2]}/#{args[3]}/#{get_id(args[4])}" } + when 4 then {:method => "DELETE", :to => "/index/node/#{args[1]}/#{args[2]}/#{get_id(args[3])}" } + when 3 then {:method => "DELETE", :to => "/index/node/#{args[1]}/#{get_id(args[2])}" } + end + when :delete_node + {:method => "DELETE", :to => "/node/#{get_id(args[1])}"} + else raise "Unknown option #{args[0]}" end - end + end def evaluate_response(response) code = response.code diff --git a/spec/integration/rest_batch_spec.rb b/spec/integration/rest_batch_spec.rb index 283ae9f..283829d 100644 --- a/spec/integration/rest_batch_spec.rb +++ b/spec/integration/rest_batch_spec.rb @@ -282,15 +282,20 @@ index = generate_text(6) key = generate_text(6) value1 = generate_text - value2 = generate_text + value2 = generate_text + value3 = generate_text - node1 = @neo.create_unique_node( index , key , value1 , { "name" => "Max" } ) - node2 = @neo.create_unique_node( index , key , value2 , { "name" => "Neo" }) + node1 = @neo.create_unique_node(index, key, value1, { "name" => "Max" }) + node2 = @neo.create_unique_node(index, key, value2, { "name" => "Neo" }) + node3 = @neo.create_unique_node(index, key, value3, { "name" => "Samir"}) - batch_result = @neo.batch [:remove_node_from_index, index, key, value1, node1 ], [:remove_node_from_index, index, key, value2, node2 ] + batch_result = @neo.batch [:remove_node_from_index, index, key, value1, node1 ], + [:remove_node_from_index, index, key, node2 ], + [:remove_node_from_index, index, node3 ] @neo.get_node_index(index, key, value1).should be_nil @neo.get_node_index(index, key, value2).should be_nil + @neo.get_node_index(index, key, value3).should be_nil end end