class Monocle::BumpCommand
Attributes
view[R]
Public Class Methods
new(view)
click to toggle source
# File lib/monocle/bump_command.rb, line 5 def initialize(view) @view = view end
Public Instance Methods
call()
click to toggle source
# File lib/monocle/bump_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 timestamp = ["-- Timestamp: #{Time.now}\n"] # Put it back together new_sql = (timestamp + 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