Module: Kagu::SwiftHelper
- Defined in:
- lib/kagu/swift_helper.rb
Class Method Summary collapse
Class Method Details
.execute(code) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/kagu/swift_helper.rb', line 5 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 |