lib/pull.rb in dev_tasks-0.0.155 vs lib/pull.rb in dev_tasks-0.0.156
- old
+ new
@@ -1,30 +1,15 @@
+require_relative('./commandarray.rb')
require_relative('./environment.rb')
require 'time'
-class Pull < Array
-
- def initialize
- update
- end
-
+class Pull < CommandArray
def update
- if(Environment.scm=='git')
+ if(Environment.scm=='git' && Environment.scm_origin.length > 0)
if(Timer.elapsed_exceeds?("last_pull",60*60*2))
#if(Timer.get_elapsed("last_pull").nil? || Timer.get_elapsed("last_pull") > 60*60*2)
self.add "<%`git pull 2>&1`%>"
self.add "<%Timer.set_timestamp('last_pull')%>"
end
- # 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))
end
end
\ No newline at end of file