inline_svg 1.7.2 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd31243686f41f3d2acfc2f7235685baaab23ca967774d6f642e7f5aab7f2fbc
4
- data.tar.gz: 1c6bdf6fc08c4a145c5ecefea9aaa2fe60d2f1d0142c78aed17a73d4acaaa9ce
3
+ metadata.gz: 23a2c45f1e25e4266196f0e2fc23a4384cb8513be840d2b676ae848b5be1d121
4
+ data.tar.gz: 8fdb1090f9037ed6c732469ffda28023e200d758533223d4bd9c85b5a20cfb72
5
5
  SHA512:
6
- metadata.gz: baee695644bd79e2561183326818a30f2dd1be7e4262973faacc2fa17ba7970888f9b4beb5cb0ebf2ce9a8c477d99d941f29431bdfaea32d66bd654c244e9545
7
- data.tar.gz: 16347bfe873b1f0ab075a43b5f98590a5d2f80cb985849dd7d6c868e4d753a8e5f86209bab55c06e47ea67f89b622132ce3fc88343cbb4a388ae94b798009ca1
6
+ metadata.gz: c3d98f05ba0b9ea222d1b852f87f30584ba4b775d7b6848a2366341e5e85bb6c9912bc1f8441117d129db4d63506d54dcd8ef4d633a5140359e25f5a829a8a1c
7
+ data.tar.gz: 45eb7d5c8a30f0814e9c775924690825ad3b3ee9c3ada3c9694bf3af46499ababaa1ba81f696514e08dc09aa5ae6520094820fc528ee34fbb307b856dc16b3f4
@@ -8,7 +8,7 @@ jobs:
8
8
  runs-on: ubuntu-latest
9
9
  strategy:
10
10
  matrix:
11
- test-branch: [rails3, rails4, main, rails6, rails6-webpacker]
11
+ test-branch: [rails5, rails6, rails7]
12
12
  steps:
13
13
  - name: Checkout
14
14
  uses: actions/checkout@v2
@@ -18,10 +18,10 @@ jobs:
18
18
  repository: jamesmartin/inline_svg_test_app
19
19
  ref: ${{ matrix.test-branch }}
20
20
  path: test_app
21
- - name: Set up Ruby 2.6
21
+ - name: Set up Ruby 2.7
22
22
  uses: actions/setup-ruby@v1
23
23
  with:
24
- ruby-version: 2.6.x
24
+ ruby-version: 2.7.x
25
25
  - name: Build local gem
26
26
  run: |
27
27
  gem install bundler
@@ -41,17 +41,6 @@ jobs:
41
41
  run: |
42
42
  cd $GITHUB_WORKSPACE/test_app
43
43
  bundle install --jobs 4 --retry 3
44
- - name: Set up Node.js 12.x
45
- uses: actions/setup-node@v1
46
- with:
47
- node-version: 12.x
48
- if: matrix.test-branch == 'rails6-webpacker'
49
- - name: Generate Webpacker config
50
- run: |
51
- cd $GITHUB_WORKSPACE/test_app
52
- yarn install --check-files
53
- bundle exec rake webpacker:compile
54
- if: matrix.test-branch == 'rails6-webpacker'
55
44
  - name: Test
56
45
  run: |
57
46
  cd $GITHUB_WORKSPACE/test_app
@@ -0,0 +1,58 @@
1
+ name: Rails 6 Webpacker Integration Tests (unreliable)
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ build:
7
+
8
+ runs-on: ubuntu-latest
9
+ strategy:
10
+ matrix:
11
+ test-branch: [rails6-webpacker]
12
+ steps:
13
+ - name: Checkout
14
+ uses: actions/checkout@v2
15
+ - name: Checkout test app
16
+ uses: actions/checkout@v2
17
+ with:
18
+ repository: jamesmartin/inline_svg_test_app
19
+ ref: ${{ matrix.test-branch }}
20
+ path: test_app
21
+ - name: Set up Ruby 2.7
22
+ uses: actions/setup-ruby@v1
23
+ with:
24
+ ruby-version: 2.7.x
25
+ - name: Build local gem
26
+ run: |
27
+ gem install bundler
28
+ bundle install --jobs 4 --retry 3
29
+ bundle exec rake build
30
+ - name: Use the local gem in the test App
31
+ id: uselocalgem
32
+ uses: jacobtomlinson/gha-find-replace@0.1.1
33
+ with:
34
+ find: "gem 'inline_svg'"
35
+ replace: "gem 'inline_svg', path: '${{github.workspace}}'"
36
+ - name: Check local gem in use
37
+ run: |
38
+ test "${{ steps.uselocalgem.outputs.modifiedFiles }}" != "0"
39
+ grep "inline_svg" $GITHUB_WORKSPACE/test_app/Gemfile
40
+ - name: Bundle
41
+ run: |
42
+ cd $GITHUB_WORKSPACE/test_app
43
+ bundle install --jobs 4 --retry 3
44
+ - name: Set up Node.js 16.x
45
+ uses: actions/setup-node@v2
46
+ with:
47
+ node-version: 16
48
+ if: matrix.test-branch == 'rails6-webpacker'
49
+ - name: Generate Webpacker config
50
+ run: |
51
+ cd $GITHUB_WORKSPACE/test_app
52
+ yarn install --check-files
53
+ bundle exec rake webpacker:compile
54
+ if: matrix.test-branch == 'rails6-webpacker'
55
+ - name: Test
56
+ run: |
57
+ cd $GITHUB_WORKSPACE/test_app
58
+ bundle exec rake test
data/CHANGELOG.md CHANGED
@@ -4,7 +4,13 @@ This project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
5
  ## [Unreleased][unreleased]
