Skip to content

Commit

Permalink
Remove support for Rails 5 (#70)
Browse files Browse the repository at this point in the history
* Remove support for Rails 5

Tech debt is too high. It's hard to know what's going on. Rails 5 is no longer listed under "Severe security issues" so it can safely be removed.

* Add help command to README

* Fix GitHub actions & update maildown in appraisals
  • Loading branch information
schneems authored Feb 9, 2023
1 parent 9b92acb commit 965a6d3
Show file tree
Hide file tree
Showing 15 changed files with 53 additions and 244 deletions.
6 changes: 0 additions & 6 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
appraise "rails_5_2" do
gem "rails", "5.2.3"
gem "sqlite3", "~> 1.4"
gem 'net-smtp', require: false
end

appraise "rails_6_0" do
gem "rails", "6.0.5"
gem "sqlite3", "~> 1.4"
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## HEAD (Unreleased)

## 4.0.0

- Remove support for Rails < 6 to minimize tech debt (https://github.com/zombocom/maildown/pull/70)

## 3.3.1

- Add support for Rails 7 (https://github.com/zombocom/maildown/pull/61)
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ We use the [appraisal gem](https://github.com/thoughtbot/appraisal) to generate
$ bundle exec appraisal install
```

Get more info on other commands with:

```
$ bundle exec appraisal --help
```

Run a specific suite like this:

```
Expand Down
10 changes: 0 additions & 10 deletions gemfiles/rails_5_2.gemfile

This file was deleted.

159 changes: 0 additions & 159 deletions gemfiles/rails_5_2.gemfile.lock

This file was deleted.

5 changes: 3 additions & 2 deletions gemfiles/rails_6_0.gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
maildown (3.3.1)
maildown (4.0.0)
actionmailer (>= 4.0.0)
kramdown-parser-gfm

Expand Down Expand Up @@ -155,6 +155,7 @@ GEM

PLATFORMS
x86_64-darwin-20
x86_64-darwin-21
x86_64-linux

DEPENDENCIES
Expand All @@ -168,4 +169,4 @@ DEPENDENCIES
sqlite3 (~> 1.4)

BUNDLED WITH
2.3.15
2.3.26
5 changes: 3 additions & 2 deletions gemfiles/rails_6_1.gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
maildown (3.3.1)
maildown (4.0.0)
actionmailer (>= 4.0.0)
kramdown-parser-gfm

Expand Down Expand Up @@ -158,6 +158,7 @@ GEM

PLATFORMS
x86_64-darwin-20
x86_64-darwin-21
x86_64-linux

DEPENDENCIES
Expand All @@ -171,4 +172,4 @@ DEPENDENCIES
sqlite3 (~> 1.4)

BUNDLED WITH
2.3.15
2.3.26
5 changes: 3 additions & 2 deletions gemfiles/rails_7_0.gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
maildown (3.3.1)
maildown (4.0.0)
actionmailer (>= 4.0.0)
kramdown-parser-gfm

Expand Down Expand Up @@ -166,6 +166,7 @@ GEM

PLATFORMS
x86_64-darwin-20
x86_64-darwin-21
x86_64-linux

DEPENDENCIES
Expand All @@ -178,4 +179,4 @@ DEPENDENCIES
sqlite3 (~> 1.4)

BUNDLED WITH
2.3.15
2.3.26
4 changes: 2 additions & 2 deletions gemfiles/rails_head.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ GIT
PATH
remote: ..
specs:
maildown (3.3.1)
maildown (4.0.0)
actionmailer (>= 4.0.0)
kramdown-parser-gfm

Expand Down Expand Up @@ -185,4 +185,4 @@ DEPENDENCIES
sqlite3 (~> 1.4)

BUNDLED WITH
2.3.15
2.3.26
4 changes: 0 additions & 4 deletions lib/maildown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ def self.allow_indentation
def self.allow_indentation=(allow_indentations)
@allow_indentations = allow_indentations
end

def self.rails_6?
@rails_6 ||= Rails.version > "6"
end
end

require 'maildown/markdown_engine'
Expand Down
25 changes: 9 additions & 16 deletions lib/maildown/ext/action_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,15 @@ def each_template(paths, name, &block)
return [html_template, text_template]
end

if Maildown.rails_6?
text_template = html_template
.class
.new(
html_template.source,
html_template.identifier,
html_template.handler,
format: :text,
locals: html_template.locals
)
else
text_template = html_template.dup
formats = html_template.formats.dup.tap { |f| f.delete(:html) }

text_template.formats = formats
end
text_template = html_template
.class
.new(
html_template.source,
html_template.identifier,
html_template.handler,
format: :text,
locals: html_template.locals
)

html_template.instance_variable_set(:"@maildown_text_template", text_template)

Expand Down
45 changes: 19 additions & 26 deletions lib/maildown/ext/action_view.rb
Original file line number Diff line number Diff line change
@@ -1,35 +1,28 @@
# frozen_string_literal: true

if !defined?(ActionView::OptimizedFileSystemResolver)
module ActionView
# https://github.com/codetriage/maildown/issues/59
#
# extract_handler_and_format_and_variant was removed in https://github.com/rails/rails/commit/2be8d3ebf85e26e936a7717b968737ee333d95bd
# OptimizedFileSystemResolver was removed in https://github.com/rails/rails/commit/faac734387124c6d780dbfcfdab721b2f26ce865
class OptimizedFileSystemResolver < FileSystemResolver
def extract_handler_and_format_and_variant(template)
details = @path_parser.parse(template)
[details.handler, details.format, details.variant]
end
end
end
end

# This monkeypatch allows the use of `.md.erb` file extensions
# in addition to `.md+erb` and `.md`
module ActionView
class OptimizedFileSystemResolver
alias :original_extract_handler_and_format_and_variant :extract_handler_and_format_and_variant
#
# The calls to `ActionView::Template.register_template_handler`
# prior to Rails 7 will only consider the last extension in a file
# so if a file is labeled `foo.md.erb` the it will be treated as a
# `.erb` file. This hack internally converts `.md.erb` files to
# `.md+erb` which older versions of Rails will recognize.
if defined?(ActionView::OptimizedFileSystemResolver)
module ActionView
class OptimizedFileSystemResolver
alias :original_extract_handler_and_format_and_variant :extract_handler_and_format_and_variant

# Different versions of rails have different
# method signatures here, path is always first
def extract_handler_and_format_and_variant(*args)
if args.first.end_with?('md.erb')
path = args.shift
path = path.gsub(/\.md\.erb\z/, '.md+erb')
args.unshift(path)
# Different versions of rails have different
# method signatures here, path is always first
def extract_handler_and_format_and_variant(*args)
if args.first.end_with?('md.erb')
path = args.shift
path = path.gsub(/\.md\.erb\z/, '.md+erb')
args.unshift(path)
end
return original_extract_handler_and_format_and_variant(*args)
end
return original_extract_handler_and_format_and_variant(*args)
end
end
end
Loading

0 comments on commit 965a6d3

Please sign in to comment.