Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use block form of 'File.open' so that File object is auto closed at end

  • Loading branch information...
commit bf928bc7329640969917eb680da4de959b7156b7 1 parent b31eac5
@ndbroadbent ndbroadbent authored
Showing with 14 additions and 14 deletions.
  1. +7 −7 actionpack/Rakefile
  2. +7 −7 activerecord/Rakefile
View
14 actionpack/Rakefile
@@ -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}"
View
14 activerecord/Rakefile
@@ -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}"
Please sign in to comment.
Something went wrong with that request. Please try again.