class Dato::Dump::Operation::CreatePost

Attributes

content[RW]
context[R]
frontmatter_format[RW]
frontmatter_value[RW]
path[R]

Public Class Methods

new(context, path) click to toggle source
# File lib/dato/dump/operation/create_post.rb, line 14
def initialize(context, path)
  @context = context
  @path = path
end

Public Instance Methods

perform() click to toggle source
# File lib/dato/dump/operation/create_post.rb, line 19
def perform
  FileUtils.mkdir_p(File.dirname(path))

  File.open(File.join(context.path, path), "w") do |file|
    file.write Format.frontmatter_dump(
      frontmatter_format,
      frontmatter_value,
    )
    file.write "\n\n"
    file.write content
  end
end