Skip to content

Commit

Permalink
Merge pull request #91 from Shopify/rm-drop-support-old-rails
Browse files Browse the repository at this point in the history
Drop support to old versions of Ruby and Rails
  • Loading branch information
rafaelfranca authored Aug 16, 2022
2 parents 9af3451 + 12f80fe commit f4891e7
Show file tree
Hide file tree
Showing 11 changed files with 145 additions and 145 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,22 @@

name: Ruby

on: [push, pull_requests]
on: [push, pull_request]

jobs:
test:

name: Ruby ${{ matrix.ruby }}
name: Ruby ${{ matrix.ruby }} - ${{ matrix.gemfile }}
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
ruby: [3.1, '3.0', 2.7, 2.6]
ruby: [3.1, '3.0', 2.7]
gemfile:
- Gemfile
- gemfiles/Gemfile-rails-6-0
- gemfiles/Gemfile-rails-6-1
env:
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
steps:
- uses: actions/checkout@v2
- name: Set up Ruby
Expand Down
40 changes: 19 additions & 21 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ PATH
remote: .
specs:
better_html (1.0.16)
actionview (>= 4.0)
activesupport (>= 4.0)
actionview (>= 6.0)
activesupport (>= 6.0)
ast (~> 2.0)
erubi (~> 1.4)
parser (>= 2.4)
Expand All @@ -12,35 +12,34 @@ PATH
GEM
remote: https://rubygems.org/
specs:
actionview (5.1.2)
activesupport (= 5.1.2)
actionview (7.0.3.1)
activesupport (= 7.0.3.1)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activesupport (5.1.2)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activesupport (7.0.3.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
minitest (~> 5.1)
tzinfo (~> 1.1)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
ast (2.4.0)
builder (3.2.3)
builder (3.2.4)
byebug (9.1.0)
coderay (1.1.2)
concurrent-ruby (1.0.5)
concurrent-ruby (1.1.10)
crass (1.0.6)
erubi (1.6.1)
i18n (0.8.6)
erubi (1.11.0)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
loofah (2.18.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
metaclass (0.0.4)
method_source (0.9.0)
mini_portile2 (2.8.0)
minitest (5.10.3)
mocha (1.2.1)
metaclass (~> 0.0.1)
nokogiri (1.13.6)
minitest (5.16.2)
mocha (1.14.0)
nokogiri (1.13.8)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
parser (2.6.3.0)
Expand All @@ -61,9 +60,8 @@ GEM
rake-compiler (1.2.0)
rake
smart_properties (1.15.0)
thread_safe (0.3.6)
tzinfo (1.2.10)
thread_safe (~> 0.1)
tzinfo (2.0.5)
concurrent-ruby (~> 1.0)

PLATFORMS
ruby
Expand Down
9 changes: 5 additions & 4 deletions better_html.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ Gem::Specification.new do |s|
s.name = "better_html"
s.version = BetterHtml::VERSION
s.authors = ["Francois Chagnon"]
s.email = ["francois.chagnon@shopify.com"]
s.email = ["ruby@shopify.com"]
s.homepage = "https://github.com/Shopify/better-html"
s.summary = "Better HTML for Rails."
s.description = "Better HTML for Rails. Provides sane html helpers that make it easier to do the right thing."
s.license = "MIT"

s.required_ruby_version = ">= 2.7.0"

s.metadata = {
"bug_tracker_uri" => "https://github.com/Shopify/better-html/issues",
"changelog_uri" => "https://github.com/Shopify/better-html/releases",
Expand All @@ -23,13 +25,12 @@ Gem::Specification.new do |s|

s.extensions = ['ext/better_html_ext/extconf.rb']
s.files = Dir["{app,config,db,lib,ext}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
s.test_files = Dir["test/**/*"]
s.require_paths = ["lib"]

s.add_dependency 'ast', '~> 2.0'
s.add_dependency 'erubi', '~> 1.4'
s.add_dependency 'activesupport', '>= 4.0'
s.add_dependency 'actionview', '>= 4.0'
s.add_dependency 'activesupport', '>= 6.0'
s.add_dependency 'actionview', '>= 6.0'
s.add_dependency 'parser', '>= 2.4'
s.add_dependency 'smart_properties'

Expand Down
13 changes: 13 additions & 0 deletions gemfiles/Gemfile-rails-6-0
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
source 'https://rubygems.org'

gemspec path: ".."

gem 'actionview', '~> 6.0.0'
gem 'rake'
gem 'rake-compiler'
gem 'minitest'
gem 'mocha'

group :deployment, :test do
gem 'pry-byebug'
end
13 changes: 13 additions & 0 deletions gemfiles/Gemfile-rails-6-1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
source 'https://rubygems.org'

gemspec path: ".."

gem 'actionview', '~> 6.1.0'
gem 'rake'
gem 'rake-compiler'
gem 'minitest'
gem 'mocha'

group :deployment, :test do
gem 'pry-byebug'
end
23 changes: 5 additions & 18 deletions lib/better_html/better_erb.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
require 'action_view'

require 'better_html_ext'
if ActionView.version < Gem::Version.new("5.1")
require 'better_html/better_erb/erubis_implementation'
else
require 'better_html/better_erb/erubi_implementation'
end
require 'better_html/better_erb/validated_output_buffer'

module BetterHtml
Expand All @@ -23,15 +19,10 @@ def initialize(message, position, line, column)

class BetterHtml::BetterErb
cattr_accessor :content_types
if ActionView.version < Gem::Version.new("5.1")
self.content_types = {
'html.erb' => BetterHtml::BetterErb::ErubisImplementation
}
else
self.content_types = {
'html.erb' => BetterHtml::BetterErb::ErubiImplementation
}
end

self.content_types = {
'html.erb' => BetterHtml::BetterErb::ErubiImplementation
}

def self.prepend!
ActionView::Template::Handlers::ERB.prepend(ConditionalImplementation)
Expand Down Expand Up @@ -71,11 +62,7 @@ def generate(template, source)
klass = BetterHtml::BetterErb.content_types[exts] unless excluded_template
klass ||= self.class.erb_implementation

escape = if ActionView::VERSION::MAJOR <= 5
self.class.escape_whitelist.include?(template.type)
else
self.class.escape_ignore_list.include?(template.type)
end
escape = self.class.escape_ignore_list.include?(template.type)
generator = klass.new(
erb,
:escape => escape,
Expand Down
44 changes: 0 additions & 44 deletions lib/better_html/better_erb/erubis_implementation.rb

This file was deleted.

2 changes: 1 addition & 1 deletion lib/better_html/better_erb/runtime_checks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def initialize(erb, config: BetterHtml.config, **options)
end

def validate!
check_parser_errors
check_parser_errors unless @config.disable_parser_validation

unless @parser.context == :none
raise BetterHtml::HtmlError, 'Detected an open tag at the end of this document.'
Expand Down
1 change: 1 addition & 0 deletions lib/better_html/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Config
property :javascript_attribute_names, default: -> { [/\Aon/i] }
property :template_exclusion_filter
property :lodash_safe_javascript_expression, default: -> { [/\AJSON\.stringify\(/] }
property :disable_parser_validation, default: false

def javascript_attribute_name?(name)
javascript_attribute_names.any?{ |other| other === name.to_s }
Expand Down
Loading

0 comments on commit f4891e7

Please sign in to comment.