From 752924ada87a9ccf0bae4d37536234421d545b13 Mon Sep 17 00:00:00 2001 From: Max De Marzi Date: Wed, 2 Nov 2011 16:47:36 -0500 Subject: [PATCH] added railtie to autoload tasks --- README.rdoc | 17 +++++++++-------- lib/neography.rb | 2 ++ lib/neography/railtie.rb | 8 ++++++++ lib/neography/tasks.rb | 2 +- 4 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 lib/neography/railtie.rb diff --git a/README.rdoc b/README.rdoc index a64a190..c219a73 100644 --- a/README.rdoc +++ b/README.rdoc @@ -40,15 +40,9 @@ in order to access the functionality. ==== Rails -Just add gem 'neography' to your Gemfile and run bundle install +Just add gem 'neography' to your Gemfile and run bundle install. -=== Tasks - -In your Rakefile or "lib/tasks/neography.rake", add: - - require 'neography/tasks' - -It will add the following rake tasks to your project: +The following tasks will be available to you: rake neo4j:install # Install Neo4j to the neo4j directory under your project rake neo4j:start # Start Neo4j @@ -59,6 +53,13 @@ It will add the following rake tasks to your project: Windows users will need to run in a command prompt with Administrative Privileges in order to install Neo4j as a Service. +If you are not using Rails, then add: + + require 'neography/tasks' + +to your Rakefile to have access to these tasks. + + === Documentation @neo = Neography::Rest.new({:protocol => 'http://', diff --git a/lib/neography.rb b/lib/neography.rb index e5835eb..0324909 100644 --- a/lib/neography.rb +++ b/lib/neography.rb @@ -41,5 +41,7 @@ def find_and_require_user_defined_code require 'neography/node' require 'neography/relationship' +require 'neography/railtie' if defined? Rails + find_and_require_user_defined_code diff --git a/lib/neography/railtie.rb b/lib/neography/railtie.rb new file mode 100644 index 0000000..bae7c89 --- /dev/null +++ b/lib/neography/railtie.rb @@ -0,0 +1,8 @@ +require 'rails' + +class Railtie < Rails::Railtie + + rake_tasks do + load "neography/tasks.rb" + end +end \ No newline at end of file diff --git a/lib/neography/tasks.rb b/lib/neography/tasks.rb index f5a0c2a..a65c944 100644 --- a/lib/neography/tasks.rb +++ b/lib/neography/tasks.rb @@ -84,7 +84,7 @@ if %x[reg query "HKU\\S-1-5-19"].size > 0 %x[neo4j/bin/Neo4j.bat restart] else - puts "You do not have administrative rights to stop the Neo4j Service" + puts "You do not have administrative rights to restart the Neo4j Service" end else %x[neo4j/bin/neo4j restart]