parent
2c0f5b3059
commit
d3b00cb84c
65
.rubocop.yml
65
.rubocop.yml
|
|
@ -9,6 +9,38 @@ AllCops:
|
||||||
- benchmark/**/*
|
- benchmark/**/*
|
||||||
- script/**/*
|
- script/**/*
|
||||||
- vendor/**/*
|
- vendor/**/*
|
||||||
|
Layout/AlignArray:
|
||||||
|
Enabled: false
|
||||||
|
Layout/AlignHash:
|
||||||
|
EnforcedHashRocketStyle: table
|
||||||
|
Layout/AlignParameters:
|
||||||
|
Enabled: false
|
||||||
|
Layout/EmptyLinesAroundAccessModifier:
|
||||||
|
Enabled: false
|
||||||
|
Layout/EmptyLinesAroundModuleBody:
|
||||||
|
Enabled: false
|
||||||
|
Layout/EndOfLine:
|
||||||
|
EnforcedStyle: lf
|
||||||
|
Layout/ExtraSpacing:
|
||||||
|
AllowForAlignment: true
|
||||||
|
Layout/FirstParameterIndentation:
|
||||||
|
EnforcedStyle: consistent
|
||||||
|
Layout/IndentationWidth:
|
||||||
|
Severity: error
|
||||||
|
Layout/IndentArray:
|
||||||
|
EnforcedStyle: consistent
|
||||||
|
Layout/IndentHash:
|
||||||
|
EnforcedStyle: consistent
|
||||||
|
Layout/IndentHeredoc:
|
||||||
|
Enabled: false
|
||||||
|
Layout/MultilineMethodCallIndentation:
|
||||||
|
EnforcedStyle: indented
|
||||||
|
Layout/MultilineOperationIndentation:
|
||||||
|
EnforcedStyle: indented
|
||||||
|
Layout/SpaceAroundOperators:
|
||||||
|
Enabled: true
|
||||||
|
Layout/SpaceInsideBrackets:
|
||||||
|
Enabled: false
|
||||||
Lint/EndAlignment:
|
Lint/EndAlignment:
|
||||||
Severity: error
|
Severity: error
|
||||||
Lint/UnreachableCode:
|
Lint/UnreachableCode:
|
||||||
|
|
@ -59,13 +91,6 @@ Security/YAMLLoad:
|
||||||
- !ruby/regexp /test\/.*.rb$/
|
- !ruby/regexp /test\/.*.rb$/
|
||||||
Style/Alias:
|
Style/Alias:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Style/AlignArray:
|
|
||||||
Enabled: false
|
|
||||||
Style/AlignHash:
|
|
||||||
EnforcedHashRocketStyle: table
|
|
||||||
Style/AlignParameters:
|
|
||||||
Enabled: false
|
|
||||||
EnforcedStyle: with_fixed_indentation
|
|
||||||
Style/AndOr:
|
Style/AndOr:
|
||||||
Severity: error
|
Severity: error
|
||||||
Style/Attr:
|
Style/Attr:
|
||||||
|
|
@ -80,18 +105,8 @@ Style/Documentation:
|
||||||
- !ruby/regexp /features\/.*.rb$/
|
- !ruby/regexp /features\/.*.rb$/
|
||||||
Style/DoubleNegation:
|
Style/DoubleNegation:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Style/EmptyLinesAroundAccessModifier:
|
|
||||||
Enabled: false
|
|
||||||
Style/EmptyLinesAroundModuleBody:
|
|
||||||
Enabled: false
|
|
||||||
Style/EndOfLine:
|
|
||||||
EnforcedStyle: lf
|
|
||||||
Style/ExtraSpacing:
|
|
||||||
AllowForAlignment: true
|
|
||||||
Style/FileName:
|
Style/FileName:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Style/FirstParameterIndentation:
|
|
||||||
EnforcedStyle: consistent
|
|
||||||
Style/GuardClause:
|
Style/GuardClause:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Style/HashSyntax:
|
Style/HashSyntax:
|
||||||
|
|
@ -99,22 +114,10 @@ Style/HashSyntax:
|
||||||
Severity: error
|
Severity: error
|
||||||
Style/IfUnlessModifier:
|
Style/IfUnlessModifier:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Style/IndentArray:
|
|
||||||
EnforcedStyle: consistent
|
|
||||||
Style/IndentHash:
|
|
||||||
EnforcedStyle: consistent
|
|
||||||
Style/IndentHeredoc:
|
|
||||||
Enabled: false
|
|
||||||
Style/IndentationWidth:
|
|
||||||
Severity: error
|
|
||||||
Style/InverseMethods:
|
Style/InverseMethods:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Style/ModuleFunction:
|
Style/ModuleFunction:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Style/MultilineMethodCallIndentation:
|
|
||||||
EnforcedStyle: indented
|
|
||||||
Style/MultilineOperationIndentation:
|
|
||||||
EnforcedStyle: indented
|
|
||||||
Style/MultilineTernaryOperator:
|
Style/MultilineTernaryOperator:
|
||||||
Severity: error
|
Severity: error
|
||||||
Style/PercentLiteralDelimiters:
|
Style/PercentLiteralDelimiters:
|
||||||
|
|
@ -138,10 +141,6 @@ Style/SignalException:
|
||||||
EnforcedStyle: only_raise
|
EnforcedStyle: only_raise
|
||||||
Style/SingleLineMethods:
|
Style/SingleLineMethods:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
Style/SpaceAroundOperators:
|
|
||||||
Enabled: false
|
|
||||||
Style/SpaceInsideBrackets:
|
|
||||||
Enabled: false
|
|
||||||
Style/StringLiterals:
|
Style/StringLiterals:
|
||||||
EnforcedStyle: double_quotes
|
EnforcedStyle: double_quotes
|
||||||
Style/StringLiteralsInInterpolation:
|
Style/StringLiteralsInInterpolation:
|
||||||
|
|
|
||||||
2
Gemfile
2
Gemfile
|
|
@ -25,7 +25,7 @@ group :test do
|
||||||
gem "nokogiri"
|
gem "nokogiri"
|
||||||
gem "rspec"
|
gem "rspec"
|
||||||
gem "rspec-mocks"
|
gem "rspec-mocks"
|
||||||
gem "rubocop", "~> 0.48.1"
|
gem "rubocop", "~> 0.49.1"
|
||||||
gem "test-dependency-theme", :path => File.expand_path("./test/fixtures/test-dependency-theme", File.dirname(__FILE__))
|
gem "test-dependency-theme", :path => File.expand_path("./test/fixtures/test-dependency-theme", File.dirname(__FILE__))
|
||||||
gem "test-theme", :path => File.expand_path("./test/fixtures/test-theme", File.dirname(__FILE__))
|
gem "test-theme", :path => File.expand_path("./test/fixtures/test-theme", File.dirname(__FILE__))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ end
|
||||||
def all_steps_to_path(path)
|
def all_steps_to_path(path)
|
||||||
source = source_dir
|
source = source_dir
|
||||||
dest = Pathname.new(path).expand_path
|
dest = Pathname.new(path).expand_path
|
||||||
paths = []
|
paths = []
|
||||||
|
|
||||||
dest.ascend do |f|
|
dest.ascend do |f|
|
||||||
break if f == source
|
break if f == source
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ module Jekyll
|
||||||
if docs.respond_to?(method.to_sym)
|
if docs.respond_to?(method.to_sym)
|
||||||
Jekyll.logger.warn "Deprecation:",
|
Jekyll.logger.warn "Deprecation:",
|
||||||
"#{label}.#{method} should be changed to #{label}.docs.#{method}."
|
"#{label}.#{method} should be changed to #{label}.docs.#{method}."
|
||||||
Jekyll.logger.warn "", "Called by #{caller.first}."
|
Jekyll.logger.warn "", "Called by #{caller(0..0)}."
|
||||||
docs.public_send(method.to_sym, *args, &blck)
|
docs.public_send(method.to_sym, *args, &blck)
|
||||||
else
|
else
|
||||||
super
|
super
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ module Jekyll
|
||||||
|
|
||||||
private
|
private
|
||||||
def format_url(ssl_enabled, address, port, baseurl = nil)
|
def format_url(ssl_enabled, address, port, baseurl = nil)
|
||||||
format("%{prefix}://%{address}:%{port}%{baseurl}", {
|
format("%<prefix>s://%<address>s:%<port>i%<baseurl>s", {
|
||||||
:prefix => ssl_enabled ? "https" : "http",
|
:prefix => ssl_enabled ? "https" : "http",
|
||||||
:address => address,
|
:address => address,
|
||||||
:port => port,
|
:port => port,
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# Returns the String prefix.
|
# Returns the String prefix.
|
||||||
def self.highlighter_prefix(highlighter_prefix = nil)
|
def self.highlighter_prefix(highlighter_prefix = nil)
|
||||||
if !defined?(@highlighter_prefix) || !highlighter_prefix.nil?
|
unless defined?(@highlighter_prefix) && highlighter_prefix.nil?
|
||||||
@highlighter_prefix = highlighter_prefix
|
@highlighter_prefix = highlighter_prefix
|
||||||
end
|
end
|
||||||
@highlighter_prefix
|
@highlighter_prefix
|
||||||
|
|
@ -22,7 +22,7 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# Returns the String suffix.
|
# Returns the String suffix.
|
||||||
def self.highlighter_suffix(highlighter_suffix = nil)
|
def self.highlighter_suffix(highlighter_suffix = nil)
|
||||||
if !defined?(@highlighter_suffix) || !highlighter_suffix.nil?
|
unless defined?(@highlighter_suffix) && highlighter_suffix.nil?
|
||||||
@highlighter_suffix = highlighter_suffix
|
@highlighter_suffix = highlighter_suffix
|
||||||
end
|
end
|
||||||
@highlighter_suffix
|
@highlighter_suffix
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,7 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# Returns true if extname == .coffee, false otherwise.
|
# Returns true if extname == .coffee, false otherwise.
|
||||||
def coffeescript_file?
|
def coffeescript_file?
|
||||||
".coffee" == ext
|
ext == ".coffee"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Determine whether the file should be rendered with Liquid.
|
# Determine whether the file should be rendered with Liquid.
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# Returns true if extname == .coffee, false otherwise.
|
# Returns true if extname == .coffee, false otherwise.
|
||||||
def coffeescript_file?
|
def coffeescript_file?
|
||||||
".coffee" == extname
|
extname == ".coffee"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Determine whether the file should be rendered with Liquid.
|
# Determine whether the file should be rendered with Liquid.
|
||||||
|
|
@ -371,7 +371,7 @@ module Jekyll
|
||||||
if data.key?(method.to_s)
|
if data.key?(method.to_s)
|
||||||
Jekyll::Deprecator.deprecation_message "Document##{method} is now a key "\
|
Jekyll::Deprecator.deprecation_message "Document##{method} is now a key "\
|
||||||
"in the #data hash."
|
"in the #data hash."
|
||||||
Jekyll::Deprecator.deprecation_message "Called by #{caller.first}."
|
Jekyll::Deprecator.deprecation_message "Called by #{caller(0..0)}."
|
||||||
data[method.to_s]
|
data[method.to_s]
|
||||||
else
|
else
|
||||||
super
|
super
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ module Jekyll
|
||||||
|
|
||||||
# register a single hook to be called later, internal API
|
# register a single hook to be called later, internal API
|
||||||
def self.register_one(owner, event, priority, &block)
|
def self.register_one(owner, event, priority, &block)
|
||||||
@registry[owner] ||={
|
@registry[owner] ||= {
|
||||||
:post_init => [],
|
:post_init => [],
|
||||||
:pre_render => [],
|
:pre_render => [],
|
||||||
:post_render => [],
|
:post_render => [],
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ module Jekyll
|
||||||
|
|
||||||
row_data.each_index do |cell_index|
|
row_data.each_index do |cell_index|
|
||||||
str << "-" * widths[cell_index]
|
str << "-" * widths[cell_index]
|
||||||
str << "-+-" unless cell_index == row_data.length-1
|
str << "-+-" unless cell_index == row_data.length - 1
|
||||||
end
|
end
|
||||||
|
|
||||||
str << "\n"
|
str << "\n"
|
||||||
|
|
@ -49,7 +49,7 @@ module Jekyll
|
||||||
cell_data.rjust(widths[cell_index], " ")
|
cell_data.rjust(widths[cell_index], " ")
|
||||||
end
|
end
|
||||||
|
|
||||||
str << " | " unless cell_index == row_data.length-1
|
str << " | " unless cell_index == row_data.length - 1
|
||||||
end
|
end
|
||||||
|
|
||||||
str << "\n"
|
str << "\n"
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# Returns the safety Boolean.
|
# Returns the safety Boolean.
|
||||||
def self.safe(safe = nil)
|
def self.safe(safe = nil)
|
||||||
if !defined?(@safe) || !safe.nil?
|
unless defined?(@safe) && safe.nil?
|
||||||
@safe = safe
|
@safe = safe
|
||||||
end
|
end
|
||||||
@safe || false
|
@safe || false
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# Returns a rational number.
|
# Returns a rational number.
|
||||||
def rational_hour(seconds)
|
def rational_hour(seconds)
|
||||||
seconds.to_r/3600
|
seconds.to_r / 3600
|
||||||
end
|
end
|
||||||
|
|
||||||
# Private: Convert given seconds to an hour as an absolute number.
|
# Private: Convert given seconds to an hour as an absolute number.
|
||||||
|
|
@ -56,7 +56,7 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# Returns an integer.
|
# Returns an integer.
|
||||||
def absolute_hour(seconds)
|
def absolute_hour(seconds)
|
||||||
seconds.abs/3600
|
seconds.abs / 3600
|
||||||
end
|
end
|
||||||
|
|
||||||
# Private: Perform a modulo operation on a given fraction.
|
# Private: Perform a modulo operation on a given fraction.
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ class TestDocument < JekyllUnitTest
|
||||||
@site = fixture_site({
|
@site = fixture_site({
|
||||||
"collections" => ["slides"],
|
"collections" => ["slides"],
|
||||||
"defaults" => [{
|
"defaults" => [{
|
||||||
"scope" => { "path"=>"", "type"=>"slides" },
|
"scope" => { "path" => "", "type" => "slides" },
|
||||||
"values" => {
|
"values" => {
|
||||||
"nested" => {
|
"nested" => {
|
||||||
"key" => "myval",
|
"key" => "myval",
|
||||||
|
|
@ -139,7 +139,7 @@ class TestDocument < JekyllUnitTest
|
||||||
@site = fixture_site({
|
@site = fixture_site({
|
||||||
"collections" => ["slides"],
|
"collections" => ["slides"],
|
||||||
"defaults" => [{
|
"defaults" => [{
|
||||||
"scope" => { "path"=>"", "type"=>"slides" },
|
"scope" => { "path" => "", "type" => "slides" },
|
||||||
"values" => {
|
"values" => {
|
||||||
"nested" => {
|
"nested" => {
|
||||||
"test1" => "default1",
|
"test1" => "default1",
|
||||||
|
|
@ -156,7 +156,7 @@ class TestDocument < JekyllUnitTest
|
||||||
assert_equal "Override title", @document.data["title"]
|
assert_equal "Override title", @document.data["title"]
|
||||||
assert_equal "slide", @document.data["layout"]
|
assert_equal "slide", @document.data["layout"]
|
||||||
assert_equal(
|
assert_equal(
|
||||||
{ "test1"=>"override1", "test2"=>"override2" },
|
{ "test1" => "override1", "test2" => "override2" },
|
||||||
@document.data["nested"]
|
@document.data["nested"]
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
@ -167,7 +167,7 @@ class TestDocument < JekyllUnitTest
|
||||||
@site = fixture_site({
|
@site = fixture_site({
|
||||||
"collections" => ["slides"],
|
"collections" => ["slides"],
|
||||||
"defaults" => [{
|
"defaults" => [{
|
||||||
"scope" => { "path"=>"_slides", "type"=>"slides" },
|
"scope" => { "path" => "_slides", "type" => "slides" },
|
||||||
"values" => {
|
"values" => {
|
||||||
"nested" => {
|
"nested" => {
|
||||||
"key" => "value123",
|
"key" => "value123",
|
||||||
|
|
@ -191,7 +191,7 @@ class TestDocument < JekyllUnitTest
|
||||||
@site = fixture_site({
|
@site = fixture_site({
|
||||||
"collections" => ["slides"],
|
"collections" => ["slides"],
|
||||||
"defaults" => [{
|
"defaults" => [{
|
||||||
"scope" => { "path"=>"somepath", "type"=>"slides" },
|
"scope" => { "path" => "somepath", "type" => "slides" },
|
||||||
"values" => {
|
"values" => {
|
||||||
"nested" => {
|
"nested" => {
|
||||||
"key" => "myval",
|
"key" => "myval",
|
||||||
|
|
|
||||||
|
|
@ -689,7 +689,7 @@ class TestFilters < JekyllUnitTest
|
||||||
end
|
end
|
||||||
|
|
||||||
should "filter objects in a hash appropriately" do
|
should "filter objects in a hash appropriately" do
|
||||||
hash = { "a"=>{ "color"=>"red" }, "b"=>{ "color"=>"blue" } }
|
hash = { "a" => { "color"=>"red" }, "b" => { "color"=>"blue" } }
|
||||||
assert_equal 1, @filter.where(hash, "color", "red").length
|
assert_equal 1, @filter.where(hash, "color", "red").length
|
||||||
assert_equal [{ "color"=>"red" }], @filter.where(hash, "color", "red")
|
assert_equal [{ "color"=>"red" }], @filter.where(hash, "color", "red")
|
||||||
end
|
end
|
||||||
|
|
@ -754,7 +754,7 @@ class TestFilters < JekyllUnitTest
|
||||||
end
|
end
|
||||||
|
|
||||||
should "filter objects in a hash appropriately" do
|
should "filter objects in a hash appropriately" do
|
||||||
hash = { "a"=>{ "color"=>"red" }, "b"=>{ "color"=>"blue" } }
|
hash = { "a" => { "color"=>"red" }, "b" => { "color"=>"blue" } }
|
||||||
assert_equal 1, @filter.where_exp(hash, "item", "item.color == 'red'").length
|
assert_equal 1, @filter.where_exp(hash, "item", "item.color == 'red'").length
|
||||||
assert_equal(
|
assert_equal(
|
||||||
[{ "color"=>"red" }],
|
[{ "color"=>"red" }],
|
||||||
|
|
@ -882,9 +882,9 @@ class TestFilters < JekyllUnitTest
|
||||||
|
|
||||||
should "allow more complex filters" do
|
should "allow more complex filters" do
|
||||||
items = [
|
items = [
|
||||||
{ "version"=>"1.0", "result"=>"slow" },
|
{ "version" => "1.0", "result" => "slow" },
|
||||||
{ "version"=>"1.1.5", "result"=>"medium" },
|
{ "version" => "1.1.5", "result" => "medium" },
|
||||||
{ "version"=>"2.7.3", "result"=>"fast" },
|
{ "version" => "2.7.3", "result" => "fast" },
|
||||||
]
|
]
|
||||||
|
|
||||||
result = @filter.group_by_exp(items, "item", "item.version | split: '.' | first")
|
result = @filter.group_by_exp(items, "item", "item.version | split: '.' | first")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue