diff --git a/lib/jekyll-compose.rb b/lib/jekyll-compose.rb index 7f2114d..dd41ca5 100644 --- a/lib/jekyll-compose.rb +++ b/lib/jekyll-compose.rb @@ -13,6 +13,8 @@ module Compose DEFAULT_TYPE = "md" DEFAULT_LAYOUT = "post" DEFAULT_LAYOUT_PAGE = "page" + DEFAULT_DATESTAMP_FORMAT = "%Y-%m-%d" + DEFAULT_TIMESTAMP_FORMAT = "%Y-%m-%d %H:%M %z" end end diff --git a/lib/jekyll/commands/post.rb b/lib/jekyll/commands/post.rb index 8817b05..18a88d2 100644 --- a/lib/jekyll/commands/post.rb +++ b/lib/jekyll/commands/post.rb @@ -56,11 +56,11 @@ def file_name end def _date_stamp - @params.date.strftime "%Y-%m-%d" + @params.date.strftime Jekyll::Compose::DEFAULT_DATESTAMP_FORMAT end def _time_stamp - @params.date.strftime("%Y-%m-%d %H:%M %z") + @params.date.strftime Jekyll::Compose::DEFAULT_TIMESTAMP_FORMAT end def content(custom_front_matter = {}) diff --git a/lib/jekyll/commands/publish.rb b/lib/jekyll/commands/publish.rb index 796d690..2ddedff 100644 --- a/lib/jekyll/commands/publish.rb +++ b/lib/jekyll/commands/publish.rb @@ -55,7 +55,7 @@ def from end def to - date_stamp = params.date.strftime "%Y-%m-%d" + date_stamp = params.date.strftime Jekyll::Compose::DEFAULT_DATESTAMP_FORMAT "_posts/#{date_stamp}-#{params.name}" end end diff --git a/spec/post_spec.rb b/spec/post_spec.rb index 7e41db7..977be38 100644 --- a/spec/post_spec.rb +++ b/spec/post_spec.rb @@ -4,8 +4,8 @@ let(:name) { "A test post" } let(:args) { [name] } let(:posts_dir) { Pathname.new source_dir("_posts") } - let(:datestamp) { Time.now.strftime("%Y-%m-%d") } - let(:timestamp) { Time.now.strftime("%Y-%m-%d %H:%M %z") } + let(:datestamp) { Time.now.strftime(Jekyll::Compose::DEFAULT_DATESTAMP_FORMAT) } + let(:timestamp) { Time.now.strftime(Jekyll::Compose::DEFAULT_TIMESTAMP_FORMAT) } let(:filename) { "#{datestamp}-a-test-post.md" } let(:path) { posts_dir.join(filename) } @@ -68,7 +68,7 @@ context "when the post already exists" do let(:name) { "An existing post" } - let(:filename) { "#{Time.now.strftime("%Y-%m-%d")}-an-existing-post.md" } + let(:filename) { "#{Time.now.strftime(Jekyll::Compose::DEFAULT_DATESTAMP_FORMAT)}-an-existing-post.md" } before(:each) do FileUtils.touch path diff --git a/spec/publish_spec.rb b/spec/publish_spec.rb index f49c9aa..1744db6 100644 --- a/spec/publish_spec.rb +++ b/spec/publish_spec.rb @@ -4,7 +4,7 @@ let(:drafts_dir) { Pathname.new source_dir("_drafts") } let(:posts_dir) { Pathname.new source_dir("_posts") } let(:draft_to_publish) { "a-test-post.md" } - let(:datestamp) { Time.now.strftime("%Y-%m-%d") } + let(:datestamp) { Time.now.strftime(Jekyll::Compose::DEFAULT_DATESTAMP_FORMAT) } let(:post_filename) { "#{datestamp}-#{draft_to_publish}" } let(:args) { ["_drafts/#{draft_to_publish}"] }