Skip to content

Commit cb01bb3

Browse files
authored
Merge pull request #163 from tagliala/feature/161-drop-legacy-ruby-rails
Drop legacy Ruby, Rails, and Webpacker support
2 parents 275d2af + c1445c7 commit cb01bb3

11 files changed

+36
-54
lines changed

.github/workflows/integration_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515
strategy:
1616
matrix:
17-
test-branch: [rails6, rails7, rails7-shakapacker]
17+
test-branch: [rails7, rails7-shakapacker]
1818
timeout-minutes: 20
1919
steps:
2020
- name: Checkout

.github/workflows/ruby.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,23 @@ jobs:
1313
build:
1414

1515
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
ruby-version: ['3.1', '3.2', '3.3']
19+
channel: ['stable']
20+
21+
include:
22+
- ruby-version: 'head'
23+
channel: 'experimental'
24+
25+
continue-on-error: ${{ matrix.channel != 'stable' }}
1626

1727
steps:
1828
- uses: actions/checkout@v4
19-
- name: Set up Ruby 2.7
29+
- name: Set up Ruby
2030
uses: ruby/setup-ruby@v1
2131
with:
22-
ruby-version: 2.7.7
32+
ruby-version: '3.3'
2333
bundler-cache: true
2434
- name: Test with Rake
2535
run: |

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
44

55
## [Unreleased][unreleased]
66

