diff --git a/lib/neography/rest/node_labels.rb b/lib/neography/rest/node_labels.rb index 27968eb..85ab331 100644 --- a/lib/neography/rest/node_labels.rb +++ b/lib/neography/rest/node_labels.rb @@ -7,7 +7,7 @@ class NodeLabels add_path :base, "/labels" add_path :node, "/node/:id/labels" add_path :nodes, "/label/:label/nodes" - add_path :find, "/label/:label/nodes?:property=%22:value%22" + add_path :find, "/label/:label/nodes?:property=:value" add_path :delete, "/node/:id/labels/:label" def initialize(connection) diff --git a/lib/neography/rest/paths.rb b/lib/neography/rest/paths.rb index b322542..db05425 100644 --- a/lib/neography/rest/paths.rb +++ b/lib/neography/rest/paths.rb @@ -21,9 +21,19 @@ def add_path(key, path) end end + def build_path(path, attributes) - path.gsub(/:([\w_]*)/) do - encode(attributes[$1.to_sym].to_s) + p = String.new(path) + p.gsub!(/=:([\w_]*)/) do + if $1.to_sym == :value and attributes[$1.to_sym].class == String + "=%22"+encode(attributes[$1.to_sym].to_s)+"%22"; + else + "="+encode(attributes[$1.to_sym].to_s) + end + end + + p.gsub(/:([\w_]*)/) do + encode(attributes[$1.to_sym].to_s) end end diff --git a/spec/unit/rest/labels_spec.rb b/spec/unit/rest/labels_spec.rb index dab5147..8939dbe 100644 --- a/spec/unit/rest/labels_spec.rb +++ b/spec/unit/rest/labels_spec.rb @@ -22,11 +22,16 @@ class Rest subject.get_nodes("person") end - it "find nodes for labels and property" do + it "find nodes for labels and property string" do connection.should_receive(:get).with("/label/person/nodes?name=%22max%22") subject.find_nodes("person", {:name => "max"}) end + it "find nodes for labels and property integer" do + connection.should_receive(:get).with("/label/person/nodes?age=26") + subject.find_nodes("person", {:age => 26}) + end + it "can add a label to a node" do options = { :body => '["Actor"]',