diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml
index e2ce0b4..7553df2 100644
--- a/.github/workflows/ruby.yml
+++ b/.github/workflows/ruby.yml
@@ -20,13 +20,16 @@ jobs:
steps:
- uses: actions/checkout@v2
+
- name: Set up Ruby
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
# change this to (see https://github.com/ruby/setup-ruby#versioning):
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
+
- name: Install dependencies
run: bundle install
+
- name: Run tests
run: bundle exec rake
diff --git a/.gitignore b/.gitignore
index 9d4f4b9..21fd016 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,11 +1,59 @@
-/.bundle/
-/.yardoc
-/_yardoc/
+.idea/
+spec/fixtures/.jekyll-cache/
+
+*.gem
+*.rbc
+/.config
/coverage/
-/doc/
+/InstalledFiles
/pkg/
/spec/reports/
+/spec/examples.txt
+/test/tmp/
+/test/version_tmp/
/tmp/
-/vendor/
-/spec/dest/
-/designs/
+
+# Used by dotenv library to load environment variables.
+.env
+
+# Ignore Byebug command history file.
+.byebug_history
+
+## Specific to RubyMotion:
+.dat*
+.repl_history
+build/
+*.bridgesupport
+build-iPhoneOS/
+build-iPhoneSimulator/
+
+## Specific to RubyMotion (use of CocoaPods):
+#
+# We recommend against adding the Pods directory to your .gitignore. However
+# you should judge for yourself, the pros and cons are mentioned at:
+# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
+#
+# vendor/Pods/
+
+## Documentation cache and generated files:
+/.yardoc/
+/_yardoc/
+/doc/
+/rdoc/
+
+## Environment normalization:
+/.bundle/
+/vendor/bundle
+/lib/bundler/man/
+
+# for a library or gem, you might want to ignore these files since the code is
+# intended to run in multiple environments; otherwise, check them in:
+# Gemfile.lock
+# .ruby-version
+# .ruby-gemset
+
+# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
+.rvmrc
+
+# Used by RuboCop. Remote config files pulled in from inherit_from directive.
+.rubocop-https?--*
\ No newline at end of file
diff --git a/.rubocop.yml b/.rubocop.yml
new file mode 100644
index 0000000..37da352
--- /dev/null
+++ b/.rubocop.yml
@@ -0,0 +1,15 @@
+AllCops:
+ NewCops: enable
+ Exclude:
+ - "spec/**/*"
+ - "vendor/**/*"
+ TargetRubyVersion: 2.7
+
+Layout:
+ Enabled: false
+
+Metrics:
+ Enabled: false
+
+Style:
+ Enabled: false
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 093c88a..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,15 +0,0 @@
-language: ruby
-rvm:
- - 2.2
- - 2.3
- - 2.4
-before_install:
- - gem update bundler
-script:
- - bundle exec rake
-after_script:
- - bundle exec codeclimate-test-reporter
-after_success:
- - gem install package_cloud
- - bundle exec rake build
- - package_cloud push myles/jekyll-typogrify pkg/jekyll-typogrify-0.3.5.gem
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index c135eff..d3ab762 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -8,14 +8,14 @@ I love to get pull requests from everyone. By participating in this project, you
Set up your machine:
- ./bin/setup
+ make setup
Make sure the tests pass
- ./bin/test
+ make test
Make your change. Add tests for your change. Make the tests pass:
- ./bin/test
+ make test
Push to your fork and [submit a pull request](https://github.com/myles/jekyll-typogrify/compare/).
diff --git a/Gemfile b/Gemfile
index c3c7240..f802763 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,11 +1,14 @@
-source 'https://rubygems.org'
+source "https://rubygems.org"
-gem 'typogruby'
-gem 'titlecase'
+gem "titlecase"
+gem "typogruby"
group :test do
- gem 'simplecov'
- gem 'codeclimate-test-reporter', '~> 1.0.0'
+ gem "codeclimate-test-reporter", "~> 1.0.0"
+ gem "pry"
+ gem "rubocop"
+ gem "rufo"
+ gem "simplecov"
end
gemspec
diff --git a/Gemfile.lock b/Gemfile.lock
index e9c5524..d28a92f 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -10,8 +10,10 @@ GEM
specs:
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
+ ast (2.4.2)
codeclimate-test-reporter (1.0.8)
simplecov (<= 0.13)
+ coderay (1.1.3)
colorator (1.1.0)
concurrent-ruby (1.1.6)
diff-lcs (1.3)
@@ -54,13 +56,24 @@ GEM
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
mercenary (0.4.0)
+ method_source (1.0.0)
+ parallel (1.24.0)
+ parser (3.2.2.4)
+ ast (~> 2.4.1)
+ racc
pathutil (0.16.2)
forwardable-extended (~> 2.6)
+ pry (0.14.2)
+ coderay (~> 1.1)
+ method_source (~> 1.0)
public_suffix (4.0.6)
+ racc (1.7.3)
+ rainbow (3.1.1)
rake (13.0.1)
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
ffi (~> 1.0)
+ regexp_parser (2.8.3)
rexml (3.2.5)
rouge (3.20.0)
rspec (3.7.0)
@@ -76,7 +89,21 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-support (3.7.0)
+ rubocop (1.42.0)
+ json (~> 2.3)
+ parallel (~> 1.10)
+ parser (>= 3.1.2.1)
+ rainbow (>= 2.2.2, < 4.0)
+ regexp_parser (>= 1.8, < 3.0)
+ rexml (>= 3.2.5, < 4.0)
+ rubocop-ast (>= 1.24.1, < 2.0)
+ ruby-progressbar (~> 1.7)
+ unicode-display_width (>= 1.4.0, < 3.0)
+ rubocop-ast (1.30.0)
+ parser (>= 3.2.1.0)
+ ruby-progressbar (1.13.0)
rubypants (0.6.0)
+ rufo (0.16.3)
safe_yaml (1.0.5)
sassc (2.4.0)
ffi (~> 1.9)
@@ -100,8 +127,11 @@ DEPENDENCIES
codeclimate-test-reporter (~> 1.0.0)
jekyll
jekyll-typogrify!
+ pry
rake (~> 13.0)
rspec (~> 3.0)
+ rubocop
+ rufo
simplecov
titlecase
typogruby
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..ad0bf27
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,29 @@
+.PHONY: setup
+setup:
+ bundle install --path vendor/bundle
+
+.PHONY: test
+test:
+ bundle exec rake
+
+.PHONY: jekyll
+jekyll:
+ bundle exec jekyll serve \
+ --config ./spec/fixtures/_config.yml \
+ -d ./spec/dest \
+ -s ./spec/fixtures/ \
+ --watch
+
+.PHONY: console
+console:
+ bundle exec ruby bin/console
+
+.PHONY: lint
+lint:
+ bundle exec rufo -c .
+ bundle exec rubocop
+
+.PHONY: lintfix
+lintfix:
+ bundle exec rufo .
+ bundle exec rubocop -a
diff --git a/README.md b/README.md
index 75c9081..2bfbf79 100644
--- a/README.md
+++ b/README.md
@@ -150,7 +150,7 @@ Identify em dashes and surround them with a span.
## Development
-After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
+After checking out the repo, run `make setup` to install dependencies. Then, run `make console` for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
diff --git a/Rakefile b/Rakefile
index cebdd46..b7e9ed5 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,6 +1,6 @@
require "bundler/gem_tasks"
-require 'rspec/core/rake_task'
+require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)
-task :default => :spec
\ No newline at end of file
+task :default => :spec
diff --git a/appveyor.yml b/appveyor.yml
deleted file mode 100644
index 52d670b..0000000
--- a/appveyor.yml
+++ /dev/null
@@ -1,25 +0,0 @@
-version: v0.3.5-{branch}-{build}
-
-environment:
- matrix:
- - ruby_version: 22
- - ruby_version: 22-x64
- - ruby_version: 23
- - ruby_version: 23-x64
- - ruby_version: 24
- - ruby_version: 24-x64
-
-install:
- - set PATH=C:\Ruby%ruby_version%\bin;%PATH%
- - gem install bundler --no-document -v 1.10.5
- - bundle install --retry=3
-
-build: off
-
-before_test:
- - ruby -v
- - gem -v
- - bundle -v
-
-test_script:
- - bundle exec rake
diff --git a/bin/console b/bin/console
index e9763bd..dbd43e6 100755
--- a/bin/console
+++ b/bin/console
@@ -3,12 +3,5 @@
require "bundler/setup"
require "jekyll/typogrify"
-# You can add fixtures and/or initialization code here to make experimenting
-# with your gem easier. You can also use a different console, if you like.
-
-# (If you use this, don't forget to add pry to your Gemfile!)
-# require "pry"
-# Pry.start
-
-require "irb"
-IRB.start
+require "pry"
+Pry.start
diff --git a/bin/server b/bin/server
deleted file mode 100755
index 0ef3053..0000000
--- a/bin/server
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-set -euo pipefail
-IFS=$'\n\t'
-
-bundle exec jekyll serve --config ./spec/fixtures/_config.yml -d ./spec/dest -s ./spec/fixtures/ --watch
diff --git a/bin/setup b/bin/setup
deleted file mode 100755
index a63e923..0000000
--- a/bin/setup
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-set -euo pipefail
-IFS=$'\n\t'
-
-bundle install --path vendor/bundle
diff --git a/bin/test b/bin/test
deleted file mode 100755
index f16ba4c..0000000
--- a/bin/test
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-set -euo pipefail
-IFS=$'\n\t'
-
-bundle exec rake
diff --git a/jekyll-typogrify.gemspec b/jekyll-typogrify.gemspec
index 2de4a08..6e34a1e 100644
--- a/jekyll-typogrify.gemspec
+++ b/jekyll-typogrify.gemspec
@@ -1,30 +1,31 @@
# coding: utf-8
-lib = File.expand_path('../lib', __FILE__)
+lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
-require 'jekyll/typogrify/version'
+require "jekyll/typogrify/version"
Gem::Specification.new do |spec|
- spec.name = "jekyll-typogrify"
- spec.version = Jekyll::Typogrify::VERSION
- spec.summary = %q{A Jekyll plugin that improves the typography of your Liquid templates.}
- spec.description = %q{A Jekyll plugin that improves the typography of your Liquid templates.}
- spec.license = "MIT"
+ spec.name = "jekyll-typogrify"
+ spec.version = Jekyll::Typogrify::VERSION
+ spec.summary = %q{A Jekyll plugin that improves the typography of your Liquid templates.}
+ spec.description = %q{A Jekyll plugin that improves the typography of your Liquid templates.}
+ spec.license = "MIT"
- spec.authors = ["Myles Braithwaite"]
- spec.email = ["me@mylesbraithwaite.com"]
+ spec.authors = ["Myles Braithwaite"]
+ spec.email = ["me@mylesbraithwaite.com"]
- spec.homepage = "http://myles.github.io/jekyll-typogrify/"
+ spec.homepage = "https://myles.github.io/jekyll-typogrify/"
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
+ spec.bindir = "exe"
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
- spec.add_runtime_dependency "typogruby"
spec.add_runtime_dependency "titlecase"
+ spec.add_runtime_dependency "typogruby"
spec.add_development_dependency "bundler", "~> 1.7"
- spec.add_development_dependency "rspec", "~> 3.0"
- spec.add_development_dependency "rake", "~> 13.0"
spec.add_development_dependency "jekyll"
+ spec.add_development_dependency "rake", "~> 13.0"
+ spec.add_development_dependency "rspec", "~> 3.0"
+ spec.metadata["rubygems_mfa_required"] = "true"
end
diff --git a/lib/jekyll-typogrify.rb b/lib/jekyll-typogrify.rb
index a1cc649..385b66c 100644
--- a/lib/jekyll-typogrify.rb
+++ b/lib/jekyll-typogrify.rb
@@ -1,2 +1,2 @@
-# rubocop: disable FileName
-require "jekyll/typogrify"
\ No newline at end of file
+# rubocop: disable Naming/FileName
+require "jekyll/typogrify"
diff --git a/lib/jekyll/typogrify.rb b/lib/jekyll/typogrify.rb
index 70188f9..a2108e3 100644
--- a/lib/jekyll/typogrify.rb
+++ b/lib/jekyll/typogrify.rb
@@ -1,9 +1,9 @@
require "jekyll/typogrify/version"
-require 'rubypants'
-require 'typogruby'
-require 'titlecase'
-require 'liquid'
+require "rubypants"
+require "typogruby"
+require "titlecase"
+require "liquid"
module Jekyll
module TypogrifyFilter
@@ -13,7 +13,7 @@ module TypogrifyFilter
# @param [String] text input text
# @return [String] input text with ampersands wrapped
def amp(text)
- return Typogruby.amp(text.to_s)
+ Typogruby.amp(text.to_s)
end
# surrounds two or more consecutive capital letters, perhaps with
@@ -22,7 +22,7 @@ def amp(text)
# @param [String] text input text
# @return [String] input text with caps wrapped
def caps(text)
- return Typogruby.caps(text.to_s)
+ Typogruby.caps(text.to_s)
end
# Converts special characters (excluding HTML tags) to HTML entities.
@@ -31,7 +31,7 @@ def caps(text)
# @return [String] input text with all special characters converted to
# HTML entities.
def entities(text)
- return Typogruby.entities(text.to_s)
+ Typogruby.entities(text.to_s)
end
# main function to do all the functions from the method.
@@ -39,18 +39,18 @@ def entities(text)
# @param [String] text input text
# @return [String] input text with all filters applied
def improve(text)
- return Typogruby.improve(text.to_s)
+ Typogruby.improve(text.to_s)
end
# encloses initial single or double quote, or their entities
- # (optionally preceeded by a block element and perhaps an inline element)
+ # (optionally preceded by a block element and perhaps an inline element)
# with a span that can be styled.
#
# @param [String] text input text
# @return [String] input text with initial quotes wrapped
def initial_quotes(text)
- return Typogruby.initial_quotes(text.to_s)
+ Typogruby.initial_quotes(text.to_s)
end
# Applies smartypants to a given piece of text
@@ -59,7 +59,7 @@ def initial_quotes(text)
# @param [String] text input text
# @return [String] input text with smartypants applied
def smartypants(text)
- return Typogruby.smartypants(text.to_s)
+ Typogruby.smartypants(text.to_s)
end
# replaces space(s) before the last word (or tag before the last word)
@@ -72,7 +72,7 @@ def smartypants(text)
# @param [String] text input text
# @return [String] input text with non-breaking spaces inserted
def widont(text)
- return Typogruby.widont(text.to_s)
+ Typogruby.widont(text.to_s)
end
# convert a given piece of text to titlecase
@@ -80,7 +80,7 @@ def widont(text)
# @param [String] text input text
# @return [String] input text convert to titlecase
def titlecase(text)
- return text.to_s.titlecase
+ text.to_s.titlecase
end
# wraps words in a span class that can look like something else
@@ -100,7 +100,7 @@ def letter_spacing(text)
# @param [String] text input text
# @return [String] input text with caps wrapped
def jt_caps(text)
- return custom_caps(text.to_s)
+ custom_caps(text.to_s)
end
# converts a — (em dash) by optional whitespace or a non-breaking space
@@ -109,7 +109,7 @@ def jt_caps(text)
# @param [String] text input text
# @return [String] input text with em dashes wrapped
def jt_emdash(text)
- return emdash(text.to_s)
+ emdash(text.to_s)
end
private
@@ -138,7 +138,7 @@ def custom_caps(text)
elsif $3 =~ /^[\d\.]+$/
before + caps
else
- before + '' + caps + ''
+ before + '' + caps + ""
end
end
end
@@ -149,7 +149,7 @@ def custom_caps(text)
# @param [String] text input text
# @return [String] input text with em dashes wrapped
def emdash(text)
- text.gsub(/(\w|\s| )—(?:mdash;|#8212;)?(\w|\s| )/) { |str|
+ text.gsub(/(\w|\s| )—(?:mdash;|#8212;)?(\w|\s| )/) { |_str|
$1 + '—' + $2
}.gsub(/(\w+)="(.*?)—<\/span>(.*?)"/, '\1="\2—\3"')
end
diff --git a/renovate.json b/renovate.json
deleted file mode 100644
index f45d8f1..0000000
--- a/renovate.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "extends": [
- "config:base"
- ]
-}
diff --git a/spec/jekyll/typogrify_spec.rb b/spec/jekyll/typogrify_spec.rb
index 9efbb43..3634712 100644
--- a/spec/jekyll/typogrify_spec.rb
+++ b/spec/jekyll/typogrify_spec.rb
@@ -1,12 +1,12 @@
-require 'rbconfig'
-require 'spec_helper'
+require "rbconfig"
+require "spec_helper"
describe(Jekyll) do
let(:overrides) do
{
- "source" => source_dir,
+ "source" => source_dir,
"destination" => dest_dir,
- "url" => "http://example.org",
+ "url" => "http://example.org",
}
end
@@ -14,16 +14,16 @@
Jekyll.configuration(overrides)
end
- let(:site) { Jekyll::Site.new(config) }
- let(:contents) { File.read(dest_dir("index.html")) }
+ let(:site) { Jekyll::Site.new(config) }
+ let(:contents) { File.read(dest_dir("index.html")) }
before(:each) do
site.process
end
- is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
+ is_windows = (RbConfig::CONFIG["host_os"] =~ /mswin|mingw|cygwin/)
- it 'has a version number' do
+ it "has a version number" do
expect(Jekyll::Typogrify::VERSION).not_to be nil
end
@@ -66,14 +66,14 @@
end
it "run improve on a couple of emojis" do
- if not is_windows
+ unless is_windows
expect(contents).to_not match /🤖s Fighting 🐵s/
expect(contents).to match /🤖s Fighting 🐵s/
end
end
it "will apply the titlecase filter" do
- if not is_windows
+ unless is_windows
expect(contents).to_not match /welcome to beautiful 東京都 (tokyo), japan/
# expect(contents).to match /Welcome to Beautiful 東京都 (Tokyo), Japan/
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 5cead75..dc30ddf 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,19 +1,19 @@
-require 'simplecov'
+require "simplecov"
SimpleCov.start
-$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
-require 'jekyll/typogrify'
-require 'jekyll'
+$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
+require "jekyll/typogrify"
+require "jekyll"
Jekyll.logger.log_level = :error
RSpec.configure do |config|
config.run_all_when_everything_filtered = true
config.filter_run :focus
- config.order = 'random'
+ config.order = "random"
SOURCE_DIR = File.expand_path("../fixtures", __FILE__)
- DEST_DIR = File.expand_path("../dest", __FILE__)
+ DEST_DIR = File.expand_path("../dest", __FILE__)
def source_dir(*files)
File.join(SOURCE_DIR, *files)