class Raykit::Rake
Public Class Methods
run(remote,branch,task='default')
click to toggle source
# File lib/raykit/rake.rb, line 5 def self.run(remote,branch,task='default') repo=Raykit::Git::Repository.new(remote) rel_dir=repo.relative_path commit=repo.latest_commit(branch) log_filename="#{Environment::get_dev_dir('log')}/RayKit.Runner/#{rel_dir}/#{branch}/#{commit}.json" if(File.exist?(log_filename)) return Command.parse(File.read(log_filename)) else run_dir="#{Environment::get_dev_dir('tmp')}/#{rel_dir}.#{branch}.#{commit}" if(!Dir.exist?(run_dir)) parent_dir = File.expand_path('..',run_dir) if(!Dir.exist?(parent_dir)) FileUtils.mkdir_p(parent_dir) end cmd = Command.new("git clone #{remote} #{run_dir}") end Dir.chdir(run_dir) do cmd = Command.new("rake #{task}") parent_dir = File.dirname(log_filename) if(!Dir.exist?(parent_dir)) FileUtils.mkdir_p(parent_dir) end File.open(log_filename,'w'){|f| f.write(JSON.generate(cmd.to_hash)) } return cmd end end end