class Monocle::VersionGenerator

Attributes

path[R]
view[R]

Public Class Methods

new(path) click to toggle source
# File lib/monocle/version_generator.rb, line 5
def initialize(path)
  @path = path
  @view = File.basename(path, ".sql")
end

Public Instance Methods

generate() click to toggle source
# File lib/monocle/version_generator.rb, line 10
def generate
  timestamp = File.open path, &:readline
  case timestamp
  when /^-- Timestamp:/
    # Get only the digits out of the timestamp line
    timestamp.gsub!(/[^\d]/, '')
    return "#{view}_#{timestamp}"
  when /^-- Drop/
    return :drop
  else
    fail "can't read timestamp of #{path}! Aborting..."
  end
end