module Chef::Mixin::TrainHelpers
Public Instance Methods
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/mixin/train_helpers.rb, line 36 def file_exist?(filename) if Chef::Config.target_mode? Chef.run_context.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/mixin/train_helpers.rb, line 48 def file_open(*args, &block) if Chef::Config.target_mode? content = Chef.run_context.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