Class: Environment
- Inherits:
-
Hash
- Object
- Hash
- Environment
- Defined in:
- lib/environment.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Environment
constructor
A new instance of Environment.
Constructor Details
#initialize ⇒ Environment
Returns a new instance of Environment.
3 4 5 6 7 |
# File 'lib/environment.rb', line 3 def initialize self[:home]=Environment.home self[:machine]=Environment.machine self[:user]=Environment.user end |
Class Method Details
.dev_root ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/environment.rb', line 34 def self.dev_root ["DEV_HOME","DEV_ROOT"].each {|v| return ENV[v].gsub('\\','/') unless ENV[v].nil? } dir=home #dir=ENV["DEV_ROOT"].gsub('\\','/') unless ENV["DEV_ROOT"].nil? return dir end |
.home ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/environment.rb', line 9 def self.home ["USERPROFILE","HOME"].each {|v| return ENV[v].gsub('\\','/') unless ENV[v].nil? } dir="~" dir=ENV["HOME"] unless ENV["HOME"].nil? dir=ENV["USERPROFILE"].gsub('\\','/') unless ENV["USERPROFILE"].nil? return dir end |
.machine ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/environment.rb', line 19 def self.machine if !ENV['COMPUTERNAME'].nil? return ENV['COMPUTERNAME'] end machine = `hostname` machine = machine.split('.')[0] if machine.include?('.') return machine.strip end |
.user ⇒ Object
29 30 31 32 |
# File 'lib/environment.rb', line 29 def self.user return ENV['USER'] if !ENV['USER'].nil? #on Unix ENV['USERNAME'] end |