Class: Moft::Draft
Constant Summary collapse
- MATCHER =
Valid post name regex (no date)
/^(.*)(\.[^.]+)$/
Constants inherited from Post
Instance Attribute Summary
Attributes inherited from Post
#categories, #content, #data, #date, #ext, #extracted_excerpt, #name, #output, #published, #site, #slug, #tags
Class Method Summary collapse
-
.valid?(name) ⇒ Boolean
Draft name validator.
Instance Method Summary collapse
-
#containing_dir(source, dir) ⇒ Object
Get the full path to the directory containing the draft files.
-
#process(name) ⇒ Object
Extract information from the post filename.
Methods inherited from Post
#<=>, #build_index, #destination, #dir, #excerpt, #id, #initialize, #inspect, #next, #path, #permalink, #populate_categories, #populate_tags, #previous, #published?, #read_yaml, #related_posts, #render, #template, #title, #to_liquid, #transform, #url
Methods included from Convertible
#converter, #do_layout, #output_ext, #read_yaml, #render_all_layouts, #render_liquid, #to_s, #transform, #write
Constructor Details
This class inherits a constructor from Moft::Post
Class Method Details
.valid?(name) ⇒ Boolean
Draft name validator. Draft filenames must be like: my-awesome-post.textile
Returns true if valid, false if not.
12 13 14 |
# File 'lib/moft/draft.rb', line 12 def self.valid?(name) name =~ MATCHER end |
Instance Method Details
#containing_dir(source, dir) ⇒ Object
Get the full path to the directory containing the draft files
17 18 19 |
# File 'lib/moft/draft.rb', line 17 def containing_dir(source, dir) File.join(source, dir, '_drafts') end |
#process(name) ⇒ Object
Extract information from the post filename.
name - The String filename of the post file.
Returns nothing.
26 27 28 29 30 31 |
# File 'lib/moft/draft.rb', line 26 def process(name) m, slug, ext = *name.match(MATCHER) self.date = File.mtime(File.join(@base, name)) self.slug = slug self.ext = ext end |