Class: ExecuteLocal
Instance Method Summary
collapse
Methods included from Verbose
#verbose, #verboseln
Methods inherited from ExecuteBase
#initialize
Constructor Details
This class inherits a constructor from ExecuteBase
Instance Method Details
#call ⇒ Object
10
11
12
13
14
15
|
# File 'lib/teuton/case/execute/execute_local.rb', line 10
def call
action[:conn_type] = :local
response = my_execute(action[:command], action[:encoding])
result.exitcode = response[:exitcode]
result.content = response[:content]
end
|
#my_execute(cmd, encoding = "UTF-8") ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/teuton/case/execute/execute_local.rb', line 17
def my_execute(cmd, encoding = "UTF-8")
return {exitcode: 0, content: ""} if Project.value[:debug]
begin
text, status = Open3.capture2e(cmd)
exitcode = status.exitstatus
rescue => e
text = e.to_s
log("cmd=<#{cmd}> => #{text}", :error)
exitcode = 1
verbose Rainbow("!").green
end
content = encode_and_split(encoding, text)
{exitcode: exitcode, content: content}
end
|