lib/projects.rb in dev_projects-0.0.8 vs lib/projects.rb in dev_projects-0.0.9
- old
+ new
@@ -1,7 +1,9 @@
require 'dev_environment'
+require 'dev_git'
require 'json'
+require 'rake'
class Projects < Hash
attr_accessor :filename
def initialize
@@ -28,7 +30,26 @@
end
def self.user_projects_filename
FileUtils.mkdir("#{Environment.dev_root}/data") if(!File.exists?("#{Environment.dev_root}/data"))
"#{Environment.dev_root}/data/PROJECTS.json"
+ end
+
+ def self.current
+ project=nil
+ if(File.exists?('.git'))
+ if(Rake.application.original_dir.include?('/wrk/') &&
+ Git.remote_origin.length > 0)
+ project=Project.new(Git.remote_origin)
+ name=Rake.application.original_dir.gsub("#{Environment.dev_root}/wrk/",'')
+ if(defined?(PROJECTS))
+ PROJECTS[name]=project if(!PROJECTS.has_key?(name))
+ project.each{|k,v|PROJECTS[name][k]=v}
+ PROJECTS.save
+ else
+ project[:name]=name
+ end
+ end
+ end
+ project
end
end
\ No newline at end of file