rubocop: fix post URL tag code style

This commit is contained in:
Anatoliy Yastreb 2016-05-24 17:23:25 +03:00
parent 0d11511914
commit 80a65d161f
2 changed files with 7 additions and 7 deletions

View File

@ -57,7 +57,6 @@ AllCops:
- lib/jekyll/static_file.rb - lib/jekyll/static_file.rb
- lib/jekyll/stevenson.rb - lib/jekyll/stevenson.rb
- lib/jekyll/tags/include.rb - lib/jekyll/tags/include.rb
- lib/jekyll/tags/post_url.rb
- lib/jekyll/theme.rb - lib/jekyll/theme.rb
- lib/jekyll/url.rb - lib/jekyll/url.rb
- lib/jekyll/utils.rb - lib/jekyll/utils.rb

View File

@ -1,14 +1,14 @@
module Jekyll module Jekyll
module Tags module Tags
class PostComparer class PostComparer
MATCHER = /^(.+\/)*(\d+-\d+-\d+)-(.*)$/ MATCHER = %r!^(.+/)*(\d+-\d+-\d+)-(.*)$!
attr_reader :path, :date, :slug, :name attr_reader :path, :date, :slug, :name
def initialize(name) def initialize(name)
@name = name @name = name
all, @path, @date, @slug = *name.sub(/^\//, "").match(MATCHER) all, @path, @date, @slug = *name.sub(%r!^/!, "").match(MATCHER)
unless all unless all
raise Jekyll::Errors::InvalidPostNameError, raise Jekyll::Errors::InvalidPostNameError,
"'#{name}' does not contain valid date and/or title." "'#{name}' does not contain valid date and/or title."
@ -42,9 +42,9 @@ module Jekyll
def post_slug(other) def post_slug(other)
path = other.basename.split("/")[0...-1].join("/") path = other.basename.split("/")[0...-1].join("/")
if path.nil? || path == "" if path.nil? || path == ""
other.data['slug'] other.data["slug"]
else else
path + '/' + other.data['slug'] path + "/" + other.data["slug"]
end end
end end
end end
@ -78,7 +78,8 @@ eos
site.posts.docs.each do |p| site.posts.docs.each do |p|
next unless @post.deprecated_equality p next unless @post.deprecated_equality p
Jekyll::Deprecator.deprecation_message "A call to '{{ post_url #{@post.name} }}' did not match " \ Jekyll::Deprecator.deprecation_message "A call to "\
"'{{ post_url #{@post.name} }}' did not match " \
"a post using the new matching method of checking name " \ "a post using the new matching method of checking name " \
"(path-date-slug) equality. Please make sure that you " \ "(path-date-slug) equality. Please make sure that you " \
"change this tag to match the post's name exactly." "change this tag to match the post's name exactly."
@ -95,4 +96,4 @@ eos
end end
end end
Liquid::Template.register_tag('post_url', Jekyll::Tags::PostUrl) Liquid::Template.register_tag("post_url", Jekyll::Tags::PostUrl)