module ChefUtils::DSL::TrainHelpers
Public Instance Methods
dir_exist?(path)
click to toggle source
Alias to easily convert Dir.exist to dir_exist
# File lib/chef-utils/dsl/train_helpers.rb, line 80 def dir_exist?(path) file_directory?(path) end
file_directory?(path)
click to toggle source
# File lib/chef-utils/dsl/train_helpers.rb, line 71 def file_directory?(path) if __transport_connection __transport_connection.file(filename).directory? else File.directory?(path) end end
file_exist?(filename)
click to toggle source
Train wrapper around File.exist? to make it local mode aware.
@param filename filename to check @return [Boolean] if it exists
# File lib/chef-utils/dsl/train_helpers.rb, line 43 def file_exist?(filename) if __transport_connection __transport_connection.file(filename).exist? else File.exist?(filename) end end
file_open(*args) { |string_io| ... }
click to toggle source
XXX: modifications to the StringIO won't get written back FIXME: this is very experimental and may be a bad idea and may break at any time @api private
# File lib/chef-utils/dsl/train_helpers.rb, line 55 def file_open(*args, &block) if __transport_connection content = __transport_connection.file(args[0]).content string_io = StringIO.new content yield string_io if block_given? string_io else File.open(*args, &block) end end
file_read(path)
click to toggle source
Alias to easily convert IO.read / File.read to file_read
# File lib/chef-utils/dsl/train_helpers.rb, line 67 def file_read(path) file_open(path).read end