Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added config settings for plugin paths #29

Merged
merged 1 commit into from
Mar 22, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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