File tree Expand file tree Collapse file tree 5 files changed +13
-11
lines changed Expand file tree Collapse file tree 5 files changed +13
-11
lines changed Original file line number Diff line number Diff line change 22
33module Jekyll
44 module Compose
5+ DEFAULT_TYPE = "md"
6+ DEFAULT_LAYOUT = "post"
57 end
68end
79
Original file line number Diff line number Diff line change @@ -19,8 +19,8 @@ def self.init_with_program(prog)
1919 def self . process ( args = [ ] , options = { } )
2020 raise ArgumentError . new ( 'You must specify a name.' ) if args . empty?
2121
22- type = options [ "type" ] || "markdown"
23- layout = options [ "layout" ] || "post"
22+ type = options [ "type" ] || Jekyll :: Compose :: DEFAULT_TYPE
23+ layout = options [ "layout" ] || Jekyll :: Compose :: DEFAULT_LAYOUT
2424
2525 title = args . shift
2626 name = title . gsub ( ' ' , '-' ) . downcase
@@ -38,7 +38,7 @@ def self.process(args = [], options = {})
3838 # Internal: Gets the filename of the draft to be created
3939 #
4040 # Returns the filename of the draft, as a String
41- def self . draft_name ( name , ext = 'markdown' )
41+ def self . draft_name ( name , ext = Jekyll :: Compose :: DEFAULT_TYPE )
4242 "_drafts/#{ name } .#{ ext } "
4343 end
4444
Original file line number Diff line number Diff line change @@ -20,8 +20,8 @@ def self.init_with_program(prog)
2020 def self . process ( args = [ ] , options = { } )
2121 raise ArgumentError . new ( 'You must specify a name.' ) if args . empty?
2222
23- type = options [ "type" ] . nil? ? "markdown" : options [ "type" ]
24- layout = options [ "layout" ] . nil? ? "post" : options [ "layout" ]
23+ type = options [ "type" ] || Jekyll :: Compose :: DEFAULT_TYPE
24+ layout = options [ "layout" ] || Jekyll :: Compose :: DEFAULT_LAYOUT
2525
2626 date = options [ "date" ] . nil? ? Time . now : DateTime . parse ( options [ "date" ] )
2727
Original file line number Diff line number Diff line change 22 let ( :name ) { 'A test post' }
33 let ( :args ) { [ name ] }
44 let ( :drafts_dir ) { Pathname . new source_dir ( '_drafts' ) }
5- let ( :path ) { drafts_dir . join ( 'a-test-post.markdown ' ) }
5+ let ( :path ) { drafts_dir . join ( 'a-test-post.md ' ) }
66
77 before ( :all ) do
88 FileUtils . mkdir_p source_dir unless File . directory? source_dir
2525
2626 it 'writes a helpful success message' do
2727 output = capture_stdout { described_class . process ( args ) }
28- expect ( output ) . to eql ( "New draft created at ./_drafts/a-test-post.markdown .\n " )
28+ expect ( output ) . to eql ( "New draft created at ./_drafts/a-test-post.md .\n " )
2929 end
3030
3131 it 'errors with no arguments' do
3636
3737 context 'when the draft already exists' do
3838 let ( :name ) { 'An existing draft' }
39- let ( :path ) { drafts_dir . join ( 'an-existing-draft.markdown ' ) }
39+ let ( :path ) { drafts_dir . join ( 'an-existing-draft.md ' ) }
4040
4141 before ( :each ) do
4242 FileUtils . touch path
4545 it 'raises an error' do
4646 expect ( -> {
4747 capture_stdout { described_class . process ( args ) }
48- } ) . to raise_error ( "A draft already exists at ./_drafts/an-existing-draft.markdown " )
48+ } ) . to raise_error ( "A draft already exists at ./_drafts/an-existing-draft.md " )
4949 end
5050
5151 it 'overwrites if --force is given' do
Original file line number Diff line number Diff line change 22 let ( :name ) { 'A test post' }
33 let ( :args ) { [ name ] }
44 let ( :posts_dir ) { Pathname . new source_dir ( '_posts' ) }
5- let ( :filename ) { "#{ Time . now . strftime ( '%Y-%m-%d' ) } -a-test-post.markdown " }
5+ let ( :filename ) { "#{ Time . now . strftime ( '%Y-%m-%d' ) } -a-test-post.md " }
66 let ( :path ) { posts_dir . join ( filename ) }
77
88 before ( :all ) do
3737
3838 context 'when the post already exists' do
3939 let ( :name ) { 'An existing post' }
40- let ( :filename ) { "#{ Time . now . strftime ( '%Y-%m-%d' ) } -an-existing-post.markdown " }
40+ let ( :filename ) { "#{ Time . now . strftime ( '%Y-%m-%d' ) } -an-existing-post.md " }
4141
4242 before ( :each ) do
4343 FileUtils . touch path
You can’t perform that action at this time.
0 commit comments