Module: Dimples::Writeable
Instance Method Summary collapse
Instance Method Details
#write(path, context = {}) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/dimples/writeable.rb', line 3 def write(path, context = {}) output = context ? render(context) : contents parent_path = File.dirname(path) begin FileUtils.mkdir_p(parent_path) unless Dir.exist?(parent_path) File.open(path, 'w+') do |file| file.write(output) end rescue SystemCallError => e raise Errors::PublishingError.new(path, e.) end end |