]> git.openstreetmap.org Git - chef.git/blob - cookbooks/chef/libraries/edit_file.rb
8a04a8090f3e45ce03a13e71bbba768d9b945376
[chef.git] / cookbooks / chef / libraries / edit_file.rb
1 class Chef
2   class Util
3     class EditedFile
4       def initialize(file, block)
5         @file = file
6         @block = block
7       end
8
9       def kind_of?(klass)
10         klass == String || super
11       end
12
13       def to_s
14         ::File.new(@file).collect do |line|
15           line = @block.call(line)
16         end.join("")
17       end
18     end
19   end
20
21   class Recipe
22     def edit_file(file, &block)
23       Chef::Util::EditedFile.new(file, block)
24     end
25   end
26 end