Sha256: a3d83320d0c158f75589b0addde16285634561a5abc708e4276e914e77e9d840
Contents?: true
Size: 1.7 KB
Versions: 4
Compression:
Stored size: 1.7 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.machine if !ENV['COMPUTERNAME'].nil? return ENV['COMPUTERNAME'] end machine = `hostname` machine = machine.split('.')[0] if machine.include?('.') return machine.strip end def self.working_directory Rake.application.original_dir end def self.context dir =Environment.working_directory.gsub(Environment.dev_root + '/','') 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 def self.copy_if_newer(source,dest) if(File.exists?(source)) if(File.exists?(dest)) if(File.mtime(source) > File.mtime(dest)) FileUtils.cp(source,dest) puts "copied " + Color.green + source + Color.clear + " to " + Color.green + dest + Color.clear end else FileUtils.cp(source,dest) puts "copied " + Color.green + source + Color.clear + " to " + Color.green + dest + Color.clear end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
dev_tasks-0.0.48 | lib/environment.rb |
dev_tasks-0.0.47 | lib/environment.rb |
dev_tasks-0.0.46 | lib/environment.rb |
dev_tasks-0.0.45 | lib/environment.rb |