Class: Architect4r::InstanceManager

Inherits:
Object
  • Object
show all
Defined in:
lib/architect4r/instance_manager.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ InstanceManager

Returns a new instance of InstanceManager.



4
5
6
# File 'lib/architect4r/instance_manager.rb', line 4

def initialize(path)
  @path = path
end

Instance Method Details

#resetObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/architect4r/instance_manager.rb', line 24

def reset
  self.stop
  
  # Reset the database
  FileUtils.rm_rf("#{server_path}/data/graph.db")
  FileUtils.mkdir("#{server_path}/data/graph.db")
  
  # Remove log files
  FileUtils.rm_rf("#{server_path}/data/log")
  FileUtils.mkdir("#{server_path}/data/log")
  
  # Start the server
  self.start
end

#reset_to_sample_data(from) ⇒ Object



39
40
41
42
43
44
# File 'lib/architect4r/instance_manager.rb', line 39

def reset_to_sample_data(from)
  self.stop
  FileUtils.rm_rf("#{server_path}/data/graph.db")
  FileUtils.cp_r(from, "#{server_path}/data/graph.db/")
  self.start
end

#restartObject



20
21
22
# File 'lib/architect4r/instance_manager.rb', line 20

def restart
  %x[#{server_path}/bin/neo4j restart]
end

#server_pathObject



8
9
10
# File 'lib/architect4r/instance_manager.rb', line 8

def server_path
  @path
end

#startObject



12
13
14
# File 'lib/architect4r/instance_manager.rb', line 12

def start
  %x[#{server_path}/bin/neo4j start]
end

#stopObject



16
17
18
# File 'lib/architect4r/instance_manager.rb', line 16

def stop
  %x[#{server_path}/bin/neo4j stop]
end