lib/dev_tasks.rb in dev_tasks-0.0.14 vs lib/dev_tasks.rb in dev_tasks-0.0.15

- old
+ new

@@ -11,10 +11,26 @@ CLEAN.include("*.gem") class DevTasks < Hash + def initialize + #hash = JSON.parse File.read("#{File.dirname(__FILE__)}/spec.json") + #self[:dev_tasks_gem]=JSON.parse File.read("#{File.dirname(__FILE__)}/spec.json") + + self[:name]=Rake.application.original_dir.split('/').last + self[:scm]=DevTasks.scm + if(self[:scm]=='git') + branches=`git branch`.split(/\n/) + branches.each{|b| + self[:branch]=b.gsub('*','').strip + } + end + self[:dev_root]=DevTasks.dev_root + update + end + def add hash hash.each do |key,value| self[key]=value if !has_key?(key) end end @@ -65,14 +81,29 @@ ruby="desc 'dev_tasks_default task';task :dev_tasks_default => [#{tasklist}] do;end" eval(ruby) end 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.scm + return "git" if(Dir.exists?(".git")) + return "svn" if(Dir.exists?(".svn")) + "none" + end end DEV_TASKS=DevTasks.new -DEV_TASKS.add JSON.parse File.read("#{File.dirname(__FILE__)}/spec.json") -DEV_TASKS.update desc 'displays information about current rake directory' task :info do Console.print_hash("",DEV_TASKS) end