Sha256: c99bff3a554a8b30e1e9c4c8d6874b44ca15538e14aa8731444f3cd4a3f70bd5

Contents?: true

Size: 893 Bytes

Versions: 3

Compression:

Stored size: 893 Bytes

Contents

# frozen_string_literal: true

require_relative '../runner'

# Case class -> DSL module:
# * goto
# * run
module DSL
  ##
  # DLS run: It's the same as goto :localhost
  # @param command (String)
  # @param args (Hash)
  def run(command, args = {})
    args[:exec] = command.to_s
    host = :localhost
    host = args[:on] if args[:on]
    goto(host, args)
  end

  # Run command from the host identify as pHostname
  # goto :host1, :execute => "command"
  def goto(host = :localhost, args = {})
    @result.reset
    args[:on] = host unless args[:on]
    @action[:command] = args[:execute] if args[:execute]
    @action[:command] = args[:exec] if args[:exec]
    tempfile(args[:tempfile]) if args[:tempfile]
    @action[:encoding] = args[:encoding] || 'UTF-8'

    start_time = Time.now
    run_cmd_on(host)
    @action[:duration] = (Time.now - start_time).round(3)
  end
  alias on goto
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
teuton-2.1.11 lib/teuton/case_manager/case/dsl/goto.rb
teuton-2.1.10 lib/teuton/case_manager/case/dsl/goto.rb
teuton-2.1.9 lib/teuton/case_manager/case/dsl/goto.rb