Class: Middleman::Cli::Draft
- Inherits:
-
Thor
- Object
- Thor
- Middleman::Cli::Draft
- Includes:
- Thor::Actions
- Defined in:
- lib/middleman-blog-drafts/commands/draft.rb
Overview
This class provides a “draft” command for the middleman CLI.
Class Method Summary collapse
-
.exit_on_failure? ⇒ Boolean
Tell Thor to exit with a nonzero exit code on failure.
-
.source_root ⇒ String
Template files are relative to this file.
Instance Method Summary collapse
Class Method Details
.exit_on_failure? ⇒ Boolean
Tell Thor to exit with a nonzero exit code on failure
20 21 22 |
# File 'lib/middleman-blog-drafts/commands/draft.rb', line 20 def self.exit_on_failure? true end |
.source_root ⇒ String
Template files are relative to this file
15 16 17 |
# File 'lib/middleman-blog-drafts/commands/draft.rb', line 15 def self.source_root File.dirname(__FILE__) end |
Instance Method Details
#draft(title) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/middleman-blog-drafts/commands/draft.rb', line 25 def draft(title) shared_instance = ::Middleman::Application.server.inst # This only exists when the config.rb sets it! if shared_instance.blog.respond_to? :drafts @title = title @slug = title.parameterize draft_path = shared_instance.blog.drafts..sources. sub(':title', @slug) template "draft.tt", File.join(shared_instance.source_dir, draft_path + shared_instance.blog..default_extension) else raise Thor::Error.new "You need to activate the drafts extension in config.rb before you can create an article" end end |