Skip to content

Commit b8b0bf1

Browse files
committed
appease Rubocop
1 parent 5c47d05 commit b8b0bf1

File tree

6 files changed

+41
-50
lines changed

6 files changed

+41
-50
lines changed

.rubocop.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
inherit_gem:
22
jekyll: .rubocop.yml
3+
4+
5+
Metrics/BlockLength:
6+
Exclude:
7+
- test/**/*.rb
8+
Metrics/LineLength:
9+
Exclude:
10+
- test/**/*.rb

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
source 'https://rubygems.org'
1+
source "https://rubygems.org"
22
gemspec
33

44
if ENV["GH_PAGES"]
@@ -8,4 +8,4 @@ elsif ENV["JEKYLL_VERSION"]
88
end
99

1010
# Support for Ruby < 2.2.2 & activesupport
11-
gem "activesupport", "~> 4.2" if RUBY_VERSION < '2.2.2'
11+
gem "activesupport", "~> 4.2" if RUBY_VERSION < "2.2.2"

Rakefile

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# From jekyll/jekyll-mentions
22

3-
require 'rubygems'
4-
require 'bundler'
3+
require "rubygems"
4+
require "bundler"
55

66
begin
77
Bundler.setup(:default, :development, :test)
@@ -11,25 +11,22 @@ rescue Bundler::BundlerError => e
1111
exit e.status_code
1212
end
1313

14-
1514
# Test task
1615

17-
require 'rake'
18-
require 'rake/testtask'
16+
require "rake"
17+
require "rake/testtask"
1918

2019
Rake::TestTask.new(:test) do |test|
21-
test.libs << 'lib' << 'test'
22-
test.pattern = 'test/**/test_*.rb'
23-
test.verbose = true
20+
test.libs << "lib" << "test"
21+
test.pattern = "test/**/test_*.rb"
2422
end
2523

26-
task :default => 'test'
27-
24+
task :default => "test"
2825

2926
# Release task
3027

3128
def name
32-
@name ||= File.basename(Dir['*.gemspec'].first, ".*")
29+
@name ||= File.basename(Dir["*.gemspec"].first, ".*")
3330
end
3431

3532
def version
@@ -46,7 +43,7 @@ end
4643

4744
desc "Release #{name} v#{version}"
4845
task :release => :build do
49-
unless `git branch` =~ /^\* master$/
46+
unless `git branch` =~ %r!^\* master$!
5047
puts "You must be on the master branch to release!"
5148
exit!
5249
end

jekyll-archives.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ Gem::Specification.new do |s|
1515

1616
s.add_dependency "jekyll", ">= 2.4"
1717

18+
s.add_development_dependency "minitest"
1819
s.add_development_dependency "rake"
1920
s.add_development_dependency "rdoc"
20-
s.add_development_dependency "shoulda"
21-
s.add_development_dependency "minitest"
2221
s.add_development_dependency "rubocop"
22+
s.add_development_dependency "shoulda"
2323
end

lib/jekyll-archives/archive.rb

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module Jekyll
22
module Archives
33
class Archive < Jekyll::Page
4-
54
attr_accessor :posts, :type, :slug
65

76
# Attributes for Liquid templates
@@ -30,10 +29,9 @@ def initialize(site, title, type, posts)
3029
@title = title
3130
@config = site.config["jekyll-archives"]
3231

33-
# Generate slug if tag or category (taken from jekyll/jekyll/features/support/env.rb)
34-
if title.is_a? String
35-
@slug = Utils.slugify(title)
36-
end
32+
# Generate slug if tag or category
33+
# (taken from jekyll/jekyll/features/support/env.rb)
34+
@slug = Utils.slugify(title) if title.is_a? String
3735

3836
# Use ".html" for file extension and url for path
3937
@ext = File.extname(relative_path)
@@ -68,7 +66,7 @@ def layout
6866
# desired placeholder replacements. For details see "url.rb".
6967
def url_placeholders
7068
if @title.is_a? Hash
71-
@title.merge({ :type => @type })
69+
@title.merge(:type => @type)
7270
else
7371
{ :name => @slug, :type => @type }
7472
end
@@ -88,7 +86,7 @@ def url
8886
end
8987

9088
def permalink
91-
data && data.is_a?(Hash) && data['permalink']
89+
data && data.is_a?(Hash) && data["permalink"]
9290
end
9391

9492
# Add any necessary layouts to this post
@@ -115,7 +113,7 @@ def add_dependencies
115113
end
116114
end
117115
end
118-
116+
119117
# Convert this Convertible's data to a Hash suitable for use by Liquid.
120118
#
121119
# Returns the Hash representation of this Convertible.
@@ -132,9 +130,7 @@ def to_liquid(attrs = nil)
132130
# Returns a String (for tag and category archives) and nil for
133131
# date-based archives.
134132
def title
135-
if @title.is_a? String
136-
@title
137-
end
133+
@title if @title.is_a? String
138134
end
139135

140136
# Produce a date object if a date-based archive
@@ -151,8 +147,8 @@ def date
151147
#
152148
# Returns the destination relative path String.
153149
def relative_path
154-
path = URL.unescape_path(url).gsub(/^\//, "")
155-
path = File.join(path, "index.html") if url =~ /\/$/
150+
path = URL.unescape_path(url).gsub(%r!^\/!, "")
151+
path = File.join(path, "index.html") if url =~ %r!\/$!
156152
path
157153
end
158154

test/test_jekyll_archives.rb

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
class TestJekyllArchives < Minitest::Test
44
context "the jekyll-archives plugin" do
55
setup do
6-
@site = fixture_site({
7-
"jekyll-archives" => {
8-
"enabled" => true
9-
}
6+
@site = fixture_site("jekyll-archives" => {
7+
"enabled" => true
108
})
119
@site.read
1210
@archives = Jekyll::Archives::Archives.new(@site.config)
@@ -50,11 +48,9 @@ class TestJekyllArchives < Minitest::Test
5048

5149
context "the jekyll-archives plugin with custom layout path" do
5250
setup do
53-
@site = fixture_site({
54-
"jekyll-archives" => {
55-
"layout" => "archive-too",
56-
"enabled" => true
57-
}
51+
@site = fixture_site("jekyll-archives" => {
52+
"layout" => "archive-too",
53+
"enabled" => true
5854
})
5955
@site.process
6056
end
@@ -111,10 +107,8 @@ class TestJekyllArchives < Minitest::Test
111107

112108
context "the archives" do
113109
setup do
114-
@site = fixture_site({
115-
"jekyll-archives" => {
116-
"enabled" => true
117-
}
110+
@site = fixture_site("jekyll-archives" => {
111+
"enabled" => true
118112
})
119113
@site.process
120114
end
@@ -137,10 +131,8 @@ class TestJekyllArchives < Minitest::Test
137131

138132
context "the jekyll-archives plugin with enabled array" do
139133
setup do
140-
@site = fixture_site({
141-
"jekyll-archives" => {
142-
"enabled" => ["tags"]
143-
}
134+
@site = fixture_site("jekyll-archives" => {
135+
"enabled" => ["tags"]
144136
})
145137
@site.process
146138
end
@@ -161,10 +153,8 @@ class TestJekyllArchives < Minitest::Test
161153

162154
context "the jekyll-archives plugin" do
163155
setup do
164-
@site = fixture_site({
165-
"jekyll-archives" => {
166-
"enabled" => true
167-
}
156+
@site = fixture_site("jekyll-archives" => {
157+
"enabled" => true
168158
})
169159
@site.process
170160
@archives = @site.config["archives"]

0 commit comments

Comments
 (0)