Sha256: b3d66cbec63d01d4263409e3a65611312acfca2c21ff0416e2c8574c7fcb96d5

Contents?: true

Size: 1.66 KB

Versions: 8

Compression:

Stored size: 1.66 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

    # Return true if Linux environment
    def self.linux_env?
      !self.macos_env? && !self.windows_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

8 entries across 8 versions & 1 rubygems

Version Path
xamarin-test-cloud-2.3.0 lib/xamarin-test-cloud/environment.rb
xamarin-test-cloud-2.2.0 lib/xamarin-test-cloud/environment.rb
xamarin-test-cloud-2.1.2 lib/xamarin-test-cloud/environment.rb
xamarin-test-cloud-2.1.1 lib/xamarin-test-cloud/environment.rb
xamarin-test-cloud-2.1.0 lib/xamarin-test-cloud/environment.rb
xamarin-test-cloud-2.0.3 lib/xamarin-test-cloud/environment.rb
xamarin-test-cloud-2.0.2 lib/xamarin-test-cloud/environment.rb
xamarin-test-cloud-2.0.1 lib/xamarin-test-cloud/environment.rb