inline_svg 1.4.0 → 1.5.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.
Potentially problematic release.
This version of inline_svg might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -1
- data/README.md +24 -1
- data/lib/inline_svg.rb +1 -0
- data/lib/inline_svg/railtie.rb +5 -1
- data/lib/inline_svg/version.rb +1 -1
- data/lib/inline_svg/webpack_asset_finder.rb +19 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7e8c4d03d15f0fdd876912e329fca61646c3dc917c3745a0f862dde2490ea2e
|
4
|
+
data.tar.gz: 606861334da0b46952d84ea19b3779405e26f411cedad03bf9dbe1973e387b3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05bb315a0a78041729e04f1860b0399e38acfcdec6729b49646b52c2a532721484b23ec6f005ade488570e057987f0761eee31d9fca541a09c712e073a4ae2c6
|
7
|
+
data.tar.gz: 0da8510891479fd88bf32e6f4a46fe001c861b64fba136609e5756b893fb86d4ebaaef40c048b132a745c954d9ddcb7f938ba218d7d94277ee61140b6d5529f6
|
data/CHANGELOG.md
CHANGED
@@ -3,7 +3,9 @@ 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
|
-
|
6
|
+
### Added
|
7
|
+
- Support for finding assets bundled by Webpacker
|
8
|
+
[#96](https://github.com/jamesmartin/inline_svg/pull/96)
|
7
9
|
|
8
10
|
## [1.4.0] - 2019-04-19
|
9
11
|
### Fixed
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ Styling a SVG document with CSS for use on the web is most reliably achieved by
|
|
6
6
|
[adding classes to the document and
|
7
7
|
embedding](http://css-tricks.com/using-svg/) it inline in the HTML.
|
8
8
|
|
9
|
-
This gem adds a Rails helper method (`inline_svg`) that reads an SVG document (via Sprockets, so works with the Rails Asset Pipeline), applies a CSS class attribute to the root of the document and
|
9
|
+
This gem adds a Rails helper method (`inline_svg`) that reads 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
10
|
then embeds it into a view.
|
11
11
|
|
12
12
|
Inline SVG supports [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)), [Rails 4](http://weblog.rubyonrails.org/2013/6/25/Rails-4-0-final/) and [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)).
|
@@ -303,6 +303,29 @@ InlineSvg.configure do |config|
|
|
303
303
|
end
|
304
304
|
```
|
305
305
|
|
306
|
+
## Sprockets and Webpacker
|
307
|
+
|
308
|
+
Inline SVG supports SVGs bundled by either Sprockets or Webpacker, however, be
|
309
|
+
aware that the gem will *always* attempt to find SVGs using Sprockts if it is
|
310
|
+
enabled.
|
311
|
+
|
312
|
+
By default, Inline SVG will use Sprockets to find SVG files if it is enabled in
|
313
|
+
your Rails project.
|
314
|
+
|
315
|
+
If you have upgraded an older Rails project from Sprockets to Webpacker and you
|
316
|
+
no longer want to use Sprockets at all, you should disable the Asset Pipeline
|
317
|
+
and Inline SVG will use Webpacker automatically.
|
318
|
+
|
319
|
+
If you have both Sprockets *and* Webpacker enabled for some reason and you want
|
320
|
+
Inline SVG to use Webpacker to find SVGs then you should configure the
|
321
|
+
`asset_finder` appropriately:
|
322
|
+
|
323
|
+
```ruby
|
324
|
+
InlineSvg.configure do |config|
|
325
|
+
config.asset_finder = InlineSvg::WebpackAssetFinder
|
326
|
+
end
|
327
|
+
```
|
328
|
+
|
306
329
|
## Contributing
|
307
330
|
|
308
331
|
1. Fork it ( [http://github.com/jamesmartin/inline_svg/fork](http://github.com/jamesmartin/inline_svg/fork) )
|
data/lib/inline_svg.rb
CHANGED
@@ -4,6 +4,7 @@ require "inline_svg/asset_file"
|
|
4
4
|
require "inline_svg/cached_asset_file"
|
5
5
|
require "inline_svg/finds_asset_paths"
|
6
6
|
require "inline_svg/static_asset_finder"
|
7
|
+
require "inline_svg/webpack_asset_finder"
|
7
8
|
require "inline_svg/transform_pipeline"
|
8
9
|
require "inline_svg/io_resource"
|
9
10
|
|
data/lib/inline_svg/railtie.rb
CHANGED
@@ -15,7 +15,11 @@ module InlineSvg
|
|
15
15
|
# Only set this when a user-configured asset finder has not been
|
16
16
|
# configured already.
|
17
17
|
if config.asset_finder.nil?
|
18
|
-
|
18
|
+
if assets = app.instance_variable_get(:@assets)
|
19
|
+
config.asset_finder = assets
|
20
|
+
elsif defined?(Webpacker)
|
21
|
+
config.asset_finder = InlineSvg::WebpackAssetFinder
|
22
|
+
end
|
19
23
|
end
|
20
24
|
end
|
21
25
|
end
|
data/lib/inline_svg/version.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
module InlineSvg
|
2
|
+
class WebpackAssetFinder
|
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
|
+
public_path = Webpacker.config.public_path
|
13
|
+
file_path = Webpacker.instance.manifest.lookup(@filename)
|
14
|
+
return unless public_path && file_path
|
15
|
+
|
16
|
+
File.join(public_path, file_path)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
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.5.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: 2019-
|
11
|
+
date: 2019-06-16 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/transformation.rb
|
168
168
|
- lib/inline_svg/transform_pipeline/transformations/width.rb
|
169
169
|
- lib/inline_svg/version.rb
|
170
|
+
- lib/inline_svg/webpack_asset_finder.rb
|
170
171
|
- spec/asset_file_spec.rb
|
171
172
|
- spec/cached_asset_file_spec.rb
|
172
173
|
- spec/files/example.svg
|