Skip to content

Commit

Permalink
Modernize tests & linting (#114)
Browse files Browse the repository at this point in the history
Merge pull request 114
  • Loading branch information
parkr authored and jekyllbot committed Dec 3, 2017
1 parent b38002b commit a7a5a84
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 51 deletions.
8 changes: 7 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
inherit_gem:
jekyll: .rubocop.yml

AllCops:
TargetRubyVersion: 2.1
Exclude:
- vendor/**/*

Lint/ShadowingOuterLocalVariable:
Exclude:
- lib/jekyll-archives.rb

Metrics/BlockLength:
Exclude:
- test/**/*.rb

Metrics/LineLength:
Exclude:
- test/**/*.rb
- lib/jekyll-archives.rb
- lib/jekyll-archives/archive.rb
- test/**/*.rb
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ rvm:

env:
- ""
- JEKYLL_VERSION=3.4
- JEKYLL_VERSION=3.6

matrix:
include:
Expand Down
42 changes: 2 additions & 40 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# frozen_string_literal: true

# From jekyll/jekyll-mentions

require "rubygems"
require "bundler"
require "bundler/gem_tasks"

begin
Bundler.setup(:default, :development, :test)
Expand All @@ -21,44 +20,7 @@ require "rake/testtask"
Rake::TestTask.new(:test) do |test|
test.libs << "lib" << "test"
test.pattern = "test/**/test_*.rb"
test.warning = false
end

task :default => "test"

# Release task

def name
@name ||= File.basename(Dir["*.gemspec"].first, ".*")
end

def version
Jekyll::Archives::VERSION
end

def gemspec_file
"#{name}.gemspec"
end

def gem_file
"#{name}-#{version}.gem"
end

desc "Release #{name} v#{version}"
task :release => :build do
unless `git branch` =~ %r!^\* master$!
puts "You must be on the master branch to release!"
exit!
end
sh "git commit --allow-empty -m 'Release :gem: #{version}'"
sh "git tag v#{version}"
sh "git push origin master"
sh "git push origin v#{version}"
sh "gem push pkg/#{name}-#{version}.gem"
end

desc "Build #{name} v#{version} into pkg/"
task :build do
mkdir_p "pkg"
sh "gem build #{gemspec_file}"
sh "mv #{gem_file} pkg"
end
6 changes: 4 additions & 2 deletions jekyll-archives.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ Gem::Specification.new do |s|

s.homepage = "https://github.com/jekyll/jekyll-archives"
s.licenses = ["MIT"]
s.files = ["lib/jekyll-archives.rb", "lib/jekyll-archives/archive.rb"]

s.add_dependency "jekyll", ">= 2.4"
all_files = `git ls-files -z`.split("\x0")
s.files = all_files.grep(%r!^(lib)/!)

s.add_dependency "jekyll", ">= 3.1"

s.add_development_dependency "minitest"
s.add_development_dependency "rake"
Expand Down
6 changes: 1 addition & 5 deletions lib/jekyll-archives.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ class Archives < Jekyll::Generator
}.freeze

def initialize(config = nil)
@config = if config["jekyll-archives"].nil?
DEFAULTS
else
Utils.deep_merge_hashes(DEFAULTS, config["jekyll-archives"])
end
@config = Utils.deep_merge_hashes(DEFAULTS, config.fetch("jekyll-archives", {}))
end

def generate(site)
Expand Down
4 changes: 4 additions & 0 deletions script/bootstrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
set -ex

bundle install
10 changes: 8 additions & 2 deletions script/fmt
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#! /bin/sh
#!/bin/bash
set -e

bundle exec rubocop -S -D -E
echo "Rubocop $(bundle exec rubocop --version)"
bundle exec rubocop -S -D -E $@
success=$?
if ((success != 0)); then
echo -e "\nTry running \`script/fmt -a\` to automatically fix errors"
fi
exit $success
7 changes: 7 additions & 0 deletions script/release
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
# Tag and push a release.

set -e

script/cibuild
bundle exec rake release

0 comments on commit a7a5a84

Please sign in to comment.