Sha256: 642df3b4964bd429d25c9e2974e991f6890541f11ca030c5ad06237ff208e6ac

Contents?: true

Size: 484 Bytes

Versions: 4

Compression:

Stored size: 484 Bytes

Contents

module Kagu

  module SwiftHelper

    def self.execute(code)
      tempfile = Tempfile.new
      begin
        tempfile << code
      ensure
        tempfile.close
      end
      begin
        stdout, stderr, result = Open3.capture3("swift #{tempfile.path.inspect}")
        raise(stderr.presence || "Swift command returned with code: #{result.exitstatus}") unless result.success?
        stdout.lines.map(&:chomp)
      ensure
        tempfile.unlink
      end
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kagu-4.0.0 lib/kagu/swift_helper.rb
kagu-3.2.0 lib/kagu/swift_helper.rb
kagu-3.1.0 lib/kagu/swift_helper.rb
kagu-3.0.10 lib/kagu/swift_helper.rb