class LearnOpen::Environments::BaseEnvironment
Attributes
environment_vars[R]
io[R]
logger[R]
options[R]
system_adapter[R]
Public Class Methods
new(options={})
click to toggle source
# File lib/learn_open/environments/base_environment.rb, line 7 def initialize(options={}) @io = options.fetch(:io) { LearnOpen.default_io } @environment_vars = options.fetch(:environment_vars) { LearnOpen.environment_vars } @system_adapter = options.fetch(:system_adapter) { LearnOpen.system_adapter } @logger = options.fetch(:logger) { LearnOpen.logger } @options = options end
Public Instance Methods
download_lesson(lesson, location)
click to toggle source
# 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)
click to toggle source
# File lib/learn_open/environments/base_environment.rb, line 42 def install_dependencies(lesson, location) DependencyInstallers.run_installers(lesson, location, self, options) end
managed?()
click to toggle source
# File lib/learn_open/environments/base_environment.rb, line 15 def managed? false end
notify_of_completion()
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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()
click to toggle source
# 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)
click to toggle source
# File lib/learn_open/environments/base_environment.rb, line 56 def start_file_backup(lesson, location) FileBackupStarter.call(lesson, location, options) end