Sha256: 1549d52b9a69aa6383d5716da0d54449bfcf1999629850911af859887b3f9feb

Contents?: true

Size: 771 Bytes

Versions: 2

Compression:

Stored size: 771 Bytes

Contents

module Monad

  class Draft < Post

    # Valid post name regex (no date)
    MATCHER = /^(.*)(\.[^.]+)$/

    # Draft name validator. Draft filenames must be like:
    # my-awesome-post.textile
    #
    # Returns true if valid, false if not.
    def self.valid?(name)
      name =~ MATCHER
    end

    # Get the full path to the directory containing the draft files
    def containing_dir(source, dir)
      File.join(source, dir, '_drafts')
    end

    # Extract information from the post filename.
    #
    # name - The String filename of the post file.
    #
    # Returns nothing.
    def process(name)
      m, slug, ext = *name.match(MATCHER)
      self.date = File.mtime(File.join(@base, name))
      self.slug = slug
      self.ext = ext
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
monad-0.0.2 lib/monad/draft.rb
monad-0.0.1 lib/monad/draft.rb