Sha256: b5b110fa222a8d5335db3b045c8b2395f2e878c8fd1ab396de6f2fd46ae8cf05

Contents?: true

Size: 983 Bytes

Versions: 1

Compression:

Stored size: 983 Bytes

Contents

module LearnOpen
  module Environments
    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

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

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

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
learn-open-1.2.21 lib/learn_open/environments.rb