lib/teuton/case_manager/utils.rb in teuton-2.3.4 vs lib/teuton/case_manager/utils.rb in teuton-2.3.5
- old
+ new
@@ -1,21 +1,19 @@
-# frozen_string_literal: true
require_relative '../application'
+require 'fileutils'
-# Define general use methods
module Utils
# Create the directory if it dosn't exist.
def ensure_dir(dirname)
unless Dir.exist?(dirname)
FileUtils.mkdir_p(dirname)
return false
end
true
end
- # rubocop:disable Metrics/MethodLength
def encode_and_split(encoding, text)
# Convert text to UTF-8 deleting unknown chars
text ||= '' # Ensure text is not nil
flag = [:default, 'UTF-8'].include? encoding
return text.encode('UTF-8', invalid: :replace).split("\n") if flag
@@ -29,10 +27,9 @@
puts " run 'command', on: :host, :encoding => 'ISO-8859-1'"
end
text.split("\n")
end
- # rubocop:enable Metrics/MethodLength
def my_execute(cmd, encoding = 'UTF-8')
return { exitstatus: 0, content: '' } if Application.instance.debug
begin