X-Git-Url: https://git.openstreetmap.org/chef.git/blobdiff_plain/805ab61e66fe3adb45e57f50e49b168d84a6a8b1..7b9ec4b60ee39614d1d083d7220e76b07d2b275f:/cookbooks/tools/libraries/content_from_file.rb diff --git a/cookbooks/tools/libraries/content_from_file.rb b/cookbooks/tools/libraries/content_from_file.rb new file mode 100644 index 000000000..d8d0fe7ee --- /dev/null +++ b/cookbooks/tools/libraries/content_from_file.rb @@ -0,0 +1,22 @@ +class Chef + class Resource + class File + def content_from_file(file, &block) + @content_file = file + @content_block = block + end + + def content(text = nil) + if text + @content = text + elsif @content + @content + elsif @content_file + ::File.new(@content_file).collect do |line| + line = @content_block.call(line) + end.join("") + end + end + end + end +end