Skip to content
Browse files

WIP Neo4j::Cypher

  • Loading branch information...
1 parent 78502ca commit f7a0c93a454c10123857421ab55744f4f7e23519 Micah Cooper and Travis Anderson committed with Hashrocket Workstation Sep 25, 2012
Showing with 24 additions and 18 deletions.
  1. +1 −0 keymaker.gemspec
  2. +1 −16 lib/keymaker/node.rb
  3. +22 −2 spec/keymaker_spec.rb
View
1 keymaker.gemspec
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
s.add_dependency 'hashie'
s.add_dependency 'faraday'
s.add_dependency 'faraday_middleware'
+ s.add_dependency 'neo4j-cypher'
s.add_development_dependency 'fakeweb'
s.add_development_dependency 'rake'
View
17 lib/keymaker/node.rb
@@ -42,26 +42,11 @@ def properties
property_traits.keys
end
- def property(attribute,type=String)
+ def property(attribute, type = String)
property_traits[attribute] = type
attr_accessor attribute
end
- def find_by_cypher(query, params={}, return_type=:results_only)
- executed_query = neo_service.execute_cypher(query, params)
- if executed_query.present?
- case return_type
- when :results_only
- executed_query["data"].flatten
- # TODO: Make this less specific
- when :full_user
- {"user" => executed_query["data"].flatten[0]["data"], "neo_id" => executed_query["data"].flatten[1]}
- end
- else
- return []
- end
- end
-
end
def initialize(attrs)
View
24 spec/keymaker_spec.rb
@@ -1,6 +1,7 @@
require 'spec_helper'
require "addressable/uri"
require 'keymaker'
+require 'neo4j-cypher'
describe Keymaker do
@@ -154,8 +155,6 @@ def do_it
let(:do_it) { service.execute_cypher(cypher_string, {}) }
- before { service.add_node_to_index(:users, :email, john_email, john_node_id) }
-
context "setting key with as" do
let(:cypher_string) { "START n=node(*) RETURN n.email AS email" }
@@ -180,6 +179,27 @@ def do_it
end
end
+ context "with no return" do
+ let(:cypher_string) { "CREATE n={email: 'kyle@resistance.net' }" }
+
+ it "returns an empty array" do
+ do_it.should == []
+ end
+
+ end
+
+ context "with a Neo4j::Cypher::Result" do
+ let(:cypher_string) do
+ ::Neo4j::Cypher.query do
+ n = node("*").ret(:email).as(:email)
+ end
+ end
+
+ it "performs the cypher query and responds" do
+ do_it.first.email.should == john_email
+ end
+ end
+
end
context "nodes" do

0 comments on commit f7a0c93

Please sign in to comment.
Something went wrong with that request. Please try again.