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
  fail "can't read timestamp of #{path}! Aborting..." unless timestamp.starts_with? "-- Timestamp: "
  # Get only the digits out of the timestamp line
  timestamp.gsub!(/[^\d]/, '')
  "#{view}_#{timestamp}"
end