X-Git-Url: https://git.openstreetmap.org/chef.git/blobdiff_plain/a49460026a3a31ca582f63914cf33f1efca20bd6..7f6415938eb888893b49cc968a5c01082743b7d7:/cookbooks/chef/libraries/edit_file.rb?ds=sidebyside diff --git a/cookbooks/chef/libraries/edit_file.rb b/cookbooks/chef/libraries/edit_file.rb index 1c8e263e4..400e1967e 100644 --- a/cookbooks/chef/libraries/edit_file.rb +++ b/cookbooks/chef/libraries/edit_file.rb @@ -1,9 +1,22 @@ class Chef + class Util + class EditedFile + def initialize(file, block) + @file = file + @block = block + end + + def to_s + ::File.new(@file).collect do |line| + line = @block.call(line) + end.join("") + end + end + end + class Recipe def edit_file(file, &block) - ::File.new(file).collect do |line| - line = yield line - end.join("") + Chef::Util::EditedFile.new(file, block) end end end