From 86095cd72b1e256b8a5d9aaec70e993d9d5851e6 Mon Sep 17 00:00:00 2001 From: nickflux Date: Mon, 19 Mar 2012 17:11:23 +0000 Subject: [PATCH] Update to config to allow for different locations for cypher and gremlin plugins --- lib/neography/config.rb | 24 +++++++++++++----------- lib/neography/rest.rb | 12 ++++++++---- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/lib/neography/config.rb b/lib/neography/config.rb index 0a0858c..efebf0f 100644 --- a/lib/neography/config.rb +++ b/lib/neography/config.rb @@ -1,17 +1,19 @@ module Neography class Config - class << self; attr_accessor :protocol, :server, :port, :directory, :log_file, :log_enabled, :logger, :max_threads, :authentication, :username, :password end + class << self; attr_accessor :protocol, :server, :port, :directory, :cypher_path, :gremlin_path, :log_file, :log_enabled, :logger, :max_threads, :authentication, :username, :password end - @protocol = 'http://' - @server = 'localhost' - @port = 7474 - @directory = '' - @log_file = 'neography.log' - @log_enabled = false - @logger = Logger.new(@log_file) if @log_enabled - @max_threads = 20 + @protocol = 'http://' + @server = 'localhost' + @port = 7474 + @directory = '' + @cypher_path = '/cypher' + @gremlin_path = '/ext/GremlinPlugin/graphdb/execute_script' + @log_file = 'neography.log' + @log_enabled = false + @logger = Logger.new(@log_file) if @log_enabled + @max_threads = 20 @authentication = {} - @username = nil - @password = nil + @username = nil + @password = nil end end \ No newline at end of file diff --git a/lib/neography/rest.rb b/lib/neography/rest.rb index 7cfa5f4..7f7a333 100644 --- a/lib/neography/rest.rb +++ b/lib/neography/rest.rb @@ -2,13 +2,15 @@ module Neography class Rest include HTTParty - attr_accessor :protocol, :server, :port, :directory, :log_file, :log_enabled, :logger, :max_threads, :authentication, :username, :password + attr_accessor :protocol, :server, :port, :directory, :cypher_path, :gremlin_path, :log_file, :log_enabled, :logger, :max_threads, :authentication, :username, :password def initialize(options=ENV['NEO4J_URL'] || {}) init = {:protocol => Neography::Config.protocol, :server => Neography::Config.server, :port => Neography::Config.port, - :directory => Neography::Config.directory, + :directory => Neography::Config.directory, + :cypher_path => Neography::Config.cypher_path, + :gremlin_path => Neography::Config.gremlin_path, :log_file => Neography::Config.log_file, :log_enabled => Neography::Config.log_enabled, :max_threads => Neography::Config.max_threads, @@ -34,6 +36,8 @@ def initialize(options=ENV['NEO4J_URL'] || {}) @server = init[:server] @port = init[:port] @directory = init[:directory] + @cypher_path = init[:cypher_path] + @gremlin_path = init[:gremlin_path] @log_file = init[:log_file] @log_enabled = init[:log_enabled] @logger = Logger.new(@log_file) if @log_enabled @@ -356,12 +360,12 @@ def get_paths(from, to, relationships, depth=1, algorithm="allPaths") def execute_query(query, params = {}) options = { :body => {:query => query, :params => params}.to_json, :headers => {'Content-Type' => 'application/json'} } - result = post("/cypher", options) + result = post(@cypher_path, options) end def execute_script(script, params = {}) options = { :body => {:script => script, :params => params}.to_json , :headers => {'Content-Type' => 'application/json'} } - result = post("/ext/GremlinPlugin/graphdb/execute_script", options) + result = post(@gremlin_path, options) result == "null" ? nil : result end