Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jekyll 4 Support #16

Merged
merged 5 commits into from
Oct 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ _site
*.gem
Gemfile.lock
.ruby*
spec/fixtures/**/.jekyll-cache
9 changes: 8 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
inherit_from: .rubocop_todo.yml

require:
- rubocop-performance
- rubocop-rspec
- rubocop-jekyll

inherit_gem:
jekyll: .rubocop.yml
rubocop-jekyll: .rubocop.yml

AllCops:
Exclude:
Expand Down
35 changes: 35 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2019-10-30 13:02:41 -0400 using RuboCop version 0.71.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 7
# Configuration parameters: Prefixes.
# Prefixes: when, with, without
RSpec/ContextWording:
Exclude:
- "spec/jekyll-readme-index/generator_spec.rb"

# Offense count: 1
# Configuration parameters: CustomTransform, IgnoreMethods.
RSpec/FilePath:
Exclude:
- "spec/jekyll-readme-index/generator_spec.rb"

# Offense count: 18
# Configuration parameters: AggregateFailuresByDefault.
RSpec/MultipleExpectations:
Max: 3

# Offense count: 26
# Configuration parameters: IgnoreSharedExamples.
RSpec/NamedSubject:
Exclude:
- "spec/jekyll-readme-index/generator_spec.rb"

# Offense count: 20
RSpec/NestedGroups:
Max: 4
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
rvm:
- 2.2
rvm: 2.5
before_install: gem install bundler
language: ruby
script: script/cibuild
sudo: false
cache: bundler

env:
- JEKYLL_VERSION="~> 3.0"
- JEKYLL_VERSION="~> 4.0"
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# frozen_string_literal: true

source "https://rubygems.org"

gemspec

gem "jekyll", ENV["JEKYLL_VERSION"] if ENV["JEKYLL_VERSION"]
9 changes: 6 additions & 3 deletions jekyll-readme-index.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: utf-8
# frozen_string_literal: true

$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift File.expand_path("lib", __dir__)
require "jekyll-readme-index/version"

Gem::Specification.new do |s|
Expand All @@ -16,7 +16,10 @@ Gem::Specification.new do |s|
s.require_paths = ["lib"]
s.license = "MIT"

s.add_runtime_dependency "jekyll", "~> 3.0"
s.add_runtime_dependency "jekyll", ">= 3.0", "< 5.0"
s.add_development_dependency "rspec", "~> 3.5"
s.add_development_dependency "rubocop", "~> 0.40"
s.add_development_dependency "rubocop-jekyll", "~> 0.10.0"
s.add_development_dependency "rubocop-performance", "~> 1.5"
s.add_development_dependency "rubocop-rspec", "~> 1.3"
end
13 changes: 8 additions & 5 deletions lib/jekyll-readme-index/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

module JekyllReadmeIndex
class Generator < Jekyll::Generator
INDEX_REGEX = %r!$|index\.(html?|xhtml|xml)$!i
INDEX_REGEX = %r!$|index\.(html?|xhtml|xml)$!i.freeze

attr_accessor :site

safe true
priority :low

CONFIG_KEY = "readme_index".freeze
ENABLED_KEY = "enabled".freeze
CLEANUP_KEY = "remove_originals".freeze
FRONTMATTER_KEY = "with_frontmatter".freeze
CONFIG_KEY = "readme_index"
ENABLED_KEY = "enabled"
CLEANUP_KEY = "remove_originals"
FRONTMATTER_KEY = "with_frontmatter"

def initialize(site)
@site = site
Expand All @@ -24,13 +24,15 @@ def generate(site)

readmes.each do |readme|
next unless should_be_index?(readme)

site.pages << readme.to_page
site.static_files.delete(readme) if cleanup?
end

if with_frontmatter?
readmes_with_frontmatter.each do |readme|
next unless should_be_index?(readme)

readme.update_permalink
end
end
Expand All @@ -50,6 +52,7 @@ def readmes_with_frontmatter
# Should the given readme be the containing directory's index?
def should_be_index?(readme)
return false unless readme

!dir_has_index? File.dirname(readme.url)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/jekyll-readme-index/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module JekyllReadmeIndex
VERSION = "0.2.0".freeze
VERSION = "0.2.0"
end
Loading