Class: LearnOpen::FileBackupStarter

Inherits:
Object
  • Object
show all
Defined in:
lib/learn_open/services/file_backup_starter.rb

Constant Summary collapse

BACKUP_LAB_PROCESS =
"tail -f ~/inotify.log | while read change; do backup-lab; done"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lesson, location, options) ⇒ FileBackupStarter

Returns a new instance of FileBackupStarter.



12
13
14
15
16
# File 'lib/learn_open/services/file_backup_starter.rb', line 12

def initialize(lesson, location, options)
  @lesson = lesson
  @location = location
  @system_adapter = options.fetch(:system_adapter, LearnOpen.system_adapter)
end

Instance Attribute Details

#lessonObject (readonly)

Returns the value of attribute lesson.



6
7
8
# File 'lib/learn_open/services/file_backup_starter.rb', line 6

def lesson
  @lesson
end

#locationObject (readonly)

Returns the value of attribute location.



6
7
8
# File 'lib/learn_open/services/file_backup_starter.rb', line 6

def location
  @location
end

#system_adapterObject (readonly)

Returns the value of attribute system_adapter.



6
7
8
# File 'lib/learn_open/services/file_backup_starter.rb', line 6

def system_adapter
  @system_adapter
end

Class Method Details

.call(lesson, location, options) ⇒ Object



8
9
10
# File 'lib/learn_open/services/file_backup_starter.rb', line 8

def self.call(lesson, location, options)
  self.new(lesson, location, options).call
end

Instance Method Details

#callObject



18
19
20
21
# File 'lib/learn_open/services/file_backup_starter.rb', line 18

def call
  system_adapter.spawn("restore-lab", block: true)
  system_adapter.spawn(BACKUP_LAB_PROCESS)
end