inline_svg 1.7.2 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/integration_test.yml +5 -16
- data/.github/workflows/rails_6_webpacker_integration_tests.yaml +62 -0
- data/.github/workflows/ruby.yml +3 -3
- data/CHANGELOG.md +14 -3
- data/README.md +5 -2
- data/lib/inline_svg/action_view/helpers.rb +0 -4
- data/lib/inline_svg/propshaft_asset_finder.rb +16 -0
- data/lib/inline_svg/static_asset_finder.rb +2 -1
- data/lib/inline_svg/transform_pipeline/transformations/view_box.rb +9 -0
- data/lib/inline_svg/transform_pipeline/transformations.rb +4 -2
- data/lib/inline_svg/version.rb +1 -1
- data/lib/inline_svg/webpack_asset_finder.rb +2 -1
- data/lib/inline_svg.rb +4 -0
- data/spec/finds_asset_paths_spec.rb +45 -0
- data/spec/propshaft_asset_finder_spec.rb +23 -0
- data/spec/static_asset_finder_spec.rb +25 -0
- data/spec/transformation_pipeline/transformations/view_box_spec.rb +13 -0
- data/spec/transformation_pipeline/transformations_spec.rb +2 -0
- data/spec/webpack_asset_finder_spec.rb +13 -0
- metadata +14 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9be789332e6a5c01a7cde946e537fe0cf1fb368fb1c1b102538298bb65791c21
|
4
|
+
data.tar.gz: fbb837594c30b641df85c6d5919737d14a8fc4dc9fe9fcd522ef403af913a0aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4181b4e48b2a5ef634dc80504e52bef5304bd7dc1c1cf44a710ed88653d175d7825640b557150033ce45c5d2bcf32f5c4fb906fffd14d9f41a62aedc2eb1254
|
7
|
+
data.tar.gz: 9e79590cf289ec30fb7b773fddd676df83822cc174af6fc6cd0bc0e38536c760a6584937c7795509b8e924384e6da9e86e45742781106697e1808961683264ee
|
@@ -4,11 +4,11 @@ on: [push]
|
|
4
4
|
|
5
5
|
jobs:
|
6
6
|
build:
|
7
|
-
|
8
7
|
runs-on: ubuntu-latest
|
9
8
|
strategy:
|
10
9
|
matrix:
|
11
|
-
test-branch: [
|
10
|
+
test-branch: [rails5, rails6, rails7]
|
11
|
+
timeout-minutes: 20
|
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.
|
22
|
-
uses:
|
21
|
+
- name: Set up Ruby 2.7
|
22
|
+
uses: ruby/setup-ruby@v1
|
23
23
|
with:
|
24
|
-
ruby-version: 2.
|
24
|
+
ruby-version: 2.7.7
|
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,62 @@
|
|
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 3.1
|
22
|
+
uses: ruby/setup-ruby@v1
|
23
|
+
with:
|
24
|
+
ruby-version: 3.1
|
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: Set up Python 2.7
|
50
|
+
uses: actions/setup-python@v4
|
51
|
+
with:
|
52
|
+
python-version: '2.7'
|
53
|
+
- name: Generate Webpacker config
|
54
|
+
run: |
|
55
|
+
cd $GITHUB_WORKSPACE/test_app
|
56
|
+
CXXFLAGS="--std=c++17" yarn install --check-files
|
57
|
+
bundle exec rake webpacker:compile
|
58
|
+
if: matrix.test-branch == 'rails6-webpacker'
|
59
|
+
- name: Test
|
60
|
+
run: |
|
61
|
+
cd $GITHUB_WORKSPACE/test_app
|
62
|
+
bundle exec rake test
|
data/.github/workflows/ruby.yml
CHANGED
@@ -9,10 +9,10 @@ jobs:
|
|
9
9
|
|
10
10
|
steps:
|
11
11
|
- uses: actions/checkout@v2
|
12
|
-
- name: Set up Ruby 2.
|
13
|
-
uses:
|
12
|
+
- name: Set up Ruby 2.7
|
13
|
+
uses: ruby/setup-ruby@v1
|
14
14
|
with:
|
15
|
-
ruby-version: 2.
|
15
|
+
ruby-version: 2.7.7
|
16
16
|
- name: Build and test with Rake
|
17
17
|
run: |
|
18
18
|
gem install bundler
|
data/CHANGELOG.md
CHANGED
@@ -3,8 +3,19 @@ All notable changes to this project will be documented in this file.
|
|
3
3
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
4
4
|
|
5
5
|
## [Unreleased][unreleased]
|
6
|
+
### Added
|
7
|
+
- A new option: `view_box` adds a `viewBox` attribute to the SVG. [#142](https://github.com/jamesmartin/inline_svg/pull/142). Thanks [@sunny](https://github.com/sunny)
|
6
8
|
|
7
|
-
|
9
|
+
### Fixed
|
10
|
+
- Allow Propshaft assets to use fallbacks. [#140](https://github.com/jamesmartin/inline_svg/pull/140). Thanks, [@ohrite](https://github.com/ohrite)
|
11
|
+
- Handling missing file when using static assets. [#141](https://github.com/jamesmartin/inline_svg/pull/141). Thanks, [@leighhalliday](https://github.com/leighhalliday)
|
12
|
+
- Handle missing file when using Webpacker assets.
|
13
|
+
|
14
|
+
## [1.8.0] - 2022-01-09
|
15
|
+
### Added
|
16
|
+
- 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)
|
17
|
+
- 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)
|
18
|
+
- Add support for Propshaft assets in Rails 7. [#134](https://github.com/jamesmartin/inline_svg/pull/134). Thanks, [@martinzamuner](https://github.com/martinzamuner)
|
8
19
|
|
9
20
|
## [1.7.2] - 2020-12-07
|
10
21
|
### Fixed
|
@@ -23,7 +34,6 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
23
34
|
- 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
35
|
- 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
36
|
|
26
|
-
|
27
37
|
## [1.6.0] - 2019-11-13
|
28
38
|
### Added
|
29
39
|
- Support Webpack via the new `inline_svg_pack_tag` helper and deprecate `inline_svg` helper in preparation for v2.0.
|
@@ -239,7 +249,8 @@ transformations](https://github.com/jamesmartin/inline_svg/blob/master/README.md
|
|
239
249
|
### Added
|
240
250
|
- Basic Railtie and view helper to inline SVG documents to Rails views.
|
241
251
|
|
242
|
-
[unreleased]: https://github.com/jamesmartin/inline_svg/compare/v1.
|
252
|
+
[unreleased]: https://github.com/jamesmartin/inline_svg/compare/v1.8.0...HEAD
|
253
|
+
[1.8.0]: https://github.com/jamesmartin/inline_svg/compare/v1.7.2...v1.8.0
|
243
254
|
[1.7.2]: https://github.com/jamesmartin/inline_svg/compare/v1.7.1...v1.7.2
|
244
255
|
[1.7.1]: https://github.com/jamesmartin/inline_svg/compare/v1.7.0...v1.7.1
|
245
256
|
[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/)
|
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
|
|
@@ -96,6 +97,7 @@ key | description
|
|
96
97
|
`desc` | add a \<desc\> node inside the top level of the SVG document
|
97
98
|
`nocomment` | remove comment tags from the SVG document
|
98
99
|
`preserve_aspect_ratio` | adds a `preserveAspectRatio` attribute to the SVG
|
100
|
+
`view_box` | adds a `viewBox` attribute to the SVG
|
99
101
|
`aria` | adds common accessibility attributes to the SVG (see [PR #34](https://github.com/jamesmartin/inline_svg/pull/34#issue-152062674) for details)
|
100
102
|
`aria_hidden` | adds the `aria-hidden=true` attribute to the SVG
|
101
103
|
`fallback` | set fallback SVG document
|
@@ -113,6 +115,7 @@ inline_svg_tag(
|
|
113
115
|
desc: 'Some description',
|
114
116
|
nocomment: true,
|
115
117
|
preserve_aspect_ratio: 'xMaxYMax meet',
|
118
|
+
view_box: '0 0 100 100',
|
116
119
|
aria: true,
|
117
120
|
aria_hidden: true,
|
118
121
|
fallback: 'fallback-document.svg'
|
@@ -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,16 @@
|
|
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
|
+
asset_path = ::Rails.application.assets.load_path.find(@filename)
|
13
|
+
asset_path.path unless asset_path.nil?
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -16,7 +16,8 @@ module InlineSvg
|
|
16
16
|
|
17
17
|
def pathname
|
18
18
|
if ::Rails.application.config.assets.compile
|
19
|
-
|
19
|
+
asset = ::Rails.application.assets[@filename]
|
20
|
+
Pathname.new(asset.filename) if asset.present?
|
20
21
|
else
|
21
22
|
manifest = ::Rails.application.assets_manifest
|
22
23
|
asset_path = manifest.assets[@filename]
|
@@ -10,11 +10,12 @@ module InlineSvg::TransformPipeline::Transformations
|
|
10
10
|
class: { transform: ClassAttribute },
|
11
11
|
style: { transform: StyleAttribute },
|
12
12
|
data: { transform: DataAttributes },
|
13
|
-
height: { transform: Height },
|
14
13
|
nocomment: { transform: NoComment },
|
15
14
|
preserve_aspect_ratio: { transform: PreserveAspectRatio },
|
16
15
|
size: { transform: Size },
|
17
16
|
width: { transform: Width },
|
17
|
+
height: { transform: Height },
|
18
|
+
view_box: { transform: ViewBox },
|
18
19
|
}
|
19
20
|
end
|
20
21
|
|
@@ -83,8 +84,9 @@ require 'inline_svg/transform_pipeline/transformations/description'
|
|
83
84
|
require 'inline_svg/transform_pipeline/transformations/size'
|
84
85
|
require 'inline_svg/transform_pipeline/transformations/height'
|
85
86
|
require 'inline_svg/transform_pipeline/transformations/width'
|
87
|
+
require 'inline_svg/transform_pipeline/transformations/view_box'
|
86
88
|
require 'inline_svg/transform_pipeline/transformations/id_attribute'
|
87
89
|
require 'inline_svg/transform_pipeline/transformations/data_attributes'
|
88
90
|
require 'inline_svg/transform_pipeline/transformations/preserve_aspect_ratio'
|
89
91
|
require 'inline_svg/transform_pipeline/transformations/aria_attributes'
|
90
|
-
require "inline_svg/transform_pipeline/transformations/aria_hidden_attribute"
|
92
|
+
require "inline_svg/transform_pipeline/transformations/aria_hidden_attribute"
|
data/lib/inline_svg/version.rb
CHANGED
@@ -6,7 +6,8 @@ module InlineSvg
|
|
6
6
|
|
7
7
|
def initialize(filename)
|
8
8
|
@filename = filename
|
9
|
-
|
9
|
+
manifest_lookup = Webpacker.manifest.lookup(@filename)
|
10
|
+
@asset_path = manifest_lookup.present? ? URI(manifest_lookup).path : ""
|
10
11
|
end
|
11
12
|
|
12
13
|
def pathname
|
data/lib/inline_svg.rb
CHANGED
@@ -3,12 +3,14 @@ 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"
|
9
10
|
require "inline_svg/io_resource"
|
10
11
|
|
11
12
|
require "inline_svg/railtie" if defined?(Rails)
|
13
|
+
require 'active_support'
|
12
14
|
require 'active_support/core_ext/string'
|
13
15
|
require 'nokogiri'
|
14
16
|
|
@@ -41,6 +43,8 @@ module InlineSvg
|
|
41
43
|
def asset_finder=(finder)
|
42
44
|
@asset_finder = if finder.respond_to?(:find_asset)
|
43
45
|
finder
|
46
|
+
elsif finder.class.name == "Propshaft::Assembly"
|
47
|
+
InlineSvg::PropshaftAssetFinder
|
44
48
|
else
|
45
49
|
# fallback to a naive static asset finder
|
46
50
|
# (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
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative '../lib/inline_svg'
|
2
|
+
|
3
|
+
describe InlineSvg::PropshaftAssetFinder do
|
4
|
+
context "when the file is not found" do
|
5
|
+
it "returns nil" do
|
6
|
+
stub_const('Rails', double('Rails').as_null_object)
|
7
|
+
expect(::Rails.application.assets.load_path).to receive(:find).with('some-file').and_return(nil)
|
8
|
+
|
9
|
+
expect(InlineSvg::PropshaftAssetFinder.find_asset('some-file').pathname).to be_nil
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
context "when the file is found" do
|
14
|
+
it "returns fully qualified file paths from Propshaft" do
|
15
|
+
stub_const('Rails', double('Rails').as_null_object)
|
16
|
+
asset = double('Asset')
|
17
|
+
expect(asset).to receive(:path).and_return(Pathname.new('/full/path/to/some-file'))
|
18
|
+
expect(::Rails.application.assets.load_path).to receive(:find).with('some-file').and_return(asset)
|
19
|
+
|
20
|
+
expect(InlineSvg::PropshaftAssetFinder.find_asset('some-file').pathname).to eq Pathname('/full/path/to/some-file')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require_relative '../lib/inline_svg'
|
2
|
+
|
3
|
+
describe InlineSvg::StaticAssetFinder do
|
4
|
+
context "when the file is not found" do
|
5
|
+
it "returns nil" do
|
6
|
+
stub_const('Rails', double('Rails').as_null_object)
|
7
|
+
expect(::Rails.application.config.assets).to receive(:compile).and_return(true)
|
8
|
+
|
9
|
+
expect(described_class.find_asset('some-file').pathname).to be_nil
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
context "when the file is found" do
|
14
|
+
it "returns fully qualified file path from Sprockets" do
|
15
|
+
stub_const('Rails', double('Rails').as_null_object)
|
16
|
+
expect(::Rails.application.config.assets).to receive(:compile).and_return(true)
|
17
|
+
pathname = Pathname.new('/full/path/to/some-file')
|
18
|
+
asset = double('Asset')
|
19
|
+
expect(asset).to receive(:filename).and_return(pathname)
|
20
|
+
expect(::Rails.application.assets).to receive(:[]).with('some-file').and_return(asset)
|
21
|
+
|
22
|
+
expect(described_class.find_asset('some-file').pathname).to eq(pathname)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'inline_svg/transform_pipeline'
|
2
|
+
|
3
|
+
describe InlineSvg::TransformPipeline::Transformations::ViewBox do
|
4
|
+
it "adds viewBox attribute to a SVG document" do
|
5
|
+
document = Nokogiri::XML::Document.parse('<svg>Some document</svg>')
|
6
|
+
transformation =
|
7
|
+
InlineSvg::TransformPipeline::Transformations::ViewBox
|
8
|
+
.create_with_value("0 0 100 100")
|
9
|
+
expect(transformation.transform(document).to_html).to eq(
|
10
|
+
"<svg viewBox=\"0 0 100 100\">Some document</svg>\n"
|
11
|
+
)
|
12
|
+
end
|
13
|
+
end
|
@@ -21,6 +21,7 @@ describe InlineSvg::TransformPipeline::Transformations do
|
|
21
21
|
size: 'irrelevant',
|
22
22
|
height: 'irrelevant',
|
23
23
|
width: 'irrelevant',
|
24
|
+
view_box: 'irrelevant',
|
24
25
|
id: 'irrelevant',
|
25
26
|
data: 'irrelevant',
|
26
27
|
preserve_aspect_ratio: 'irrelevant',
|
@@ -37,6 +38,7 @@ describe InlineSvg::TransformPipeline::Transformations do
|
|
37
38
|
InlineSvg::TransformPipeline::Transformations::Size,
|
38
39
|
InlineSvg::TransformPipeline::Transformations::Height,
|
39
40
|
InlineSvg::TransformPipeline::Transformations::Width,
|
41
|
+
InlineSvg::TransformPipeline::Transformations::ViewBox,
|
40
42
|
InlineSvg::TransformPipeline::Transformations::IdAttribute,
|
41
43
|
InlineSvg::TransformPipeline::Transformations::DataAttributes,
|
42
44
|
InlineSvg::TransformPipeline::Transformations::PreserveAspectRatio,
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require_relative '../lib/inline_svg'
|
2
|
+
|
3
|
+
describe InlineSvg::WebpackAssetFinder do
|
4
|
+
context "when the file is not found" do
|
5
|
+
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
|
+
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.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Martin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-29 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
|
@@ -165,6 +167,7 @@ files:
|
|
165
167
|
- lib/inline_svg/transform_pipeline/transformations/style_attribute.rb
|
166
168
|
- lib/inline_svg/transform_pipeline/transformations/title.rb
|
167
169
|
- lib/inline_svg/transform_pipeline/transformations/transformation.rb
|
170
|
+
- lib/inline_svg/transform_pipeline/transformations/view_box.rb
|
168
171
|
- lib/inline_svg/transform_pipeline/transformations/width.rb
|
169
172
|
- lib/inline_svg/version.rb
|
170
173
|
- lib/inline_svg/webpack_asset_finder.rb
|
@@ -182,6 +185,8 @@ files:
|
|
182
185
|
- spec/id_generator_spec.rb
|
183
186
|
- spec/inline_svg_spec.rb
|
184
187
|
- spec/io_resource_spec.rb
|
188
|
+
- spec/propshaft_asset_finder_spec.rb
|
189
|
+
- spec/static_asset_finder_spec.rb
|
185
190
|
- spec/transformation_pipeline/transformations/aria_attributes_spec.rb
|
186
191
|
- spec/transformation_pipeline/transformations/aria_hidden_attribute_spec.rb
|
187
192
|
- spec/transformation_pipeline/transformations/class_attribute_spec.rb
|
@@ -194,8 +199,10 @@ files:
|
|
194
199
|
- spec/transformation_pipeline/transformations/style_attribute_spec.rb
|
195
200
|
- spec/transformation_pipeline/transformations/title_spec.rb
|
196
201
|
- spec/transformation_pipeline/transformations/transformation_spec.rb
|
202
|
+
- spec/transformation_pipeline/transformations/view_box_spec.rb
|
197
203
|
- spec/transformation_pipeline/transformations/width_spec.rb
|
198
204
|
- spec/transformation_pipeline/transformations_spec.rb
|
205
|
+
- spec/webpack_asset_finder_spec.rb
|
199
206
|
homepage: https://github.com/jamesmartin/inline_svg
|
200
207
|
licenses:
|
201
208
|
- MIT
|
@@ -215,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
215
222
|
- !ruby/object:Gem::Version
|
216
223
|
version: '0'
|
217
224
|
requirements: []
|
218
|
-
rubygems_version: 3.
|
225
|
+
rubygems_version: 3.3.26
|
219
226
|
signing_key:
|
220
227
|
specification_version: 4
|
221
228
|
summary: Embeds an SVG document, inline.
|
@@ -234,6 +241,8 @@ test_files:
|
|
234
241
|
- spec/id_generator_spec.rb
|
235
242
|
- spec/inline_svg_spec.rb
|
236
243
|
- spec/io_resource_spec.rb
|
244
|
+
- spec/propshaft_asset_finder_spec.rb
|
245
|
+
- spec/static_asset_finder_spec.rb
|
237
246
|
- spec/transformation_pipeline/transformations/aria_attributes_spec.rb
|
238
247
|
- spec/transformation_pipeline/transformations/aria_hidden_attribute_spec.rb
|
239
248
|
- spec/transformation_pipeline/transformations/class_attribute_spec.rb
|
@@ -246,5 +255,7 @@ test_files:
|
|
246
255
|
- spec/transformation_pipeline/transformations/style_attribute_spec.rb
|
247
256
|
- spec/transformation_pipeline/transformations/title_spec.rb
|
248
257
|
- spec/transformation_pipeline/transformations/transformation_spec.rb
|
258
|
+
- spec/transformation_pipeline/transformations/view_box_spec.rb
|
249
259
|
- spec/transformation_pipeline/transformations/width_spec.rb
|
250
260
|
- spec/transformation_pipeline/transformations_spec.rb
|
261
|
+
- spec/webpack_asset_finder_spec.rb
|