Configuration and initialization

Jason Gilmore edited this page Dec 19, 2013 · 5 revisions

Configuration

To configure Neography within your Rails application, create the file /config/initializers/neography.rb and paste in the following content:

# these are the default values:
Neography.configure do |config|
  config.protocol       = "http://"
  config.server         = "localhost"
  config.port           = 7474
  config.directory      = ""  # prefix this path with '/' 
  config.cypher_path    = "/cypher"
  config.gremlin_path   = "/ext/GremlinPlugin/graphdb/execute_script"
  config.log_file       = "neography.log"
  config.log_enabled    = false
  config.max_threads    = 20
  config.authentication = nil  # 'basic' or 'digest'
  config.username       = nil
  config.password       = nil
  config.parser         = MultiJsonParser
end

Initialization

Then initialize as follows:

@neo = Neography::Rest.new

Overriding default configuration

You can override the configured values as follows:

@neo = Neography::Rest.new({ :protocol       => 'http://',
                             :server         => 'localhost',
                             :port           => 7474,
                             :directory      => '',
                             :authentication => 'basic',
                             :username       => 'your username',
                             :password       => 'your password',
                             :log_file       => 'neography.log',
                             :log_enabled    => false,
                             :max_threads    => 20,
                             :cypher_path    => '/cypher',
                             :gremlin_path   => '/ext/GremlinPlugin/graphdb/execute_script' })

Quick initialization

@neo = Neography::Rest.new("http://username:password@myserver.com:7474/mydirectory")

Basic authentication is assumed if a if username is given.