From 2ef9bae75a5aa6d6a0843c1c5582fc047d4ee5df Mon Sep 17 00:00:00 2001 From: Martin Jorn Rogalla Date: Wed, 4 Mar 2015 14:16:55 +0100 Subject: [PATCH] Refactored url.rb to compliant with Ruby Style Guide. - Single Quotes - Fixed Typo's in variable names. - Removed Redundant Escaping in Regular Expressions. Signed-off-by: Martin Jorn Rogalla --- lib/jekyll/url.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/jekyll/url.rb b/lib/jekyll/url.rb index 60c96507..4bbbf92e 100644 --- a/lib/jekyll/url.rb +++ b/lib/jekyll/url.rb @@ -29,7 +29,7 @@ module Jekyll @permalink = options[:permalink] if (@template || @permalink).nil? - raise ArgumentError, "One of :template or :permalink must be supplied." + raise ArgumentError, 'One of :template or :permalink must be supplied.' end end @@ -44,12 +44,12 @@ module Jekyll # # Returns the _unsanitized String URL def generated_permalink - (@generated_permlink ||= generate_url(@permalink)) if @permalink + (@generated_permalink ||= generate_url(@permalink)) if @permalink end # Generates a URL from the template # - # Returns the _unsanitized String URL + # Returns the unsanitized String URL def generated_url @generated_url ||= generate_url(@template) end @@ -57,7 +57,7 @@ module Jekyll # Internal: Generate the URL by replacing all placeholders with their # respective values in the given template # - # Returns the _unsanitizied_ String URL + # Returns the unsanitized String URL def generate_url(template) @placeholders.inject(template) do |result, token| break result if result.index(':').nil? @@ -81,7 +81,7 @@ module Jekyll .gsub(/\A([^\/])/, '/\1') # Append a trailing slash to the URL if the unsanitized URL had one - url << "/" if in_url[-1].eql?('/') + url << '/' if in_url[-1].eql?('/') url end @@ -107,7 +107,7 @@ module Jekyll # pct-encoded = "%" HEXDIG HEXDIG # sub-delims = "!" / "$" / "&" / "'" / "(" / ")" # / "*" / "+" / "," / ";" / "=" - URI.escape(path, /[^a-zA-Z\d\-._~!$&\'()*+,;=:@\/]/).encode('utf-8') + URI.escape(path, /[^a-zA-Z\d\-._~!$&'()*+,;=:@\/]/).encode('utf-8') end # Unescapes a URL path segment