lib/sermont.rb in xinuc-sermont-0.2.6 vs lib/sermont.rb in xinuc-sermont-0.3.0
- old
+ new
@@ -42,33 +42,33 @@
puts "Run 'sermont --setup' to create example config file in your home directory"
exit
end
end
- def run(raw = nil, time = nil, output = nil, daemon = nil)
+ def run(raw = nil, time = nil, output = nil, daemon = nil, last = nil)
load_setup
@raw = @raw || raw
unless time
- output ? add_to_output(report, output) : print(report)
+ output ? add_to_output(report, output, last) : print(report)
else
if daemon && @can_daemon && output
pwd = Dir.pwd
daemonize
Dir.chdir pwd
end
loop do
- output ? add_to_output(report, output) : print(report)
+ output ? add_to_output(report, output, last) : print(report)
begin
sleep time.to_i
rescue Exception
exit
end
end
end
end
- def add_to_output(out, file)
- File.open(file, "ab") do |f|
+ def add_to_output(out, file, last)
+ File.open(file, last ? "wb" : "ab") do |f|
f << out
end
end
def report
\ No newline at end of file