Module: LearnOpen::Environments

Defined in:
lib/learn_open/environments.rb,
lib/learn_open/environments/ide_environment.rb,
lib/learn_open/environments/mac_environment.rb,
lib/learn_open/environments/base_environment.rb,
lib/learn_open/environments/linux_environment.rb,
lib/learn_open/environments/generic_environment.rb,
lib/learn_open/environments/jupyter_container_environment.rb

Defined Under Namespace

Classes: BaseEnvironment, GenericEnvironment, IDEEnvironment, JupyterContainerEnvironment, LinuxEnvironment, MacEnvironment, MacWithChromeEnvironment, UnknownLessonDownloadError

Class Method Summary collapse

Class Method Details

.classify(options) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/learn_open/environments.rb', line 3

def self.classify(options)
  environment_vars = options.fetch(:environment_vars, LearnOpen.environment_vars)
  platform = options.fetch(:platform, LearnOpen.platform)
  if jupyter_container?(environment_vars)
    JupyterContainerEnvironment.new(options)
  elsif ide_environment?(environment_vars)
    IDEEnvironment.new(options)
  elsif on_mac?(platform)
    MacEnvironment.classify(options)
  elsif on_linux?(platform)
    LinuxEnvironment.new(options)
  else
    GenericEnvironment.new(options)
  end
end

.ide_environment?(environment_vars) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/learn_open/environments.rb', line 23

def self.ide_environment?(environment_vars)
  environment_vars['IDE_CONTAINER'] == "true"
end

.jupyter_container?(environment_vars) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/learn_open/environments.rb', line 19

def self.jupyter_container?(environment_vars)
  environment_vars['JUPYTER_CONTAINER'] == "true"
end

.on_linux?(platform) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/learn_open/environments.rb', line 31

def self.on_linux?(platform)
  !!platform.match(/linux/)
end

.on_mac?(platform) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/learn_open/environments.rb', line 27

def self.on_mac?(platform)
  !!platform.match(/darwin/)
end