Class: Kryo::Generators::PostGenerator

Inherits:
Base
  • Object
show all
Defined in:
lib/kryo/generators/post/post_generator.rb

Overview

Used to generate a basic post

Author:

  • Matthew A. Johnston (warmwaffles)

Constant Summary collapse

VALID_TYPES =
%w{markdown}.freeze

Class Method Summary collapse

Methods inherited from Base

create

Class Method Details

.invoke(title, type = 'markdown') ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/kryo/generators/post/post_generator.rb', line 12

def self.invoke title, type='markdown'
  directory = File.join(FileUtils.pwd, 'source', 'posts')
  date = DateTime.now
  name = [date.strftime("%Y-%m-%d"),title.gsub(/\s+/,'-')].join('-')
  name = [name, type].join('.').downcase
  create "post/templates/post.#{type}", directory, name: name do
    @title = title
  end
end