Skip to content

Commit

Permalink
Merge pull request #346 from gjtorikian/migrate-to-gh-actions
Browse files Browse the repository at this point in the history
Switch to GitHub Actions
  • Loading branch information
gjtorikian authored Jan 8, 2021
2 parents 0e3d84e + c904e2b commit 1b1482d
Show file tree
Hide file tree
Showing 15 changed files with 106 additions and 195 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Ruby CI

on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
ruby-version:
- 3.0.0
- 2.7.2
- 2.6.6
- 2.5.8
experimental: [false]
include:
- ruby-version: head
experimental: true

continue-on-error: ${{ matrix.experimental }}

steps:
- uses: actions/checkout@v2
- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true
- name: Install dependencies
run: |
bundle config set --local path '../../vendor/bundle'
bundle install
- name: Run tests
run: bundle exec rake
22 changes: 22 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Linting

on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0
bundler-cache: true
- run: bundle install
- name: Rubocop
run: bundle exec rake rubocop
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
inherit_gem:
rubocop-standard:
- config/default.yml
- config/minitest.yml
43 changes: 0 additions & 43 deletions .travis.yml

This file was deleted.

19 changes: 0 additions & 19 deletions Appraisals

This file was deleted.

17 changes: 12 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@ source 'https://rubygems.org'
# Specify your gem's dependencies in html-pipeline.gemspec
gemspec

group :development, :test do
gem 'awesome_print'

gem 'rubocop'
gem 'rubocop-performance'
gem 'rubocop-standard'
end

group :development do
gem 'appraisal'
gem 'bundler'
gem 'rake'
end
Expand All @@ -16,11 +23,11 @@ group :test do
gem 'email_reply_parser', '~> 0.5', require: false
gem 'gemoji', '~> 2.0', require: false
gem 'minitest'
gem 'RedCloth', '~> 4.2.9', require: false
gem 'rinku', '~> 1.7', require: false
gem 'sanitize', '~> 4.6', require: false
gem 'RedCloth', '~> 4.3', require: false
gem 'rinku', '~> 1.7', require: false
gem 'sanitize', '~> 5.2', require: false

gem 'escape_utils', '~> 1.0', require: false
gem 'rouge', '~> 3.1', require: false
gem 'minitest-focus', '~> 1.1'
gem 'rouge', '~> 3.1', require: false
end
4 changes: 4 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ Rake::TestTask.new do |t|
end

task default: :test

require 'rubocop/rake_task'

RuboCop::RakeTask.new(:rubocop)
27 changes: 0 additions & 27 deletions gemfiles/rails_3.gemfile

This file was deleted.

27 changes: 0 additions & 27 deletions gemfiles/rails_4.gemfile

This file was deleted.

26 changes: 0 additions & 26 deletions gemfiles/rails_5.gemfile

This file was deleted.

26 changes: 0 additions & 26 deletions gemfiles/rails_6.gemfile

This file was deleted.

25 changes: 13 additions & 12 deletions html-pipeline.gemspec
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
# frozen_string_literal: true

require File.expand_path('../lib/html/pipeline/version', __FILE__)
require File.expand_path('lib/html/pipeline/version', __dir__)

Gem::Specification.new do |gem|
gem.name = 'html-pipeline'
gem.version = HTML::Pipeline::VERSION
gem.license = 'MIT'
gem.authors = ['Ryan Tomayko', 'Jerry Cheung', 'Garen J. Torikian']
gem.email = ['[email protected]', '[email protected]', '[email protected]']
gem.description = 'GitHub HTML processing filters and utilities'
gem.description = 'HTML processing filters and utilities'
gem.summary = 'Helpers for processing content through a chain of filters'
gem.homepage = 'https://github.com/jch/html-pipeline'

gem.files = `git ls-files -z`.split("\x0").reject { |f| f =~ %r{^(test|gemfiles|script)/} }
gem.require_paths = ['lib']

gem.add_dependency 'activesupport', '>= 2'
gem.add_dependency 'nokogiri', '>= 1.4'
gem.required_ruby_version = ['>= 2.5.8', '< 4.0']

gem.post_install_message = <<msg
-------------------------------------------------
Thank you for installing html-pipeline!
You must bundle Filter gem dependencies.
See html-pipeline README.md for more details.
https://github.com/jch/html-pipeline#dependencies
-------------------------------------------------
msg
gem.add_dependency 'nokogiri', '~> 1.11'

gem.post_install_message = <<~MSG
-------------------------------------------------
Thank you for installing html-pipeline!
You must bundle Filter gem dependencies.
See html-pipeline README.md for more details.
https://github.com/jch/html-pipeline#dependencies
-------------------------------------------------
MSG
end
1 change: 0 additions & 1 deletion lib/html/pipeline.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require 'nokogiri'
require 'active_support/xml_mini/nokogiri' # convert Documents to hashes

module HTML
# GitHub HTML processing filters and utilities. This module includes a small
Expand Down
13 changes: 8 additions & 5 deletions lib/html/pipeline/emoji_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,15 @@ def asset_path(name)

# Build an emoji image tag
def emoji_image_tag(name)
require 'active_support/core_ext/hash/indifferent_access'
html_attrs =
default_img_attrs(name)
.merge!((context[:img_attrs] || {}).with_indifferent_access)
.map { |attr, value| !value.nil? && %(#{attr}="#{value.respond_to?(:call) && value.call(name) || value}") }
.reject(&:blank?).join(' '.freeze)
default_img_attrs(name).transform_keys(&:to_sym)
.merge!(context[:img_attrs] || {}).transform_keys(&:to_sym)
.each_with_object([]) do |(attr, value), arr|
next if value.nil?

value = value.respond_to?(:call) && value.call(name) || value
arr << %(#{attr}="#{value}")
end.compact.join(' '.freeze)

"<img #{html_attrs}>"
end
Expand Down
6 changes: 2 additions & 4 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
require 'minitest/pride'
require 'minitest/focus'

require 'active_support/core_ext/string'

module TestHelpers
# Asserts that two html fragments are equivalent. Attribute order
# will be ignored.
def assert_equal_html(expected, actual)
assert_equal Nokogiri::HTML::DocumentFragment.parse(expected).to_hash,
Nokogiri::HTML::DocumentFragment.parse(actual).to_hash
assert_equal Nokogiri::HTML::DocumentFragment.parse(expected).to_h,
Nokogiri::HTML::DocumentFragment.parse(actual).to_h
end
end

Expand Down

0 comments on commit 1b1482d

Please sign in to comment.