Permalink
Browse files

a little cleaner setup

  • Loading branch information...
1 parent 7e67ba8 commit fcf50b6ef0f937406b2a0e8efe118d46b6551878 @maxdemarzi committed Jan 6, 2012
Showing with 10 additions and 8 deletions.
  1. +2 −0 config.ru
  2. +8 −8 neovigator.rb
View
@@ -1,3 +1,5 @@
+$LOAD_PATH.unshift File.dirname(__FILE__)
+
require 'rubygems'
require 'bundler'
View
@@ -8,12 +8,8 @@ class Neovigator < Sinatra::Application
set :app_file, __FILE__
configure :test do
- require 'net-http-spy'
- Net::HTTP.http_logger_options = {:verbose => true}
- end
-
- before do
- @neo = Neography::Rest.new
+ require 'net-http-spy'
+ Net::HTTP.http_logger_options = {:verbose => true}
end
helpers do
@@ -22,6 +18,10 @@ def link_to(url, text=url, opts={})
opts.each { |key,value| attributes << key.to_s << "=\"" << value << "\" "}
"<a href=\"#{url}\" #{attributes}>#{text}</a>"
end
+
+ def neo
+ @neo ||= ENV['NEO4J_URL'].nil? ? Neography::Rest.new : Neography::Rest.new(ENV['NEO4J_URL'])
+ end
end
def neighbours
@@ -53,8 +53,8 @@ def get_properties(node)
get '/resources/show' do
content_type :json
- node = @neo.get_node(params[:id])
- connections = @neo.traverse(node, "fullpath", neighbours)
+ node = neo.get_node(params[:id])
+ connections = neo.traverse(node, "fullpath", neighbours)
incoming = Hash.new{|h, k| h[k] = []}
outgoing = Hash.new{|h, k| h[k] = []}
nodes = Hash.new

0 comments on commit fcf50b6

Please sign in to comment.