lib/pull.rb in dev_tasks-0.0.98 vs lib/pull.rb in dev_tasks-0.0.99

- old
+ new

@@ -1,15 +1,22 @@ require_relative('./environment.rb') +require 'time' class Pull < Array def initialize update end def update if(Environment.scm=='git') - self.add "<%`git pull 2>&1`%>" + last_pull_time=nil + last_pull_time = Time.parse(File.read('log/last_pull').strip) if(File.exist?('log/last_pull')) + if(last_pull_time.nil? || (last_pull_time-Time.now) > 60*60*2) + self.add "<%`git pull 2>&1`%>" + self.add "<%Dir.mkdir('log') if(!File.exists?('log'))%>" + self.add "<%File.open('log/last_pull','w'){|f|f.puts(Time.now.to_s)}%>" + end end end def add command self << command if(!include?(command)) \ No newline at end of file