Sha256: 337c400f3198c93e2d2488f00ffbe5aa1e0d13af5a9bcad6064728c7ffe5e40d

Contents?: true

Size: 706 Bytes

Versions: 10

Compression:

Stored size: 706 Bytes

Contents

require 'open3'
module Riiif
  # Runs shell commands under benchmark and saves the output
  class CommandRunner
    include Open3
    include ActiveSupport::Benchmarkable
    delegate :logger, to: :Rails

    def execute(command)
      out = nil
      benchmark("Riiif executed #{command}") do
        stdin, stdout, stderr, wait_thr = popen3(command)
        stdin.close
        stdout.binmode
        out = stdout.read
        stdout.close
        err = stderr.read
        stderr.close
        raise ConversionError, "Unable to execute command \"#{command}\"\n#{err}" unless wait_thr.value.success?
      end
      out
    end

    def self.execute(command)
      new.execute(command)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
riiif-1.7.1 app/services/riiif/command_runner.rb
riiif-1.7.0 app/services/riiif/command_runner.rb
riiif-1.6.0 app/services/riiif/command_runner.rb
riiif-1.5.1 app/services/riiif/command_runner.rb
riiif-1.5.0 app/services/riiif/command_runner.rb
riiif-1.4.4 app/services/riiif/command_runner.rb
riiif-1.4.3 app/services/riiif/command_runner.rb
riiif-1.4.2 app/services/riiif/command_runner.rb
riiif-1.4.1 app/services/riiif/command_runner.rb
riiif-1.4.0 app/services/riiif/command_runner.rb