inline_svg 1.8.0 → 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 +3 -3
- data/.github/workflows/rails_6_webpacker_integration_tests.yaml +8 -4
- data/.github/workflows/ruby.yml +3 -3
- data/CHANGELOG.md +6 -1
- data/README.md +3 -1
- data/lib/inline_svg/propshaft_asset_finder.rb +2 -1
- 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 +1 -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 +15 -6
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
10
|
test-branch: [rails5, rails6, rails7]
|
11
|
+
timeout-minutes: 20
|
12
12
|
steps:
|
13
13
|
- name: Checkout
|
14
14
|
uses: actions/checkout@v2
|
@@ -19,9 +19,9 @@ jobs:
|
|
19
19
|
ref: ${{ matrix.test-branch }}
|
20
20
|
path: test_app
|
21
21
|
- name: Set up Ruby 2.7
|
22
|
-
uses:
|
22
|
+
uses: ruby/setup-ruby@v1
|
23
23
|
with:
|
24
|
-
ruby-version: 2.7.
|
24
|
+
ruby-version: 2.7.7
|
25
25
|
- name: Build local gem
|
26
26
|
run: |
|
27
27
|
gem install bundler
|
@@ -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
|
22
|
-
uses:
|
21
|
+
- name: Set up Ruby 3.1
|
22
|
+
uses: ruby/setup-ruby@v1
|
23
23
|
with:
|
24
|
-
ruby-version:
|
24
|
+
ruby-version: 3.1
|
25
25
|
- name: Build local gem
|
26
26
|
run: |
|
27
27
|
gem install bundler
|
@@ -46,10 +46,14 @@ jobs:
|
|
46
46
|
with:
|
47
47
|
node-version: 16
|
48
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'
|
49
53
|
- name: Generate Webpacker config
|
50
54
|
run: |
|
51
55
|
cd $GITHUB_WORKSPACE/test_app
|
52
|
-
yarn install --check-files
|
56
|
+
CXXFLAGS="--std=c++17" yarn install --check-files
|
53
57
|
bundle exec rake webpacker:compile
|
54
58
|
if: matrix.test-branch == 'rails6-webpacker'
|
55
59
|
- name: 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,13 @@ 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.
|
8
13
|
|
9
14
|
## [1.8.0] - 2022-01-09
|
10
15
|
### Added
|
data/README.md
CHANGED
@@ -14,7 +14,7 @@ Inline SVG supports:
|
|
14
14
|
|
15
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
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/)
|
17
|
+
- [Rails 7](https://weblog.rubyonrails.org/2021/12/6/Rails-7-0-rc-1-released/)
|
18
18
|
|
19
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).
|
20
20
|
|
@@ -97,6 +97,7 @@ key | description
|
|
97
97
|
`desc` | add a \<desc\> node inside the top level of the SVG document
|
98
98
|
`nocomment` | remove comment tags from the SVG document
|
99
99
|
`preserve_aspect_ratio` | adds a `preserveAspectRatio` attribute to the SVG
|
100
|
+
`view_box` | adds a `viewBox` attribute to the SVG
|
100
101
|
`aria` | adds common accessibility attributes to the SVG (see [PR #34](https://github.com/jamesmartin/inline_svg/pull/34#issue-152062674) for details)
|
101
102
|
`aria_hidden` | adds the `aria-hidden=true` attribute to the SVG
|
102
103
|
`fallback` | set fallback SVG document
|
@@ -114,6 +115,7 @@ inline_svg_tag(
|
|
114
115
|
desc: 'Some description',
|
115
116
|
nocomment: true,
|
116
117
|
preserve_aspect_ratio: 'xMaxYMax meet',
|
118
|
+
view_box: '0 0 100 100',
|
117
119
|
aria: true,
|
118
120
|
aria_hidden: true,
|
119
121
|
fallback: 'fallback-document.svg'
|
@@ -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
@@ -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
|
-
autorequire:
|
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
|
@@ -167,6 +167,7 @@ files:
|
|
167
167
|
- lib/inline_svg/transform_pipeline/transformations/style_attribute.rb
|
168
168
|
- lib/inline_svg/transform_pipeline/transformations/title.rb
|
169
169
|
- lib/inline_svg/transform_pipeline/transformations/transformation.rb
|
170
|
+
- lib/inline_svg/transform_pipeline/transformations/view_box.rb
|
170
171
|
- lib/inline_svg/transform_pipeline/transformations/width.rb
|
171
172
|
- lib/inline_svg/version.rb
|
172
173
|
- lib/inline_svg/webpack_asset_finder.rb
|
@@ -184,6 +185,8 @@ files:
|
|
184
185
|
- spec/id_generator_spec.rb
|
185
186
|
- spec/inline_svg_spec.rb
|
186
187
|
- spec/io_resource_spec.rb
|
188
|
+
- spec/propshaft_asset_finder_spec.rb
|
189
|
+
- spec/static_asset_finder_spec.rb
|
187
190
|
- spec/transformation_pipeline/transformations/aria_attributes_spec.rb
|
188
191
|
- spec/transformation_pipeline/transformations/aria_hidden_attribute_spec.rb
|
189
192
|
- spec/transformation_pipeline/transformations/class_attribute_spec.rb
|
@@ -196,13 +199,15 @@ files:
|
|
196
199
|
- spec/transformation_pipeline/transformations/style_attribute_spec.rb
|
197
200
|
- spec/transformation_pipeline/transformations/title_spec.rb
|
198
201
|
- spec/transformation_pipeline/transformations/transformation_spec.rb
|
202
|
+
- spec/transformation_pipeline/transformations/view_box_spec.rb
|
199
203
|
- spec/transformation_pipeline/transformations/width_spec.rb
|
200
204
|
- spec/transformation_pipeline/transformations_spec.rb
|
205
|
+
- spec/webpack_asset_finder_spec.rb
|
201
206
|
homepage: https://github.com/jamesmartin/inline_svg
|
202
207
|
licenses:
|
203
208
|
- MIT
|
204
209
|
metadata: {}
|
205
|
-
post_install_message:
|
210
|
+
post_install_message:
|
206
211
|
rdoc_options: []
|
207
212
|
require_paths:
|
208
213
|
- lib
|
@@ -217,8 +222,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
217
222
|
- !ruby/object:Gem::Version
|
218
223
|
version: '0'
|
219
224
|
requirements: []
|
220
|
-
rubygems_version: 3.
|
221
|
-
signing_key:
|
225
|
+
rubygems_version: 3.3.26
|
226
|
+
signing_key:
|
222
227
|
specification_version: 4
|
223
228
|
summary: Embeds an SVG document, inline.
|
224
229
|
test_files:
|
@@ -236,6 +241,8 @@ test_files:
|
|
236
241
|
- spec/id_generator_spec.rb
|
237
242
|
- spec/inline_svg_spec.rb
|
238
243
|
- spec/io_resource_spec.rb
|
244
|
+
- spec/propshaft_asset_finder_spec.rb
|
245
|
+
- spec/static_asset_finder_spec.rb
|
239
246
|
- spec/transformation_pipeline/transformations/aria_attributes_spec.rb
|
240
247
|
- spec/transformation_pipeline/transformations/aria_hidden_attribute_spec.rb
|
241
248
|
- spec/transformation_pipeline/transformations/class_attribute_spec.rb
|
@@ -248,5 +255,7 @@ test_files:
|
|
248
255
|
- spec/transformation_pipeline/transformations/style_attribute_spec.rb
|
249
256
|
- spec/transformation_pipeline/transformations/title_spec.rb
|
250
257
|
- spec/transformation_pipeline/transformations/transformation_spec.rb
|
258
|
+
- spec/transformation_pipeline/transformations/view_box_spec.rb
|
251
259
|
- spec/transformation_pipeline/transformations/width_spec.rb
|
252
260
|
- spec/transformation_pipeline/transformations_spec.rb
|
261
|
+
- spec/webpack_asset_finder_spec.rb
|