Class: Neo4jTest::Server
- Inherits:
-
Object
- Object
- Neo4jTest::Server
- Defined in:
- lib/neo4j_test_server/neo4j_server.rb
Constant Summary collapse
- ServerError =
Raised if #stop is called but the server is not running
Class.new(RuntimeError)
- AlreadyRunningError =
Class.new(ServerError)
- NotRunningError =
Class.new(ServerError)
- JavaMissing =
Class.new(ServerError)
Instance Attribute Summary collapse
- #bind_address ⇒ Object
-
#edition ⇒ Object
Returns the value of attribute edition.
-
#neo4j_data_dir ⇒ Object
writeonly
Sets the attribute neo4j_data_dir.
-
#neo4j_home ⇒ Object
writeonly
Sets the attribute neo4j_home.
-
#neo4j_jar ⇒ Object
writeonly
Sets the attribute neo4j_jar.
- #port ⇒ Object
Instance Method Summary collapse
- #bootstrap ⇒ Object
- #ensure_java_installed ⇒ Object
-
#initialize(ed = 'community-2.2.0') ⇒ Server
constructor
A new instance of Server.
- #install_location ⇒ Object
- #start ⇒ Object
- #start_command ⇒ Object
- #start_starnix_server(command) ⇒ Object
- #start_windows_server(command) ⇒ Object
- #stop ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(ed = 'community-2.2.0') ⇒ Server
Returns a new instance of Server.
18 19 20 21 |
# File 'lib/neo4j_test_server/neo4j_server.rb', line 18 def initialize(ed = 'community-2.2.0') ensure_java_installed self.edition = ed end |
Instance Attribute Details
#bind_address ⇒ Object
34 35 36 |
# File 'lib/neo4j_test_server/neo4j_server.rb', line 34 def bind_address @bind_address ||= '127.0.0.1' end |
#edition ⇒ Object
Returns the value of attribute edition.
14 15 16 |
# File 'lib/neo4j_test_server/neo4j_server.rb', line 14 def edition @edition end |
#neo4j_data_dir=(value) ⇒ Object (writeonly)
Sets the attribute neo4j_data_dir
16 17 18 |
# File 'lib/neo4j_test_server/neo4j_server.rb', line 16 def neo4j_data_dir=(value) @neo4j_data_dir = value end |
#neo4j_home=(value) ⇒ Object (writeonly)
Sets the attribute neo4j_home
16 17 18 |
# File 'lib/neo4j_test_server/neo4j_server.rb', line 16 def neo4j_home=(value) @neo4j_home = value end |
#neo4j_jar=(value) ⇒ Object (writeonly)
Sets the attribute neo4j_jar
16 17 18 |
# File 'lib/neo4j_test_server/neo4j_server.rb', line 16 def neo4j_jar=(value) @neo4j_jar = value end |
#port ⇒ Object
38 39 40 |
# File 'lib/neo4j_test_server/neo4j_server.rb', line 38 def port @port ||= '7474' end |
Instance Method Details
#bootstrap ⇒ Object
27 28 29 30 31 32 |
# File 'lib/neo4j_test_server/neo4j_server.rb', line 27 def bootstrap unless @bootstrapped Neo4jTest::Installer.bootstrap edition @bootstrapped = true end end |
#ensure_java_installed ⇒ Object
82 83 84 85 86 87 88 89 90 |
# File 'lib/neo4j_test_server/neo4j_server.rb', line 82 def ensure_java_installed unless defined?(@java_installed) @java_installed = Neo4jTest::Java.installed? unless @java_installed raise JavaMissing.new('You need a Java Runtime Environment to run the Solr server') end end @java_installed end |
#install_location ⇒ Object
92 93 94 |
# File 'lib/neo4j_test_server/neo4j_server.rb', line 92 def install_location Neo4jTest::Installer.install_location end |
#start ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/neo4j_test_server/neo4j_server.rb', line 46 def start bootstrap puts 'Starting Neo4j...' if OS::Underlying.windows? start_windows_server(start_command) else start_starnix_server(start_command) end end |
#start_command ⇒ Object
42 43 44 |
# File 'lib/neo4j_test_server/neo4j_server.rb', line 42 def start_command @start_command ||= 'start' end |
#start_starnix_server(command) ⇒ Object
78 79 80 |
# File 'lib/neo4j_test_server/neo4j_server.rb', line 78 def start_starnix_server(command) `#{install_location}/bin/neo4j #{command}` end |
#start_windows_server(command) ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'lib/neo4j_test_server/neo4j_server.rb', line 69 def start_windows_server(command) if `reg query "HKU\\S-1-5-19"`.size > 0 `#{install_location}/bin/Neo4j.bat #{command}` # start service else puts 'Starting Neo4j directly, not as a service.' `#{install_location}/bin/Neo4j.bat` end end |
#stop ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/neo4j_test_server/neo4j_server.rb', line 57 def stop if OS::Underlying.windows? if `reg query "HKU\\S-1-5-19"`.size > 0 `#{install_location}/bin/Neo4j.bat stop` # stop service else puts 'You do not have administrative rights to stop the Neo4j Service' end else `#{install_location}/bin/neo4j stop` end end |
#to_s ⇒ Object
23 24 25 |
# File 'lib/neo4j_test_server/neo4j_server.rb', line 23 def to_s "http://#{bind_address}:#{port}" unless bind_address.empty? && port.empty? end |