class Capistrano::DBSync::Postgres::FileNameGenerator

Public Class Methods

extract_name(file_path) click to toggle source
# File lib/capistrano/db_sync/postgres/file_name_generator.rb, line 18
def self.extract_name(file_path)
  file_name = File.basename(file_path)
  file_name.scan(/\d+-(.*)\.(schema|table)$/).flatten.first
end
new(path) click to toggle source
# File lib/capistrano/db_sync/postgres/file_name_generator.rb, line 2
def initialize(path)
  @path = path
  @sequence = 0
end

Public Instance Methods

next(name, extension) click to toggle source

Generates sequential file names. Examples: next(“faceburger”, :schema) => 0001-faceburger.schema next(“posts”, :table) => 0002-posts.table next(“comments”, :table) => 0003-comments.table

# File lib/capistrano/db_sync/postgres/file_name_generator.rb, line 12
def next(name, extension)
  raise ArgumentError unless [:schema, :table].include?(extension)
  @sequence += 1
  File.join(@path, "%04i-#{name}.#{extension}" % @sequence)
end