class Monocle::DropCommand
Attributes
view[R]
Public Class Methods
new(view)
click to toggle source
# File lib/monocle/drop_command.rb, line 5 def initialize(view) @view = view end
Public Instance Methods
call()
click to toggle source
# File lib/monocle/drop_command.rb, line 9 def call # Get the SQL from the file, skipping the timestamp row # Drop the newlines too sql = File.readlines(view.path_for_sql)[1..-1] # Generate the new timestamp line drop_directive = ["-- Drop\n"] # Put it back together new_sql = (drop_directive + sql).join # Open the file for writing (no w+, we want to clear it up) File.open(view.path_for_sql, "w") do |f| f << new_sql end end