Sha256: d1ccc1f3bf54ccd188af073cf074873822267b5e5183cbb885705e31bf6ea2e2

Contents?: true

Size: 1.07 KB

Versions: 14

Compression:

Stored size: 1.07 KB

Contents

class Environment < Hash

  def initialize
  end

  def self.scm
    return "git" if(Dir.exists?(".git"))
	return "svn" if(Dir.exists?(".svn"))
	"none"
  end

  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

  def self.working_directory
    Rake.application.original_dir
  end

  def self.context
    dir =Environment.working_directory.gsub(Environment.dev_root + '/','')
	puts "dir=" + dir
	return dir.split('/').first
  end

  def self.relative_directory
    Environment.working_directory.gsub(Environment.dev_root + '/' + Environment.context + '/','')
  end

  def self.branch
    if(Environment.scm=='git')
      branches=`git branch`.split(/\n/)
	  branches.each{|b|
	    return b.gsub('*','').strip if b.include?('*')
	  }
	end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
dev_tasks-0.0.33 lib/environment.rb
dev_tasks-0.0.32 lib/environment.rb
dev_tasks-0.0.31 lib/environment.rb
dev_tasks-0.0.30 lib/environment.rb
dev_tasks-0.0.29 lib/environment.rb
dev_tasks-0.0.28 lib/environment.rb
dev_tasks-0.0.27 lib/environment.rb
dev_tasks-0.0.26 lib/environment.rb
dev_tasks-0.0.25 lib/environment.rb
dev_tasks-0.0.24 lib/environment.rb
dev_tasks-0.0.23 lib/environment.rb
dev_tasks-0.0.22 lib/environment.rb
dev_tasks-0.0.21 lib/environment.rb
dev_tasks-0.0.20 lib/environment.rb