Skip to content

Commit

Permalink
Use block form of 'File.open' so that File object is auto closed at end
Browse files Browse the repository at this point in the history
  • Loading branch information
ndbroadbent committed Jan 29, 2012
1 parent b31eac5 commit bf928bc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions actionpack/Rakefile
Expand Up @@ -57,13 +57,13 @@ task :lines do

FileList["lib/**/*.rb"].each do |file_name|
next if file_name =~ /vendor/
f = File.open(file_name)

while line = f.gets
lines += 1
next if line =~ /^\s*$/
next if line =~ /^\s*#/
codelines += 1
File.open(file_name, 'r') do |f|
while line = f.gets
lines += 1
next if line =~ /^\s*$/
next if line =~ /^\s*#/
codelines += 1
end
end
puts "L: #{sprintf("%4d", lines)}, LOC #{sprintf("%4d", codelines)} | #{file_name}"

Expand Down
14 changes: 7 additions & 7 deletions activerecord/Rakefile
Expand Up @@ -189,13 +189,13 @@ task :lines do

FileList["lib/active_record/**/*.rb"].each do |file_name|
next if file_name =~ /vendor/
f = File.open(file_name)

while line = f.gets
lines += 1
next if line =~ /^\s*$/
next if line =~ /^\s*#/
codelines += 1
File.open(file_name, 'r') do |f|
while line = f.gets
lines += 1
next if line =~ /^\s*$/
next if line =~ /^\s*#/
codelines += 1
end
end
puts "L: #{sprintf("%4d", lines)}, LOC #{sprintf("%4d", codelines)} | #{file_name}"

Expand Down

0 comments on commit bf928bc

Please sign in to comment.