From 315a726a700d1907ed8f53e29324760d0c797534 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Donoso Date: Wed, 7 Jan 2015 21:40:18 -0300 Subject: [PATCH 1/3] changes default markdown extension to md --- lib/jekyll/commands/draft.rb | 4 ++-- lib/jekyll/commands/post.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/jekyll/commands/draft.rb b/lib/jekyll/commands/draft.rb index 2bd0be9..2192cf5 100644 --- a/lib/jekyll/commands/draft.rb +++ b/lib/jekyll/commands/draft.rb @@ -19,7 +19,7 @@ def self.init_with_program(prog) def self.process(args = [], options = {}) raise ArgumentError.new('You must specify a name.') if args.empty? - type = options["type"] || "markdown" + type = options["type"] || "md" layout = options["layout"] || "post" title = args.shift @@ -38,7 +38,7 @@ def self.process(args = [], options = {}) # Internal: Gets the filename of the draft to be created # # Returns the filename of the draft, as a String - def self.draft_name(name, ext='markdown') + def self.draft_name(name, ext='md') "_drafts/#{name}.#{ext}" end diff --git a/lib/jekyll/commands/post.rb b/lib/jekyll/commands/post.rb index da35d02..db06125 100644 --- a/lib/jekyll/commands/post.rb +++ b/lib/jekyll/commands/post.rb @@ -20,7 +20,7 @@ def self.init_with_program(prog) def self.process(args = [], options = {}) raise ArgumentError.new('You must specify a name.') if args.empty? - type = options["type"].nil? ? "markdown" : options["type"] + type = options["type"].nil? ? "md" : options["type"] layout = options["layout"].nil? ? "post" : options["layout"] date = options["date"].nil? ? Time.now : DateTime.parse(options["date"]) From fb4feb13b1f7c359b7d09079a17d42d0ef869d61 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Donoso Date: Wed, 7 Jan 2015 23:37:30 -0300 Subject: [PATCH 2/3] move type and layout values to contants --- lib/jekyll/commands/draft.rb | 7 ++++++- lib/jekyll/commands/post.rb | 4 ++-- lib/jekyll/compose.rb | 12 ++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 lib/jekyll/compose.rb diff --git a/lib/jekyll/commands/draft.rb b/lib/jekyll/commands/draft.rb index 2192cf5..679ed76 100644 --- a/lib/jekyll/commands/draft.rb +++ b/lib/jekyll/commands/draft.rb @@ -19,8 +19,13 @@ def self.init_with_program(prog) def self.process(args = [], options = {}) raise ArgumentError.new('You must specify a name.') if args.empty? +<<<<<<< HEAD type = options["type"] || "md" layout = options["layout"] || "post" +======= + type = options["type"].nil? ? Jekyll::Compose::DEFAULT_TYPE : options["type"] + layout = options["layout"].nil? ? Jekyll::Compose::DEFAULT_LAYOUT : options["layout"] +>>>>>>> move type and layout values to contants title = args.shift name = title.gsub(' ', '-').downcase @@ -38,7 +43,7 @@ def self.process(args = [], options = {}) # Internal: Gets the filename of the draft to be created # # Returns the filename of the draft, as a String - def self.draft_name(name, ext='md') + def self.draft_name(name, ext=Jekyll::Compose::DEFAULT_TYPE) "_drafts/#{name}.#{ext}" end diff --git a/lib/jekyll/commands/post.rb b/lib/jekyll/commands/post.rb index db06125..99cddd3 100644 --- a/lib/jekyll/commands/post.rb +++ b/lib/jekyll/commands/post.rb @@ -20,8 +20,8 @@ def self.init_with_program(prog) def self.process(args = [], options = {}) raise ArgumentError.new('You must specify a name.') if args.empty? - type = options["type"].nil? ? "md" : options["type"] - layout = options["layout"].nil? ? "post" : options["layout"] + type = options["type"].nil? ? Jekyll::Compose::DEFAULT_TYPE : options["type"] + layout = options["layout"].nil? ? Jekyll::Compose::DEFAULT_LAYOUT : options["layout"] date = options["date"].nil? ? Time.now : DateTime.parse(options["date"]) diff --git a/lib/jekyll/compose.rb b/lib/jekyll/compose.rb new file mode 100644 index 0000000..c3c3b51 --- /dev/null +++ b/lib/jekyll/compose.rb @@ -0,0 +1,12 @@ +require "jekyll/compose/version" + +module Jekyll + module Compose + DEFAULT_TYPE = "md" + DEFAULT_LAYOUT = "post" + end +end + +require "jekyll/commands/draft" +require "jekyll/commands/post" +require "jekyll/commands/publish" From 00ec9b4cc0f4fa9b1948c3e09aaf3a4aa8e4ac49 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Sat, 10 Jan 2015 01:27:27 -0800 Subject: [PATCH 3/3] Fix tests for the new .md default extension. --- lib/jekyll-compose.rb | 2 ++ lib/jekyll/commands/draft.rb | 9 ++------- lib/jekyll/commands/post.rb | 4 ++-- lib/jekyll/compose.rb | 12 ------------ spec/draft_spec.rb | 8 ++++---- spec/post_spec.rb | 4 ++-- 6 files changed, 12 insertions(+), 27 deletions(-) delete mode 100644 lib/jekyll/compose.rb diff --git a/lib/jekyll-compose.rb b/lib/jekyll-compose.rb index 92f34ec..b492052 100644 --- a/lib/jekyll-compose.rb +++ b/lib/jekyll-compose.rb @@ -2,6 +2,8 @@ module Jekyll module Compose + DEFAULT_TYPE = "md" + DEFAULT_LAYOUT = "post" end end diff --git a/lib/jekyll/commands/draft.rb b/lib/jekyll/commands/draft.rb index 679ed76..7272f42 100644 --- a/lib/jekyll/commands/draft.rb +++ b/lib/jekyll/commands/draft.rb @@ -19,13 +19,8 @@ def self.init_with_program(prog) def self.process(args = [], options = {}) raise ArgumentError.new('You must specify a name.') if args.empty? -<<<<<<< HEAD - type = options["type"] || "md" - layout = options["layout"] || "post" -======= - type = options["type"].nil? ? Jekyll::Compose::DEFAULT_TYPE : options["type"] - layout = options["layout"].nil? ? Jekyll::Compose::DEFAULT_LAYOUT : options["layout"] ->>>>>>> move type and layout values to contants + type = options["type"] || Jekyll::Compose::DEFAULT_TYPE + layout = options["layout"] || Jekyll::Compose::DEFAULT_LAYOUT title = args.shift name = title.gsub(' ', '-').downcase diff --git a/lib/jekyll/commands/post.rb b/lib/jekyll/commands/post.rb index 99cddd3..6b939d6 100644 --- a/lib/jekyll/commands/post.rb +++ b/lib/jekyll/commands/post.rb @@ -20,8 +20,8 @@ def self.init_with_program(prog) def self.process(args = [], options = {}) raise ArgumentError.new('You must specify a name.') if args.empty? - type = options["type"].nil? ? Jekyll::Compose::DEFAULT_TYPE : options["type"] - layout = options["layout"].nil? ? Jekyll::Compose::DEFAULT_LAYOUT : options["layout"] + type = options["type"] || Jekyll::Compose::DEFAULT_TYPE + layout = options["layout"] || Jekyll::Compose::DEFAULT_LAYOUT date = options["date"].nil? ? Time.now : DateTime.parse(options["date"]) diff --git a/lib/jekyll/compose.rb b/lib/jekyll/compose.rb deleted file mode 100644 index c3c3b51..0000000 --- a/lib/jekyll/compose.rb +++ /dev/null @@ -1,12 +0,0 @@ -require "jekyll/compose/version" - -module Jekyll - module Compose - DEFAULT_TYPE = "md" - DEFAULT_LAYOUT = "post" - end -end - -require "jekyll/commands/draft" -require "jekyll/commands/post" -require "jekyll/commands/publish" diff --git a/spec/draft_spec.rb b/spec/draft_spec.rb index 0d03d73..2556342 100644 --- a/spec/draft_spec.rb +++ b/spec/draft_spec.rb @@ -2,7 +2,7 @@ let(:name) { 'A test post' } let(:args) { [name] } let(:drafts_dir) { Pathname.new source_dir('_drafts') } - let(:path) { drafts_dir.join('a-test-post.markdown') } + let(:path) { drafts_dir.join('a-test-post.md') } before(:all) do FileUtils.mkdir_p source_dir unless File.directory? source_dir @@ -25,7 +25,7 @@ it 'writes a helpful success message' do output = capture_stdout { described_class.process(args) } - expect(output).to eql("New draft created at ./_drafts/a-test-post.markdown.\n") + expect(output).to eql("New draft created at ./_drafts/a-test-post.md.\n") end it 'errors with no arguments' do @@ -36,7 +36,7 @@ context 'when the draft already exists' do let(:name) { 'An existing draft' } - let(:path) { drafts_dir.join('an-existing-draft.markdown') } + let(:path) { drafts_dir.join('an-existing-draft.md') } before(:each) do FileUtils.touch path @@ -45,7 +45,7 @@ it 'raises an error' do expect(-> { capture_stdout { described_class.process(args) } - }).to raise_error("A draft already exists at ./_drafts/an-existing-draft.markdown") + }).to raise_error("A draft already exists at ./_drafts/an-existing-draft.md") end it 'overwrites if --force is given' do diff --git a/spec/post_spec.rb b/spec/post_spec.rb index e9b27a5..d94485a 100644 --- a/spec/post_spec.rb +++ b/spec/post_spec.rb @@ -2,7 +2,7 @@ let(:name) { 'A test post' } let(:args) { [name] } let(:posts_dir) { Pathname.new source_dir('_posts') } - let(:filename) { "#{Time.now.strftime('%Y-%m-%d')}-a-test-post.markdown" } + let(:filename) { "#{Time.now.strftime('%Y-%m-%d')}-a-test-post.md" } let(:path) { posts_dir.join(filename) } before(:all) do @@ -37,7 +37,7 @@ context 'when the post already exists' do let(:name) { 'An existing post' } - let(:filename) { "#{Time.now.strftime('%Y-%m-%d')}-an-existing-post.markdown" } + let(:filename) { "#{Time.now.strftime('%Y-%m-%d')}-an-existing-post.md" } before(:each) do FileUtils.touch path