Sha256: 27bc0f2a71d7a476efb5b6fd4f458eb5caf3422d08667747f0f0acaa0f107a27

Contents?: true

Size: 755 Bytes

Versions: 8

Compression:

Stored size: 755 Bytes

Contents

require "open3"
require "rainbow"
require_relative "../../utils/project"
require_relative "../../utils/verbose"
require_relative "execute_base"

class ExecuteLocal < ExecuteBase
  def call
    action[:conn_type] = :local
    response = my_execute(action[:command], action[:encoding])
    result.exitcode = response[:exitcode]
    result.content = response[:content]
  end

  def my_execute(cmd, encoding = "UTF-8")
    return {exitcode: 0, content: ""} if Project.debug?

    begin
      text, status = Open3.capture2e(cmd)
      exitcode = status.exitstatus
    rescue => e
      verbose Rainbow("!").green
      text = e.to_s
      exitcode = 1
    end
    content = encode_and_split(encoding, text)
    {exitcode: exitcode, content: content}
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
teuton-2.9.2 lib/teuton/case/execute/execute_local.rb
teuton-2.9.1 lib/teuton/case/execute/execute_local.rb
teuton-2.9.0 lib/teuton/case/execute/execute_local.rb
teuton-2.8.0 lib/teuton/case/execute/execute_local.rb
teuton-2.7.3 lib/teuton/case/execute/execute_local.rb
teuton-2.7.2 lib/teuton/case/execute/execute_local.rb
teuton-2.7.1 lib/teuton/case/execute/execute_local.rb
teuton-2.7.0 lib/teuton/case/execute/execute_local.rb