Sha256: 964b8e735da65942d1db424713f40a74726289744041dc4659e43307d01b1f09

Contents?: true

Size: 557 Bytes

Versions: 12

Compression:

Stored size: 557 Bytes

Contents

class Ridgepole::ExternalSqlExecuter
  def initialize(script, logger)
    @script = script
    @logger = logger
  end

  def execute(sql)
    cmd = Shellwords.join([@script, sql, JSON.dump(ActiveRecord::Base.connection_config)])
    @logger.info("Execute #{@script}")

    out, err, status = Open3.capture3(cmd)
    out.strip!
    err.strip!

    @logger.info("#{@script}: #{out}") unless out.empty?
    @logger.warn("[WARNING] #{@script}: #{err}") unless err.empty?

    unless status.success?
      raise "`#{@script}` execution failed"
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ridgepole-0.6.5.beta4 lib/ridgepole/external_sql_executer.rb
ridgepole-0.6.5.beta3 lib/ridgepole/external_sql_executer.rb
ridgepole-0.6.5.beta2 lib/ridgepole/external_sql_executer.rb
ridgepole-0.6.5.beta lib/ridgepole/external_sql_executer.rb
ridgepole-0.6.4 lib/ridgepole/external_sql_executer.rb
ridgepole-0.6.4.beta9 lib/ridgepole/external_sql_executer.rb
ridgepole-0.6.4.beta8 lib/ridgepole/external_sql_executer.rb
ridgepole-0.6.4.beta7 lib/ridgepole/external_sql_executer.rb
ridgepole-0.6.4.beta6 lib/ridgepole/external_sql_executer.rb
ridgepole-0.6.4.beta5 lib/ridgepole/external_sql_executer.rb
ridgepole-0.6.4.beta4 lib/ridgepole/external_sql_executer.rb
ridgepole-0.6.4.beta3 lib/ridgepole/external_sql_executer.rb