Class: Monocle::BumpCommand
- Inherits:
-
Object
- Object
- Monocle::BumpCommand
- Defined in:
- lib/monocle/bump_command.rb
Instance Attribute Summary collapse
-
#view ⇒ Object
readonly
Returns the value of attribute view.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(view) ⇒ BumpCommand
constructor
A new instance of BumpCommand.
Constructor Details
#initialize(view) ⇒ BumpCommand
Returns a new instance of BumpCommand.
5 6 7 |
# File 'lib/monocle/bump_command.rb', line 5 def initialize(view) @view = view end |
Instance Attribute Details
#view ⇒ Object (readonly)
Returns the value of attribute view.
3 4 5 |
# File 'lib/monocle/bump_command.rb', line 3 def view @view end |
Instance Method Details
#call ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# 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: #{Time.now}\n"] # Put it back together new_sql = ( + 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 |