Sha256: 289504ad5ddfcce0bbd610ca1516b1c61a276765ed09cb281e5248e60319dd86
Contents?: true
Size: 1.01 KB
Versions: 14
Compression:
Stored size: 1.01 KB
Contents
require "open3" class Terraspace::Compiler::Strategy::Mod class TextFile include Terraspace::Util::Logging def initialize(filename) @filename = filename end @@already_reported = false def check unless file_installed? return true if @@already_reported logger.warn <<~EOL.color(:yellow) WARN: The command 'file' is not installed. Unable to check if files are text or binary files as a part of the Terraspace compile processing. Assuming all files are not binary file. Please install the file command to remove this warning message. EOL @@already_reported = true return true end # Thanks: https://stackoverflow.com/questions/2355866/ruby-how-to-determine-if-file-being-read-is-binary-or-text file_type, status = Open3.capture2e("file", @filename) status.success? && file_type.include?("text") end private def file_installed? system("type file > /dev/null 2>&1") end end end
Version data entries
14 entries across 14 versions & 1 rubygems