Sha256: e5f527202e8cfb58a7313669a5c8051e4586c6c49f0c0328bffc8ece2db29331

Contents?: true

Size: 772 Bytes

Versions: 3

Compression:

Stored size: 772 Bytes

Contents

module Tigefa

  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

3 entries across 3 versions & 1 rubygems

Version Path
tigefa-1.1.3 lib/tigefa/draft.rb
tigefa-1.1.2 lib/tigefa/draft.rb
tigefa-1.1.1 lib/tigefa/draft.rb