diff --git a/lib/neography/config.rb b/lib/neography/config.rb index c8f70b2..0a0858c 100644 --- a/lib/neography/config.rb +++ b/lib/neography/config.rb @@ -1,6 +1,6 @@ module Neography class Config - class << self; attr_accessor :protocol, :server, :port, :directory, :log_file, :log_enabled, :logger, :max_threads, :authentication end + class << self; attr_accessor :protocol, :server, :port, :directory, :log_file, :log_enabled, :logger, :max_threads, :authentication, :username, :password end @protocol = 'http://' @server = 'localhost' @@ -11,5 +11,7 @@ class << self; attr_accessor :protocol, :server, :port, :directory, :log_file, : @logger = Logger.new(@log_file) if @log_enabled @max_threads = 20 @authentication = {} + @username = nil + @password = nil end end \ No newline at end of file diff --git a/lib/neography/node_index.rb b/lib/neography/node_index.rb new file mode 100644 index 0000000..c0c402a --- /dev/null +++ b/lib/neography/node_index.rb @@ -0,0 +1,9 @@ +module Neography + module NodeIndex + + def find + + end + + end +end \ No newline at end of file diff --git a/lib/neography/rest.rb b/lib/neography/rest.rb index 4b01f13..0b8c44f 100644 --- a/lib/neography/rest.rb +++ b/lib/neography/rest.rb @@ -5,14 +5,16 @@ class Rest attr_accessor :protocol, :server, :port, :directory, :log_file, :log_enabled, :logger, :max_threads, :authentication, :username, :password def initialize(options={}) - init = {:protocol => Neography::Config.protocol, - :server => Neography::Config.server, - :port => Neography::Config.port, - :directory => Neography::Config.directory, - :log_file => Neography::Config.log_file, - :log_enabled => Neography::Config.log_enabled, - :max_threads => Neography::Config.max_threads, - :authentication => Neography::Config.authentication} + init = {:protocol => Neography::Config.protocol, + :server => Neography::Config.server, + :port => Neography::Config.port, + :directory => Neography::Config.directory, + :log_file => Neography::Config.log_file, + :log_enabled => Neography::Config.log_enabled, + :max_threads => Neography::Config.max_threads, + :authentication => Neography::Config.authentication, + :username => Neography::Config.username, + :password => Neography::Config.password} unless options.respond_to?(:each_pair) url = URI.parse(options) @@ -21,12 +23,13 @@ def initialize(options={}) options[:server] = url.host options[:port] = url.port options[:directory] = url.path - options[:user] = url.user + options[:username] = url.user options[:password] = url.password options[:authentication] = 'basic' unless url.user.nil? end init.merge!(options) + puts init.inspect @protocol = init[:protocol] @server = init[:server] @@ -38,6 +41,7 @@ def initialize(options={}) @max_threads = init[:max_threads] @authentication = Hash.new @authentication = {"#{init[:authentication]}_auth".to_sym => {:username => init[:username], :password => init[:password]}} unless init[:authentication].empty? + puts "Authentication: #{@authentication.inspect}" end def configure(protocol, server, port, directory) diff --git a/spec/integration/index_spec.rb b/spec/integration/index_spec.rb new file mode 100644 index 0000000..005448e --- /dev/null +++ b/spec/integration/index_spec.rb @@ -0,0 +1,31 @@ +require File.join(File.dirname(__FILE__), '..', 'spec_helper') + +describe Neography::Relationship, "find" do + before(:each) do + Neography::Relationship.index(:strength) + end + + it "can index when Neography::Relationships are created" do + a = Neography::Node.create + b = Neography::Node.create + r = Neography::Relationship.create(:friends, a, b) + r[:strength] = 'strong' + Neography::Relationship.find('strength: strong').first.should == r + end + + it "can remove index when Neography::Relationship is deleted, just like nodes" do + a = Neography::Node.create + b = Neography::Node.create + r = Neography::Relationship.create(:friends, a, b) + r[:strength] = 'weak' + r2 = Neography::Relationship.find('strength: weak').first + r2.should == r + r2.del + Neography::Relationship.find('strength: weak').should be_empty + end +end + + +describe Neography::Node, "find" do + +end