lib/teuton/case/dsl/goto.rb in teuton-2.6.0 vs lib/teuton/case/dsl/goto.rb in teuton-2.7.0
- old
+ new
@@ -1,35 +1,36 @@
# frozen_string_literal: true
-require_relative "../runner"
+require_relative "../execute/execute_manager"
-# Case class -> DSL module:
-# * goto
-# * run
module DSL
##
- # DLS run: It's the same as goto :localhost
+ # DSL run and goto
+ # 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
+ # Run command from the host identify as "host"
# goto :host1, :execute => "command"
def goto(host = :localhost, args = {})
@result.reset
args[:on] = host unless args[:on]
@action[:command] = args[:execute].to_s if args[:execute]
@action[:command] = args[:exec].to_s 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)
+ ExecuteManager.new(self).call(host)
+ @action[:output] = if @result.content.size < 2
+ @result.value.clone
+ else
+ "(#{@result.content.size} lines)"
+ end
end
alias_method :on, :goto
end