Sha256: a8e7fd36074aa8f60eb8ba3f9b2f43c2cecba368971f468eff7a9acb069e0184
Contents?: true
Size: 781 Bytes
Versions: 1
Compression:
Stored size: 781 Bytes
Contents
require 'yaml' require 'shellwords' module SlonikMigration class Command def initialize @config = SlonikMigration::Config.load end def execute(sql, options = {}) command = build(sql, options) puts command if ENV['VERBOSE'] system command end private def build(sql, target: nil, name: nil, owner: nil) sql << %Q|; ALTER #{target} "#{name}" OWNER TO #{@config.owner}| if target && name && @config.owner command = @config.command.dup command.gsub!(%r{\$SQL}) { Shellwords.escape(sql) } command.gsub!(%r{\$(\w+)}) { replace($1) } command end def replace(key) if (var = @config.variables[key]) Shellwords.escape(var.to_s) else "$#{key}" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
slonik_migration-1.1.2 | lib/slonik_migration/command.rb |