From e1142dfcae036bd8c6400962f9e07112b750b730 Mon Sep 17 00:00:00 2001 From: Curtis Cablegram Date: Wed, 28 Jul 2010 19:47:53 -0500 Subject: Refactor log-tailer to depend on File#eof? rather than File#mtime MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [#5220 state:resolved] Eliminate 1 instance variable and 1 local variable. Signed-off-by: José Valim --- railties/lib/rails/rack/log_tailer.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/rack/log_tailer.rb b/railties/lib/rails/rack/log_tailer.rb index 2ca6b5f8da..011ac6cecc 100644 --- a/railties/lib/rails/rack/log_tailer.rb +++ b/railties/lib/rails/rack/log_tailer.rb @@ -6,7 +6,6 @@ module Rails path = Pathname.new(log || "#{File.expand_path(Rails.root)}/log/#{Rails.env}.log").cleanpath @cursor = ::File.size(path) - @last_checked = Time.now.to_f @file = ::File.open(path, 'r') end @@ -20,10 +19,8 @@ module Rails def tail! @file.seek @cursor - mod = @file.mtime.to_f - if mod > @last_checked + if !@file.eof? contents = @file.read - @last_checked = mod @cursor = @file.tell $stdout.print contents end -- cgit v1.2.3