Sha256: b604e69d6fef94859a63db3e4f50f97224975f7bde7340ab5fbb5db42e3b0643
Contents?: true
Size: 1.27 KB
Versions: 3
Compression:
Stored size: 1.27 KB
Contents
module PDK module Util module Filesystem def write_file(path, content) raise ArgumentError unless path.is_a?(String) || path.respond_to?(:to_path) # Harmonize newlines across platforms. content = content.encode(universal_newline: true) # Make sure all written files have a trailing newline. content += "\n" unless content[-1] == "\n" File.open(path, 'wb') { |f| f.write(content) } end module_function :write_file def read_file(file, nil_on_error: false) File.read(file) rescue => e raise e unless nil_on_error nil end module_function :read_file #:nocov: # These methods just wrap core Ruby functionality and # can be ignored for code coverage def directory?(*args) File.directory?(*args) end module_function :directory? def file?(*args) File.file?(*args) end module_function :file? def expand_path(*args) File.expand_path(*args) end module_function :expand_path def glob(*args) Dir.glob(*args) end module_function :glob def fnmatch(*args) File.fnmatch(*args) end module_function :fnmatch #:nocov: end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pdk-1.12.0 | lib/pdk/util/filesystem.rb |
pdk-1.11.1 | lib/pdk/util/filesystem.rb |
pdk-1.11.0 | lib/pdk/util/filesystem.rb |