Class: Environment
- Inherits:
-
Hash
- Object
- Hash
- Environment
- Defined in:
- lib/environment.rb
Class Method Summary collapse
- .branch ⇒ Object
- .context ⇒ Object
- .dev_root ⇒ Object
- .relative_directory ⇒ Object
- .scm ⇒ Object
- .working_directory ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ Environment
constructor
A new instance of Environment.
Constructor Details
#initialize ⇒ Environment
Returns a new instance of Environment.
4 5 |
# File 'lib/environment.rb', line 4 def initialize end |
Class Method Details
.branch ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/environment.rb', line 38 def self.branch if(Environment.scm=='git') branches=`git branch`.split(/\n/) branches.each{|b| return b.gsub('*','').strip if b.include?('*') } end end |
.context ⇒ Object
29 30 31 32 |
# File 'lib/environment.rb', line 29 def self.context dir =Environment.working_directory.gsub(Environment.dev_root + '/','') return dir.split('/').first end |
.dev_root ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/environment.rb', line 13 def self.dev_root ["DEV_HOME","DEV_ROOT","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? dir=ENV["DEV_ROOT"].gsub('\\','/') unless ENV["DEV_ROOT"].nil? return dir end |
.relative_directory ⇒ Object
34 35 36 |
# File 'lib/environment.rb', line 34 def self.relative_directory Environment.working_directory.gsub(Environment.dev_root + '/' + Environment.context + '/','') end |
.scm ⇒ Object
7 8 9 10 11 |
# File 'lib/environment.rb', line 7 def self.scm return "git" if(Dir.exists?(".git")) return "svn" if(Dir.exists?(".svn")) "none" end |
.working_directory ⇒ Object
25 26 27 |
# File 'lib/environment.rb', line 25 def self.working_directory Rake.application.original_dir end |