Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/seed-fu/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,17 @@ def run_file(filename)
ActiveRecord::Base.transaction do
open(filename) do |file|
chunked_ruby = ''
file.each_line do |line|
line_number = 1
file.each_line.with_index do |line, index|
if line == "# BREAK EVAL\n"
eval(chunked_ruby)
eval(chunked_ruby, binding, filename, line_number)
chunked_ruby = ''
line_number = index + 2
else
chunked_ruby << line
end
end
eval(chunked_ruby) unless chunked_ruby == ''
eval(chunked_ruby, binding, filename, line_number) unless chunked_ruby == ''

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does eval automatically send the caller's binding? If not it might be best to to pass nil for binding.

Also if you do file.lineno you shouldn't need to track line_number as you do above.

end
end
end
Expand Down