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(*args) ⇒ 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(*args) ⇒ Server
Returns a new instance of Server.
18 19 20 21 22 |
# File 'lib/neo4j_test_server/neo4j_server.rb', line 18 def initialize(*args) ensure_java_installed self.edition = 'community-2.2.0' super(*args) end |
Instance Attribute Details
#bind_address ⇒ Object
35 36 37 |
# File 'lib/neo4j_test_server/neo4j_server.rb', line 35 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
39 40 41 |
# File 'lib/neo4j_test_server/neo4j_server.rb', line 39 def port @port ||= '7474' end |
Instance Method Details
#bootstrap ⇒ Object
28 29 30 31 32 33 |
# File 'lib/neo4j_test_server/neo4j_server.rb', line 28 def bootstrap unless @bootstrapped Neo4jTest::Installer.bootstrap edition @bootstrapped = true end end |
#ensure_java_installed ⇒ Object
83 84 85 86 87 88 89 90 91 |
# File 'lib/neo4j_test_server/neo4j_server.rb', line 83 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
93 94 95 |
# File 'lib/neo4j_test_server/neo4j_server.rb', line 93 def install_location Neo4jTest::Installer.install_location end |
#start ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/neo4j_test_server/neo4j_server.rb', line 47 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
43 44 45 |
# File 'lib/neo4j_test_server/neo4j_server.rb', line 43 def start_command @start_command ||= 'start' end |
#start_starnix_server(command) ⇒ Object
79 80 81 |
# File 'lib/neo4j_test_server/neo4j_server.rb', line 79 def start_starnix_server(command) `#{install_location}/bin/neo4j #{command}` end |
#start_windows_server(command) ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/neo4j_test_server/neo4j_server.rb', line 70 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
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/neo4j_test_server/neo4j_server.rb', line 58 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
24 25 26 |
# File 'lib/neo4j_test_server/neo4j_server.rb', line 24 def to_s "http://#{bind_address}:#{port}" unless bind_address.empty? && port.empty? end |