6
6
 
7
- - Nothing
7
+ Nothing.
8
+
9
+ ## [1.8.0] - 2022-01-09
10
+ ### Added
11
+ - Remove deprecation warning for `inline_svg`, as we intend to keep it in 2.0. [#131](https://github.com/jamesmartin/inline_svg/pull/131). Thanks [@DanielJackson-Oslo](https://github.com/DanielJackson-Oslo)
12
+ - Add support for Webpacker 6 beta. [#129](https://github.com/jamesmartin/inline_svg/pull/129). Thanks [@Intrepidd](https://github.com/Intrepidd) and [@tessi](https://github.com/tessi)
13
+ - Add support for Propshaft assets in Rails 7. [#134](https://github.com/jamesmartin/inline_svg/pull/134). Thanks, [@martinzamuner](https://github.com/martinzamuner)
8
14
 
9
15
  ## [1.7.2] - 2020-12-07
10
16
  ### Fixed
@@ -23,7 +29,6 @@ This project adheres to [Semantic Versioning](http://semver.org/).
23
29
  - Using Webpacker and Asset Pipeline in a single App could result in SVGs not being found because the wrong `AssetFinder` was used. [#114](https://github.com/jamesmartin/inline_svg/pull/114). Thanks, [@kylefox](https://github.com/kylefox)
24
30
  - Prevent "EOFError error" when using webpack dev server over HTTPS [#113](https://github.com/jamesmartin/inline_svg/pull/113). Thanks, [@kylefox](https://github.com/kylefox)
25
31
 
26
-
27
32
  ## [1.6.0] - 2019-11-13
28
33
  ### Added
29
34
  - Support Webpack via the new `inline_svg_pack_tag` helper and deprecate `inline_svg` helper in preparation for v2.0.
@@ -239,7 +244,8 @@ transformations](https://github.com/jamesmartin/inline_svg/blob/master/README.md
239
244
  ### Added
240
245
  - Basic Railtie and view helper to inline SVG documents to Rails views.
241
246
 
242
- [unreleased]: https://github.com/jamesmartin/inline_svg/compare/v1.7.2...HEAD
247
+ [unreleased]: https://github.com/jamesmartin/inline_svg/compare/v1.8.0...HEAD
248
+ [1.8.0]: https://github.com/jamesmartin/inline_svg/compare/v1.7.2...v1.8.0
243
249
  [1.7.2]: https://github.com/jamesmartin/inline_svg/compare/v1.7.1...v1.7.2
244
250
  [1.7.1]: https://github.com/jamesmartin/inline_svg/compare/v1.7.0...v1.7.1
245
251
  [1.7.0]: https://github.com/jamesmartin/inline_svg/compare/v1.6.0...v1.7.0
data/README.md CHANGED
@@ -12,10 +12,11 @@ then embeds it into a view.
12
12
 
13
13
  Inline SVG supports:
14
14
 
15
- - [Rails 3](http://weblog.rubyonrails.org/2010/8/29/rails-3-0-it-s-done/) (from [v0.12.0](https://github.com/jamesmartin/inline_svg/releases/tag/v0.12.0))
16
- - [Rails 4](http://weblog.rubyonrails.org/2013/6/25/Rails-4-0-final/)
17
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))
18
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/) (experimental)
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).
19
20
 
20
21
  ## Changelog
21
22
 
@@ -17,10 +17,6 @@ module InlineSvg
17
17
  end
18
18
 
19
19
  def inline_svg(filename, transform_params={})
20
- ActiveSupport::Deprecation.warn(
21
- '`inline_svg` is deprecated and will be removed from inline_svg 2.0 (use `inline_svg_tag` or `inline_svg_pack_tag` instead)'
22
- )
23
-
24
20
  render_inline_svg(filename, transform_params)
25
21
  end
26
22
 
@@ -0,0 +1,15 @@
1
+ module InlineSvg
2
+ class PropshaftAssetFinder
3
+ def self.find_asset(filename)
4
+ new(filename)
5
+ end
6
+
7
+ def initialize(filename)
8
+ @filename = filename
9
+ end
10
+
11
+ def pathname
12
+ ::Rails.application.assets.load_path.find(@filename).path
13
+ end
14
+ end
15
+ end
@@ -1,3 +1,3 @@
1
1
  module InlineSvg
2
- VERSION = "1.7.2"
2
+ VERSION = "1.8.0"
3
3
  end
@@ -6,7 +6,7 @@ module InlineSvg
6
6
 
7
7
  def initialize(filename)
8
8
  @filename = filename
9
- @asset_path = Webpacker.manifest.lookup(@filename)
9
+ @asset_path = URI(Webpacker.manifest.lookup(@filename)).path
10
10
  end
11
11
 
12
12
  def pathname
data/lib/inline_svg.rb CHANGED
@@ -3,6 +3,7 @@ require "inline_svg/action_view/helpers"
3
3
  require "inline_svg/asset_file"
4
4
  require "inline_svg/cached_asset_file"
5
5
  require "inline_svg/finds_asset_paths"
6
+ require "inline_svg/propshaft_asset_finder"
6
7
  require "inline_svg/static_asset_finder"
7
8
  require "inline_svg/webpack_asset_finder"
8
9
  require "inline_svg/transform_pipeline"
@@ -41,6 +42,8 @@ module InlineSvg
41
42
  def asset_finder=(finder)
42
43
  @asset_finder = if finder.respond_to?(:find_asset)
43
44
  finder
45
+ elsif finder.class.name == "Propshaft::Assembly"
46
+ InlineSvg::PropshaftAssetFinder
44
47
  else
45
48
  # fallback to a naive static asset finder
46
49
  # (sprokects >= 3.0 && config.assets.precompile = false
@@ -45,4 +45,49 @@ describe InlineSvg::FindsAssetPaths do
45
45
  expect(InlineSvg::FindsAssetPaths.by_filename('some-file')).to be_nil
46
46
  end
47
47
  end
48
+
49
+ context "when propshaft finder returns an object which supports only the pathname method" do
50
+ it "returns fully qualified file paths from Propshaft" do
51
+ propshaft = double('PropshaftDouble')
52
+
53
+ expect(propshaft).to receive(:find_asset).with('some-file').
54
+ and_return(double(pathname: Pathname('/full/path/to/some-file')))
55
+
56
+ InlineSvg.configure do |config|
57
+ config.asset_finder = propshaft
58
+ end
59
+
60
+ expect(InlineSvg::FindsAssetPaths.by_filename('some-file')).to eq Pathname('/full/path/to/some-file')
61
+ end
62
+ end
63
+
64
+ context "when webpack finder returns an object with a relative asset path" do
65
+ it "returns the fully qualified file path" do
66
+ webpacker = double('WebpackerDouble')
67
+
68
+ expect(webpacker).to receive(:find_asset).with('some-file').
69
+ and_return(double(filename: Pathname('/full/path/to/some-file')))
70
+
71
+ InlineSvg.configure do |config|
72
+ config.asset_finder = webpacker
73
+ end
74
+
75
+ expect(InlineSvg::FindsAssetPaths.by_filename('some-file')).to eq Pathname('/full/path/to/some-file')
76
+ end
77
+ end
78
+
79
+ context "when webpack finder returns an object with an absolute http asset path" do
80
+ it "returns the fully qualified file path" do
81
+ webpacker = double('WebpackerDouble')
82
+
83
+ expect(webpacker).to receive(:find_asset).with('some-file').
84
+ and_return(double(filename: Pathname('https://my-fancy-domain.test/full/path/to/some-file')))
85
+
86
+ InlineSvg.configure do |config|
87
+ config.asset_finder = webpacker
88
+ end
89
+
90
+ expect(InlineSvg::FindsAssetPaths.by_filename('some-file')).to eq Pathname('https://my-fancy-domain.test/full/path/to/some-file')
91
+ end
92
+ end
48
93
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inline_svg
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.2
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Martin
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-07 00:00:00.000000000 Z
11
+ date: 2022-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -130,6 +130,7 @@ extensions: []
130
130
  extra_rdoc_files: []
131
131
  files:
132
132
  - ".github/workflows/integration_test.yml"
133
+ - ".github/workflows/rails_6_webpacker_integration_tests.yaml"
133
134
  - ".github/workflows/ruby.yml"
134
135
  - ".gitignore"
135
136
  - ".rubocop.yml"
@@ -147,6 +148,7 @@ files:
147
148
  - lib/inline_svg/finds_asset_paths.rb
148
149
  - lib/inline_svg/id_generator.rb
149
150
  - lib/inline_svg/io_resource.rb
151
+ - lib/inline_svg/propshaft_asset_finder.rb
150
152
  - lib/inline_svg/railtie.rb
151
153
  - lib/inline_svg/static_asset_finder.rb
152
154
  - lib/inline_svg/transform_pipeline.rb
@@ -200,7 +202,7 @@ homepage: https://github.com/jamesmartin/inline_svg
200
202
  licenses:
201
203
  - MIT
202
204
  metadata: {}
203
- post_install_message:
205
+ post_install_message:
204
206
  rdoc_options: []
205
207
  require_paths:
206
208
  - lib
@@ -216,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
216
218
  version: '0'
217
219
  requirements: []
218
220
  rubygems_version: 3.1.2
219
- signing_key:
221
+ signing_key:
220
222
  specification_version: 4
221
223
  summary: Embeds an SVG document, inline.
222
224
  test_files: