]> git.openstreetmap.org Git - chef.git/blob - cookbooks/chef/libraries/content_from_file.rb
d8d0fe7ee74acccf08a783d5d25c3126f3ac8947
[chef.git] / cookbooks / chef / libraries / content_from_file.rb
1 class Chef
2   class Resource
3     class File
4       def content_from_file(file, &block)
5         @content_file = file
6         @content_block = block
7       end
8
9       def content(text = nil)
10         if text
11           @content = text
12         elsif @content
13           @content
14         elsif @content_file
15           ::File.new(@content_file).collect do |line|
16             line = @content_block.call(line)
17           end.join("")
18         end
19       end
20     end
21   end
22 end