Sha256: e2155bafe92ae1b725b4fe2fa5fc84b5f13e176f3010afe8945e3fea2189a289

Contents?: true

Size: 660 Bytes

Versions: 79

Compression:

Stored size: 660 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]
    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')
    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

79 entries across 55 versions & 2 rubygems

Version Path
rhodes-2.3.2 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-2.3.2.beta.2 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-2.3.2.beta.1 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-2.3.1 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-2.3.1.beta.1 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-2.3.0 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-2.3.0.beta.3 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-2.3.0.beta.2 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-2.3.0.beta.1 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-2.2.6 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-2.2.6.beta.1 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-2.2.5 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-2.2.5.beta.3 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-2.2.5.beta.2 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-2.2.5.beta.1 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-2.2.4.beta.1 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-2.2.3 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-2.2.3.beta.1 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-2.2.2 lib/extensions/mspec/mspec/helpers/environment.rb
rhodes-2.2.2.beta.1 lib/extensions/mspec/mspec/helpers/environment.rb