Skip to content

Commit

Permalink
Update to config to allow for different locations for cypher and gremlin
Browse files Browse the repository at this point in the history
plugins
  • Loading branch information
nickflux committed Mar 19, 2012
1 parent 9e4540e commit 86095cd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
24 changes: 13 additions & 11 deletions lib/neography/config.rb
Original file line number Diff line number Diff line change
@@ -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
12 changes: 8 additions & 4 deletions lib/neography/rest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 86095cd

Please sign in to comment.