7-
Nothing.
7+
- Drop Support for Webpacker, Legacy Ruby (< 3.0), and Legacy Rails (< 7.0). [#163](https://github.com/jamesmartin/inline_svg/pull/163). Thanks, [@tagliala](https://github.com/tagliala)
88

99
## [1.10.0] - 2024-09-03
1010
### Added

Gemfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,9 @@ source 'https://rubygems.org'
22

33
# Specify your gem's dependencies in inline_svg.gemspec
44
gemspec
5+
6+
gem "bundler"
7+
gem "pry"
8+
gem "rake"
9+
gem "rspec"
10+
gem "rubocop"

README.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,10 @@ Styling a SVG document with CSS for use on the web is most reliably achieved by
77
[adding classes to the document and
88
embedding](http://css-tricks.com/using-svg/) it inline in the HTML.
99

10-
This gem adds Rails helper methods (`inline_svg_tag` and `inline_svg_pack_tag`) that read an SVG document (via Sprockets or Webpacker, so works with the Rails Asset Pipeline), applies a CSS class attribute to the root of the document and
10+
This gem adds Rails helper methods (`inline_svg_tag` and `inline_svg_pack_tag`) that read an SVG document (via Sprockets or Shakapacker, so works with the Rails Asset Pipeline), applies a CSS class attribute to the root of the document and
1111
then embeds it into a view.
1212

13-
Inline SVG supports:
14-
15-
- [Rails 5](http://weblog.rubyonrails.org/2016/6/30/Rails-5-0-final/) (from [v0.10.0](https://github.com/jamesmartin/inline_svg/releases/tag/v0.10.0))
16-
- [Rails 6](https://weblog.rubyonrails.org/2019/4/24/Rails-6-0-rc1-released/) with Sprockets or Webpacker (from [v1.5.2](https://github.com/jamesmartin/inline_svg/releases/tag/v1.5.2)).
17-
- [Rails 7](https://weblog.rubyonrails.org/2021/12/6/Rails-7-0-rc-1-released/)
18-
19-
Inline SVG no longer officially supports Rails 3 or Rails 4 (although they may still work). In order to reduce the maintenance cost of this project we now follow the [Rails Maintenance Policy](https://guides.rubyonrails.org/maintenance_policy.html).
13+
Inline SVG supports Rails 7.x with Propshaft, Sprockets, or Shakapacker
2014

2115
## Changelog
2216

@@ -43,7 +37,7 @@ Or install it yourself as:
4337
# Sprockets
4438
inline_svg_tag(file_name, options={})
4539

46-
# Webpacker
40+
# Shakapacker
4741
inline_svg_pack_tag(file_name, options={})
4842
```
4943

inline_svg.gemspec

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,9 @@ Gem::Specification.new do |spec|
1818
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
1919
spec.require_paths = ["lib"]
2020

21-
spec.add_development_dependency "bundler", "~> 2.0"
22-
spec.add_development_dependency "rake"
23-
spec.add_development_dependency "rspec", "~> 3.2"
24-
spec.add_development_dependency "rspec_junit_formatter", "0.2.2"
25-
spec.add_development_dependency "pry"
26-
spec.add_development_dependency "rubocop"
21+
spec.metadata['rubygems_mfa_required'] = 'true'
22+
spec.required_ruby_version = '>= 3.1'
2723

28-
spec.add_runtime_dependency "activesupport", ">= 3.0"
29-
spec.add_runtime_dependency "nokogiri", ">= 1.6"
24+
spec.add_dependency "activesupport", ">= 7.0"
25+
spec.add_dependency "nokogiri", ">= 1.16"
3026
end

lib/inline_svg/action_view/helpers.rb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,6 @@ def inline_svg(filename, transform_params={})
2222

2323
private
2424

25-
def backwards_compatible_html_escape(filename)
26-
# html_escape_once was introduced in newer versions of Rails.
27-
if ERB::Util.respond_to?(:html_escape_once)
28-
ERB::Util.html_escape_once(filename)
29-
else
30-
ERB::Util.html_escape(filename)
31-
end
32-
end
33-
3425
def render_inline_svg(filename, transform_params={})
3526
begin
3627
svg_file = read_svg(filename)
@@ -60,7 +51,7 @@ def read_svg(filename)
6051

6152
def placeholder(filename)
6253
css_class = InlineSvg.configuration.svg_not_found_css_class
63-
not_found_message = "'#{backwards_compatible_html_escape(filename)}' #{extension_hint(filename)}"
54+
not_found_message = "'#{ERB::Util.html_escape_once(filename)}' #{extension_hint(filename)}"
6455

6556
if css_class.nil?
6657
return "<svg><!-- SVG file not found: #{not_found_message}--></svg>".html_safe

lib/inline_svg/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module InlineSvg
2-
VERSION = "1.10.0"
2+
VERSION = "2.0.0"
33
end

lib/inline_svg/webpack_asset_finder.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,7 @@ def pathname
2323
private
2424

2525
def asset_helper
26-
@asset_helper ||=
27-
if defined?(::Shakapacker)
28-
::Shakapacker
29-
else
30-
::Webpacker
31-
end
26+
@asset_helper ||= ::Shakapacker
3227
end
3328

3429
def dev_server_asset(file_path)

spec/finds_asset_paths_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@
6363

6464
context "when webpack finder returns an object with a relative asset path" do
6565
it "returns the fully qualified file path" do
66-
webpacker = double('WebpackerDouble')
66+
shakapacker = double('ShakapackerDouble')
6767

68-
expect(webpacker).to receive(:find_asset).with('some-file').
68+
expect(shakapacker).to receive(:find_asset).with('some-file').
6969
and_return(double(filename: Pathname('/full/path/to/some-file')))
7070

7171
InlineSvg.configure do |config|
72-
config.asset_finder = webpacker
72+
config.asset_finder = shakapacker
7373
end
7474

7575
expect(InlineSvg::FindsAssetPaths.by_filename('some-file')).to eq Pathname('/full/path/to/some-file')
@@ -78,13 +78,13 @@
7878

7979
context "when webpack finder returns an object with an absolute http asset path" do
8080
it "returns the fully qualified file path" do
81-
webpacker = double('WebpackerDouble')
81+
shakapacker = double('ShakapackerDouble')
8282

83-
expect(webpacker).to receive(:find_asset).with('some-file').
83+
expect(shakapacker).to receive(:find_asset).with('some-file').
8484
and_return(double(filename: Pathname('https://my-fancy-domain.test/full/path/to/some-file')))
8585

8686
InlineSvg.configure do |config|
87-
config.asset_finder = webpacker
87+
config.asset_finder = shakapacker
8888
end
8989

9090
expect(InlineSvg::FindsAssetPaths.by_filename('some-file')).to eq Pathname('https://my-fancy-domain.test/full/path/to/some-file')

spec/webpack_asset_finder_spec.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,6 @@
33
describe InlineSvg::WebpackAssetFinder do
44
context "when the file is not found" do
55
it "returns nil" do
6-
stub_const('Rails', double('Rails').as_null_object)
7-
stub_const('Webpacker', double('Webpacker').as_null_object)
8-
expect(::Webpacker.manifest).to receive(:lookup).with('some-file').and_return(nil)
9-
10-
expect(described_class.find_asset('some-file').pathname).to be_nil
11-
end
12-
end
13-
14-
context "when Shakapacker is defined" do
15-
it "uses the new spelling" do
166
stub_const('Rails', double('Rails').as_null_object)
177
stub_const('Shakapacker', double('Shakapacker').as_null_object)
188
expect(::Shakapacker.manifest).to receive(:lookup).with('some-file').and_return(nil)

0 commit comments

Comments
 (0)