Class: Dato::Dump::Operation::CreatePost
- Inherits:
-
Object
- Object
- Dato::Dump::Operation::CreatePost
- Defined in:
- lib/dato/dump/operation/create_post.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#frontmatter_format ⇒ Object
Returns the value of attribute frontmatter_format.
-
#frontmatter_value ⇒ Object
Returns the value of attribute frontmatter_value.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(context, path) ⇒ CreatePost
constructor
A new instance of CreatePost.
- #perform ⇒ Object
Constructor Details
#initialize(context, path) ⇒ CreatePost
Returns a new instance of CreatePost.
14 15 16 17 |
# File 'lib/dato/dump/operation/create_post.rb', line 14 def initialize(context, path) @context = context @path = path end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
12 13 14 |
# File 'lib/dato/dump/operation/create_post.rb', line 12 def content @content end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
10 11 12 |
# File 'lib/dato/dump/operation/create_post.rb', line 10 def context @context end |
#frontmatter_format ⇒ Object
Returns the value of attribute frontmatter_format.
12 13 14 |
# File 'lib/dato/dump/operation/create_post.rb', line 12 def frontmatter_format @frontmatter_format end |
#frontmatter_value ⇒ Object
Returns the value of attribute frontmatter_value.
12 13 14 |
# File 'lib/dato/dump/operation/create_post.rb', line 12 def frontmatter_value @frontmatter_value end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
10 11 12 |
# File 'lib/dato/dump/operation/create_post.rb', line 10 def path @path end |
Instance Method Details
#perform ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# 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 |