Class: Terraspace::Compiler::Strategy::Mod::TextFile

Inherits:
Object
  • Object
show all
Includes:
Util::Logging
Defined in:
lib/terraspace/compiler/strategy/mod/text_file.rb

Instance Method Summary collapse

Methods included from Util::Logging

#logger

Constructor Details

#initialize(filename) ⇒ TextFile

Returns a new instance of TextFile.



7
8
9
# File 'lib/terraspace/compiler/strategy/mod/text_file.rb', line 7

def initialize(filename)
  @filename = filename
end

Instance Method Details

#checkObject



11
12
13
14
15
16
17
18
# File 'lib/terraspace/compiler/strategy/mod/text_file.rb', line 11

def check
  return true if Gem.win_platform? # assume text file if on windows
  return true unless file_installed?

  # 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