Class: LearnOpen::Environments::BaseEnvironment
- Inherits:
-
Object
- Object
- LearnOpen::Environments::BaseEnvironment
show all
- Defined in:
- lib/learn_open/environments/base_environment.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#download_lesson(lesson, location) ⇒ Object
-
#initialize(options = {}) ⇒ BaseEnvironment
constructor
A new instance of BaseEnvironment.
-
#install_dependencies(lesson, location) ⇒ Object
-
#managed? ⇒ Boolean
-
#notify_of_completion ⇒ Object
-
#open_editor(lesson, location, editor) ⇒ Object
-
#open_jupyter_lab(_lesson, _location, _editor, _clone_only) ⇒ Object
-
#open_lab(lesson, location, editor, clone_only) ⇒ Object
-
#open_shell ⇒ Object
-
#start_file_backup(lesson, location) ⇒ Object
Constructor Details
Returns a new instance of BaseEnvironment.
Instance Attribute Details
#environment_vars ⇒ Object
Returns the value of attribute environment_vars.
5
6
7
|
# File 'lib/learn_open/environments/base_environment.rb', line 5
def environment_vars
@environment_vars
end
|
#io ⇒ Object
Returns the value of attribute io.
5
6
7
|
# File 'lib/learn_open/environments/base_environment.rb', line 5
def io
@io
end
|
#logger ⇒ Object
Returns the value of attribute logger.
5
6
7
|
# File 'lib/learn_open/environments/base_environment.rb', line 5
def logger
@logger
end
|
#options ⇒ Object
Returns the value of attribute options.
5
6
7
|
# File 'lib/learn_open/environments/base_environment.rb', line 5
def options
@options
end
|
#system_adapter ⇒ Object
Returns the value of attribute system_adapter.
5
6
7
|
# File 'lib/learn_open/environments/base_environment.rb', line 5
def system_adapter
@system_adapter
end
|
Instance Method Details
#download_lesson(lesson, location) ⇒ Object
46
47
48
|
# File 'lib/learn_open/environments/base_environment.rb', line 46
def download_lesson(lesson, location)
LessonDownloader.call(lesson, location, self, options)
end
|
#install_dependencies(lesson, location) ⇒ Object
42
43
44
|
# File 'lib/learn_open/environments/base_environment.rb', line 42
def install_dependencies(lesson, location)
DependencyInstallers.run_installers(lesson, location, self, options)
end
|
#managed? ⇒ Boolean
15
16
17
|
# File 'lib/learn_open/environments/base_environment.rb', line 15
def managed?
false
end
|
#notify_of_completion ⇒ Object
64
65
66
67
|
# File 'lib/learn_open/environments/base_environment.rb', line 64
def notify_of_completion
logger.log("Done.")
io.puts "Done."
end
|
#open_editor(lesson, location, editor) ⇒ Object
50
51
52
53
54
|
# File 'lib/learn_open/environments/base_environment.rb', line 50
def open_editor(lesson, location, editor)
io.puts "Opening lesson..."
system_adapter.change_context_directory(lesson.to_path)
system_adapter.open_editor(editor, path: ".")
end
|
#open_jupyter_lab(_lesson, _location, _editor, _clone_only) ⇒ Object
19
20
21
|
# File 'lib/learn_open/environments/base_environment.rb', line 19
def open_jupyter_lab(_lesson, _location, _editor, _clone_only)
:noop
end
|
#open_lab(lesson, location, editor, clone_only) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/learn_open/environments/base_environment.rb', line 23
def open_lab(lesson, location, editor, clone_only)
case lesson
when LearnOpen::Lessons::IosLesson
io.puts "You need to be on a Mac to work on iOS lessons."
else
case download_lesson(lesson, location)
when :ok, :noop
open_editor(lesson, location, editor) unless clone_only
install_dependencies(lesson, location)
notify_of_completion
open_shell unless clone_only
when :ssh_unauthenticated
io.puts 'Failed to obtain an SSH connection!'
else
raise LearnOpen::Environments::UnknownLessonDownloadError
end
end
end
|
#open_shell ⇒ Object
60
61
62
|
# File 'lib/learn_open/environments/base_environment.rb', line 60
def open_shell
system_adapter.open_login_shell(environment_vars['SHELL'])
end
|
#start_file_backup(lesson, location) ⇒ Object
56
57
58
|
# File 'lib/learn_open/environments/base_environment.rb', line 56
def start_file_backup(lesson, location)
FileBackupStarter.call(lesson, location, options)
end
|