Sha256: 139e7d18ab47984b1556f53b8ad1f740024069e534f7d5ad5c63105844f3afef

Contents?: true

Size: 758 Bytes

Versions: 31

Compression:

Stored size: 758 Bytes

Contents

require 'mspec/guards/guard'

class Object
  def env
    env = ""
    if SpecGuard.windows?
      env = Hash[*`cmd.exe /C set`.split("\n").map { |e| e.split("=", 2) }.flatten]
    elsif SpecGuard.android?
      env = {}
    else
      env = Hash[*`env`.split("\n").map { |e| e.split("=", 2) }.flatten]
    end
    env
  end

  def windows_env_echo(var)
    `cmd.exe /C ECHO %#{var}%`.strip
  end  

  def username
    user = ""
    if SpecGuard.windows?
      user = windows_env_echo('USERNAME')
    elsif SpecGuard.android?
      user = ENV['USER']
    else
      user = `whoami`.strip
    end
    user
  end

  def home_directory
    return ENV['HOME'] unless SpecGuard.windows?
    windows_env_echo('HOMEDRIVE') + windows_env_echo('HOMEPATH')
  end  
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
rhodes-3.1.1 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-3.1.1.beta lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-3.1.0 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-3.1.0.beta.5 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-3.1.0.beta.4 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-3.1.0.beta.3 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-3.1.0.beta.2 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-3.1.0.beta.1 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-3.0.2 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-3.0.2.beta.1 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-3.0.1 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-3.0.1.beta.8 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-3.0.1.beta.7 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-3.0.1.beta.6 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-3.0.1.beta.5 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-3.0.1.beta.4 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-3.0.1.beta.3 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-3.0.1.beta.2 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-3.0.0 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-3.0.0.beta.7 lib/extensions/mspec/mspec/helpers/environment.rb