Sha256: ee2a6eb1a093a9da6914dafc36b528dbb64e12cdb2f670a1c92e7992c0ed0ca0

Contents?: true

Size: 1.54 KB

Versions: 2

Compression:

Stored size: 1.54 KB

Contents

module XamarinTestCloud
  module Environment

    # Returns true if Windows environment
    def self.windows_env?
      if @@windows_env.nil?
        @@windows_env = Environment.host_os_is_win?
      end
      @@windows_env
    end

    # Returns true if MacOS environment
    def self.macos_env?
      if @@macos_env.nil?
        @@macos_env = Environment.host_os_is_darwin?
      end
      @@macos_env
    end

    # Returns true if debugging is enabled.
    def self.debug?
      ENV["DEBUG"] == "1"
    end

    # Returns the XTC_ENDPOINT
    def self.xtc_endpoint
      Environment.value_of_env("XTC_ENDPOINT")
    end

    # Returns the XTC_USERNAME
    def self.xtc_username
      Environment.value_of_env("XTC_USERNAME")
    end

    # Returns the XTC_PASSWORD
    def self.xtc_password
      Environment.value_of_env("XTC_PASSWORD")
    end

    private

    # @visibility private
    WIN_PATTERNS = [
      /bccwin/i,
      /cygwin/i,
      /djgpp/i,
      /mingw/i,
      /mswin/i,
      /wince/i,
    ]

    # @!visibility private
    @@windows_env = nil

    # @!visibility private
    @@macos_env = nil

    # @!visibility private
    def self.host_os_is_win?
      ruby_platform = RbConfig::CONFIG["host_os"]
      !!WIN_PATTERNS.find { |r| ruby_platform =~ r }
    end

    #@!visibility private
    def self.host_os_is_darwin?
      (RbConfig::CONFIG['host_os'] =~ /darwin/)
    end

    # @!visibility private
    def self.value_of_env(name)
      value = ENV[name]
      if value && value != ""
        value
      else
        nil
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
xamarin-test-cloud-2.0.1.pre1 lib/xamarin-test-cloud/environment.rb
xamarin-test-cloud-2.0.0 lib/xamarin-test-cloud/environment.rb