Skip to content

Commit

Permalink
Drop Webpacker support
Browse files Browse the repository at this point in the history
  • Loading branch information
tagliala committed Sep 3, 2024
1 parent 5ad54e0 commit 348addc
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 25 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased][unreleased]

Nothing.
- Drop Support for Webpacker and Legacy Rails. [#163](https://github.com/jamesmartin/inline_svg/pull/163).

## [1.10.0] - 2024-09-03
### Added
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Styling a SVG document with CSS for use on the web is most reliably achieved by
[adding classes to the document and
embedding](http://css-tricks.com/using-svg/) it inline in the HTML.

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
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
then embeds it into a view.

Inline SVG supports Rails 6.1/7.x with Sprockets or Shakapacker
Expand Down Expand Up @@ -37,7 +37,7 @@ Or install it yourself as:
# Sprockets
inline_svg_tag(file_name, options={})

# Webpacker
# Shakapacker
inline_svg_pack_tag(file_name, options={})
```

Expand Down
7 changes: 1 addition & 6 deletions lib/inline_svg/webpack_asset_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@ def pathname
private

def asset_helper
@asset_helper ||=
if defined?(::Shakapacker)
::Shakapacker
else
::Webpacker
end
@asset_helper ||= ::Shakapacker
end

def dev_server_asset(file_path)
Expand Down
12 changes: 6 additions & 6 deletions spec/finds_asset_paths_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@

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

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

InlineSvg.configure do |config|
config.asset_finder = webpacker
config.asset_finder = shakapacker
end

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

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

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

InlineSvg.configure do |config|
config.asset_finder = webpacker
config.asset_finder = shakapacker
end

expect(InlineSvg::FindsAssetPaths.by_filename('some-file')).to eq Pathname('https://my-fancy-domain.test/full/path/to/some-file')
Expand Down
10 changes: 0 additions & 10 deletions spec/webpack_asset_finder_spec.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
require_relative '../lib/inline_svg'

describe InlineSvg::WebpackAssetFinder do
context "when the file is not found" do
it "returns nil" do
stub_const('Rails', double('Rails').as_null_object)
stub_const('Webpacker', double('Webpacker').as_null_object)
expect(::Webpacker.manifest).to receive(:lookup).with('some-file').and_return(nil)

expect(described_class.find_asset('some-file').pathname).to be_nil
end
end

context "when Shakapacker is defined" do
it "uses the new spelling" do
stub_const('Rails', double('Rails').as_null_object)
Expand Down

0 comments on commit 348addc

Please sign in to comment.