parent
7c12ebb28a
commit
2a032a38ec
23
.rubocop.yml
23
.rubocop.yml
|
@ -46,8 +46,13 @@ Layout/MultilineMethodCallIndentation:
|
|||
EnforcedStyle: indented
|
||||
Layout/MultilineOperationIndentation:
|
||||
EnforcedStyle: indented
|
||||
Lint/NestedPercentLiteral:
|
||||
Exclude:
|
||||
- test/test_site.rb
|
||||
Layout/SpaceInsideBrackets:
|
||||
Enabled: false
|
||||
Layout/EmptyComment:
|
||||
Enabled: false
|
||||
Lint/EndAlignment:
|
||||
Severity: error
|
||||
Lint/UnreachableCode:
|
||||
|
@ -94,6 +99,14 @@ Naming/FileName:
|
|||
Enabled: false
|
||||
Naming/HeredocDelimiterNaming:
|
||||
Enabled: false
|
||||
Naming/MemoizedInstanceVariableName:
|
||||
Exclude:
|
||||
- lib/jekyll/page_without_a_file.rb
|
||||
- lib/jekyll/drops/unified_payload_drop.rb
|
||||
- lib/jekyll/drops/site_drop.rb
|
||||
Naming/UncommunicativeMethodParamName:
|
||||
AllowedNames:
|
||||
- _
|
||||
Security/MarshalLoad:
|
||||
Exclude:
|
||||
- !ruby/regexp /test\/.*.rb$/
|
||||
|
@ -118,6 +131,9 @@ Style/Documentation:
|
|||
- !ruby/regexp /features\/.*.rb$/
|
||||
Style/DoubleNegation:
|
||||
Enabled: false
|
||||
Style/FormatStringToken:
|
||||
Exclude:
|
||||
- lib/jekyll/utils/ansi.rb
|
||||
Style/GuardClause:
|
||||
Enabled: false
|
||||
Style/HashSyntax:
|
||||
|
@ -127,6 +143,9 @@ Style/IfUnlessModifier:
|
|||
Enabled: false
|
||||
Style/InverseMethods:
|
||||
Enabled: false
|
||||
Style/MixinUsage:
|
||||
Exclude:
|
||||
- test/helper.rb
|
||||
Style/ModuleFunction:
|
||||
Enabled: false
|
||||
Style/MultilineTernaryOperator:
|
||||
|
@ -158,5 +177,7 @@ Style/StringLiteralsInInterpolation:
|
|||
EnforcedStyle: double_quotes
|
||||
Style/SymbolArray:
|
||||
Enabled: false
|
||||
Style/TrailingCommaInLiteral:
|
||||
Style/TrailingCommaInArrayLiteral:
|
||||
EnforcedStyleForMultiline: consistent_comma
|
||||
Style/TrailingCommaInHashLiteral:
|
||||
EnforcedStyleForMultiline: consistent_comma
|
||||
|
|
2
Gemfile
2
Gemfile
|
@ -31,7 +31,7 @@ group :test do
|
|||
gem "nokogiri", RUBY_VERSION >= "2.2" ? "~> 1.7" : "~> 1.7.0"
|
||||
gem "rspec"
|
||||
gem "rspec-mocks"
|
||||
gem "rubocop", "~> 0.51.0"
|
||||
gem "rubocop", "~> 0.54.0"
|
||||
gem "test-dependency-theme", :path => File.expand_path("test/fixtures/test-dependency-theme", __dir__)
|
||||
gem "test-theme", :path => File.expand_path("test/fixtures/test-theme", __dir__)
|
||||
|
||||
|
|
|
@ -45,31 +45,31 @@ module Jekyll
|
|||
|
||||
# Add common options to a command for building configuration
|
||||
#
|
||||
# c - the Jekyll::Command to add these options to
|
||||
# cmd - the Jekyll::Command to add these options to
|
||||
#
|
||||
# Returns nothing
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
def add_build_options(c)
|
||||
c.option "config", "--config CONFIG_FILE[,CONFIG_FILE2,...]",
|
||||
def add_build_options(cmd)
|
||||
cmd.option "config", "--config CONFIG_FILE[,CONFIG_FILE2,...]",
|
||||
Array, "Custom configuration file"
|
||||
c.option "destination", "-d", "--destination DESTINATION",
|
||||
cmd.option "destination", "-d", "--destination DESTINATION",
|
||||
"The current folder will be generated into DESTINATION"
|
||||
c.option "source", "-s", "--source SOURCE", "Custom source directory"
|
||||
c.option "future", "--future", "Publishes posts with a future date"
|
||||
c.option "limit_posts", "--limit_posts MAX_POSTS", Integer,
|
||||
cmd.option "source", "-s", "--source SOURCE", "Custom source directory"
|
||||
cmd.option "future", "--future", "Publishes posts with a future date"
|
||||
cmd.option "limit_posts", "--limit_posts MAX_POSTS", Integer,
|
||||
"Limits the number of posts to parse and publish"
|
||||
c.option "watch", "-w", "--[no-]watch", "Watch for changes and rebuild"
|
||||
c.option "baseurl", "-b", "--baseurl URL",
|
||||
cmd.option "watch", "-w", "--[no-]watch", "Watch for changes and rebuild"
|
||||
cmd.option "baseurl", "-b", "--baseurl URL",
|
||||
"Serve the website from the given base URL"
|
||||
c.option "force_polling", "--force_polling", "Force watch to use polling"
|
||||
c.option "lsi", "--lsi", "Use LSI for improved related posts"
|
||||
c.option "show_drafts", "-D", "--drafts", "Render posts in the _drafts folder"
|
||||
c.option "unpublished", "--unpublished",
|
||||
cmd.option "force_polling", "--force_polling", "Force watch to use polling"
|
||||
cmd.option "lsi", "--lsi", "Use LSI for improved related posts"
|
||||
cmd.option "show_drafts", "-D", "--drafts", "Render posts in the _drafts folder"
|
||||
cmd.option "unpublished", "--unpublished",
|
||||
"Render posts that were marked as unpublished"
|
||||
c.option "quiet", "-q", "--quiet", "Silence output."
|
||||
c.option "verbose", "-V", "--verbose", "Print verbose output."
|
||||
c.option "incremental", "-I", "--incremental", "Enable incremental rebuild."
|
||||
c.option "strict_front_matter", "--strict_front_matter",
|
||||
cmd.option "quiet", "-q", "--quiet", "Silence output."
|
||||
cmd.option "verbose", "-V", "--verbose", "Print verbose output."
|
||||
cmd.option "incremental", "-I", "--incremental", "Enable incremental rebuild."
|
||||
cmd.option "strict_front_matter", "--strict_front_matter",
|
||||
"Fail if errors are present in front matter"
|
||||
end
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
|
|
|
@ -70,7 +70,7 @@ module Jekyll
|
|||
cmd.action do |_, opts|
|
||||
opts["livereload_port"] ||= LIVERELOAD_PORT
|
||||
opts["serving"] = true
|
||||
opts["watch" ] = true unless opts.key?("watch")
|
||||
opts["watch"] = true unless opts.key?("watch")
|
||||
|
||||
start(opts)
|
||||
end
|
||||
|
@ -173,6 +173,7 @@ module Jekyll
|
|||
@changed_pages = nil
|
||||
end
|
||||
end
|
||||
# rubocop:enable Metrics/AbcSize
|
||||
|
||||
# Do a base pre-setup of WEBRick so that everything is in place
|
||||
# when we get ready to party, checking for an setting up an error page
|
||||
|
@ -336,7 +337,7 @@ module Jekyll
|
|||
require "webrick/https"
|
||||
|
||||
opts[:SSLCertificate] = OpenSSL::X509::Certificate.new(read_file(src, cert))
|
||||
opts[:SSLPrivateKey ] = OpenSSL::PKey::RSA.new(read_file(src, key))
|
||||
opts[:SSLPrivateKey] = OpenSSL::PKey::RSA.new(read_file(src, key))
|
||||
opts[:SSLEnable] = true
|
||||
end
|
||||
|
||||
|
|
|
@ -31,11 +31,11 @@ module Jekyll
|
|||
EM.reactor_running?
|
||||
end
|
||||
|
||||
def handle_websockets_event(ws)
|
||||
ws.onopen { |handshake| connect(ws, handshake) }
|
||||
ws.onclose { disconnect(ws) }
|
||||
ws.onmessage { |msg| print_message(msg) }
|
||||
ws.onerror { |error| log_error(error) }
|
||||
def handle_websockets_event(websocket)
|
||||
websocket.onopen { |handshake| connect(websocket, handshake) }
|
||||
websocket.onclose { disconnect(websocket) }
|
||||
websocket.onmessage { |msg| print_message(msg) }
|
||||
websocket.onerror { |error| log_error(error) }
|
||||
end
|
||||
|
||||
def start(opts)
|
||||
|
@ -82,14 +82,14 @@ module Jekyll
|
|||
end
|
||||
|
||||
private
|
||||
def connect(ws, handshake)
|
||||
def connect(websocket, handshake)
|
||||
@connections_count += 1
|
||||
if @connections_count == 1
|
||||
message = "Browser connected"
|
||||
message += " over SSL/TLS" if handshake.secure?
|
||||
Jekyll.logger.info "LiveReload:", message
|
||||
end
|
||||
ws.send(
|
||||
websocket.send(
|
||||
JSON.dump(
|
||||
:command => "hello",
|
||||
:protocols => ["http://livereload.com/protocols/official-7"],
|
||||
|
@ -97,12 +97,12 @@ module Jekyll
|
|||
)
|
||||
)
|
||||
|
||||
@websockets << ws
|
||||
@websockets << websocket
|
||||
end
|
||||
|
||||
private
|
||||
def disconnect(ws)
|
||||
@websockets.delete(ws)
|
||||
def disconnect(websocket)
|
||||
@websockets.delete(websocket)
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -116,10 +116,10 @@ module Jekyll
|
|||
end
|
||||
|
||||
private
|
||||
def log_error(e)
|
||||
def log_error(error)
|
||||
Jekyll.logger.error "LiveReload experienced an error. " \
|
||||
"Run with --trace for more information."
|
||||
raise e
|
||||
raise error
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -88,6 +88,7 @@ module Jekyll
|
|||
end
|
||||
@new_body = @new_body.join
|
||||
end
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
|
||||
def template
|
||||
# Unclear what "snipver" does. Doc at
|
||||
|
@ -175,6 +176,7 @@ module Jekyll
|
|||
res.header.merge!(@headers)
|
||||
rtn
|
||||
end
|
||||
# rubocop:enable Naming/MethodName
|
||||
|
||||
#
|
||||
|
||||
|
|
|
@ -74,6 +74,7 @@ module Jekyll
|
|||
close_connection_after_writing
|
||||
end
|
||||
end
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -50,14 +50,12 @@ module Jekyll
|
|||
end
|
||||
|
||||
private
|
||||
# rubocop:disable Performance/HashEachMethods
|
||||
def make_accessible(hash = @config)
|
||||
hash.keys.each do |key|
|
||||
hash[key.to_sym] = hash[key]
|
||||
make_accessible(hash[key]) if hash[key].is_a?(Hash)
|
||||
end
|
||||
end
|
||||
# rubocop:enable Performance/HashEachMethods
|
||||
|
||||
# config[kramdown][syntax_higlighter] >
|
||||
# config[kramdown][enable_coderay] >
|
||||
|
|
|
@ -22,9 +22,9 @@ module Jekyll
|
|||
end
|
||||
|
||||
private
|
||||
def replace_generated_toc(rd, html, toc_token)
|
||||
if rd.generate_toc && html.include?(toc_token)
|
||||
utf8_toc = rd.toc_content
|
||||
def replace_generated_toc(rd_instance, html, toc_token)
|
||||
if rd_instance.generate_toc && html.include?(toc_token)
|
||||
utf8_toc = rd_instance.toc_content
|
||||
utf8_toc.force_encoding("utf-8") if utf8_toc.respond_to?(:force_encoding)
|
||||
html.gsub(toc_token, utf8_toc)
|
||||
else
|
||||
|
|
|
@ -109,7 +109,6 @@ module Jekyll
|
|||
def render_liquid(content, payload, info, path)
|
||||
_renderer.render_liquid(content, payload, info, path)
|
||||
end
|
||||
# rubocop: enable RescueException
|
||||
|
||||
# Convert this Convertible's data to a Hash suitable for use by Liquid.
|
||||
#
|
||||
|
|
|
@ -86,8 +86,8 @@ module Jekyll
|
|||
# Check if an entry matches a specific pattern and return true,false.
|
||||
# Returns true if path matches against any glob pattern.
|
||||
# --
|
||||
def glob_include?(enum, e)
|
||||
entry = Pathutil.new(site.in_source_dir).join(e)
|
||||
def glob_include?(enum, entry)
|
||||
entry_path = Pathutil.new(site.in_source_dir).join(entry)
|
||||
enum.any? do |exp|
|
||||
# Users who send a Regexp knows what they want to
|
||||
# exclude, so let them send a Regexp to exclude files,
|
||||
|
@ -95,7 +95,7 @@ module Jekyll
|
|||
# on them at this point.
|
||||
|
||||
if exp.is_a?(Regexp)
|
||||
entry =~ exp
|
||||
entry_path =~ exp
|
||||
|
||||
else
|
||||
item = Pathutil.new(site.in_source_dir).join(exp)
|
||||
|
@ -105,14 +105,14 @@ module Jekyll
|
|||
# see if the entry falls within that path and
|
||||
# exclude it if that's the case.
|
||||
|
||||
if e.end_with?("/")
|
||||
entry.in_path?(
|
||||
if entry.end_with?("/")
|
||||
entry_path.in_path?(
|
||||
item
|
||||
)
|
||||
|
||||
else
|
||||
File.fnmatch?(item, entry) ||
|
||||
entry.to_path.start_with?(
|
||||
File.fnmatch?(item, entry_path) ||
|
||||
entry_path.to_path.start_with?(
|
||||
item
|
||||
)
|
||||
end
|
||||
|
|
|
@ -42,12 +42,12 @@ module Jekyll
|
|||
@stats[filename][:time] += time
|
||||
end
|
||||
|
||||
def stats_table(n = 50)
|
||||
LiquidRenderer::Table.new(@stats).to_s(n)
|
||||
def stats_table(num_of_rows = 50)
|
||||
LiquidRenderer::Table.new(@stats).to_s(num_of_rows)
|
||||
end
|
||||
|
||||
def self.format_error(e, path)
|
||||
"#{e.message} in #{path}"
|
||||
def self.format_error(error, path)
|
||||
"#{error.message} in #{path}"
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -6,8 +6,8 @@ module Jekyll
|
|||
@stats = stats
|
||||
end
|
||||
|
||||
def to_s(n = 50)
|
||||
data = data_for_table(n)
|
||||
def to_s(num_of_rows = 50)
|
||||
data = data_for_table(num_of_rows)
|
||||
widths = table_widths(data)
|
||||
generate_table(data, widths)
|
||||
end
|
||||
|
@ -63,16 +63,16 @@ module Jekyll
|
|||
|
||||
data.each do |row|
|
||||
row.each_with_index do |cell, index|
|
||||
widths[index] = [ cell.length, widths[index] ].compact.max
|
||||
widths[index] = [cell.length, widths[index]].compact.max
|
||||
end
|
||||
end
|
||||
|
||||
widths
|
||||
end
|
||||
|
||||
def data_for_table(n)
|
||||
def data_for_table(num_of_rows)
|
||||
sorted = @stats.sort_by { |_, file_stats| -file_stats[:time] }
|
||||
sorted = sorted.slice(0, n)
|
||||
sorted = sorted.slice(0, num_of_rows)
|
||||
|
||||
table = [%w(Filename Count Bytes Time)]
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ module Jekyll
|
|||
|
||||
private
|
||||
def proc_version
|
||||
@cached_proc_version ||= begin
|
||||
@proc_version ||= begin
|
||||
Pathutil.new(
|
||||
"/proc/version"
|
||||
).read
|
||||
|
|
|
@ -307,7 +307,7 @@ class TestCommandsServe < JekyllUnitTest
|
|||
})
|
||||
|
||||
assert result[:SSLEnable]
|
||||
assert_equal result[:SSLPrivateKey ], "c2"
|
||||
assert_equal result[:SSLPrivateKey], "c2"
|
||||
assert_equal result[:SSLCertificate], "c1"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -931,7 +931,7 @@ class TestFilters < JekyllUnitTest
|
|||
end
|
||||
|
||||
should "filter with other operators" do
|
||||
assert_equal [3, 4, 5], @filter.where_exp([ 1, 2, 3, 4, 5 ], "n", "n >= 3")
|
||||
assert_equal [3, 4, 5], @filter.where_exp([1, 2, 3, 4, 5], "n", "n >= 3")
|
||||
end
|
||||
|
||||
objects = [
|
||||
|
@ -1101,9 +1101,9 @@ class TestFilters < JekyllUnitTest
|
|||
end
|
||||
should "return sorted by subproperty array" do
|
||||
assert_equal [{ "a" => { "b" => 1 } }, { "a" => { "b" => 2 } },
|
||||
{ "a" => { "b" => 3 } }, ],
|
||||
{ "a" => { "b" => 3 } },],
|
||||
@filter.sort([{ "a" => { "b" => 2 } }, { "a" => { "b" => 1 } },
|
||||
{ "a" => { "b" => 3 } }, ], "a.b")
|
||||
{ "a" => { "b" => 3 } },], "a.b")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue