Class: Jekyll::Draft

Inherits:
Post
  • Object
show all
Defined in:
lib/jekyll/draft.rb

Constant Summary collapse

MATCHER =

Valid post name regex (no date)

/^(.*)(\.[^.]+)$/

Constants inherited from Post

Post::ATTRIBUTES_FOR_LIQUID, Post::EXCERPT_ATTRIBUTES_FOR_LIQUID

Instance Attribute Summary

Attributes inherited from Post

#categories, #content, #data, #date, #ext, #extracted_excerpt, #name, #output, #site, #slug, #tags

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Post

#<=>, #destination, #dir, #draft?, #excerpt, #excerpt_separator, #id, #initialize, #inspect, #next, #path, #permalink, #populate_categories, #populate_tags, #previous, #published?, #read_yaml, #related_posts, #render, #template, #title, #titleized_slug, #url, #url_placeholders

Methods included from Convertible

#[], #asset_file?, #coffeescript_file?, #converters, #do_layout, #invalid_layout?, #merged_file_read_opts, #output_ext, #place_in_layout?, #published?, #read_yaml, #render_all_layouts, #render_liquid, #render_with_liquid?, #sass_file?, #to_liquid, #to_s, #transform, #type, #write

Constructor Details

This class inherits a constructor from Jekyll::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.

Returns:

  • (Boolean)

12
13
14
# File 'lib/jekyll/draft.rb', line 12

def self.valid?(name)
  name =~ MATCHER
end

Instance Method Details

#containing_dir(dir) ⇒ Object

Get the full path to the directory containing the draft files


17
18
19
# File 'lib/jekyll/draft.rb', line 17

def containing_dir(dir)
  site.in_source_dir(dir, '_drafts')
end

#process(name) ⇒ Object

Extract information from the post filename.

name - The String filename of the post file.

Returns nothing.


31
32
33
34
35
36
# File 'lib/jekyll/draft.rb', line 31

def process(name)
  m, slug, ext = *name.match(MATCHER)
  self.date = File.mtime(File.join(@base, name))
  self.slug = slug
  self.ext = ext
end

#relative_pathObject

The path to the draft source file, relative to the site source


22
23
24
# File 'lib/jekyll/draft.rb', line 22

def relative_path
  File.join(@dir, '_drafts', @name)
end