inline_svg 0.6.1 → 0.6.2
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 +1 -1
- data/README.md +8 -5
- data/lib/inline_svg/static_asset_finder.rb +27 -0
- data/lib/inline_svg/version.rb +1 -1
- data/lib/inline_svg.rb +5 -1
- data/spec/finds_asset_paths_spec.rb +1 -0
- data/spec/inline_svg_spec.rb +6 -6
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d53e3e703f3681894bee4523d13869a70d9d8d85
|
4
|
+
data.tar.gz: 114b05c6779d93d8f8a8cd2f19b6c19f8e32dc2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5f10abb1ebcff4ae18bda0f7600b14e0e8f2fb3123f100229e942fb63d8ea5cb6aaeb76a7f192dff2cbbfd1744370325c43e7a620000530d3b9877dad0a9fec
|
7
|
+
data.tar.gz: aa1a416596f428d0afd41e028f8e1ccd3003a3e292f08046d5d3166c2d32f3e5cf99c47799b6e209f0b979821a65e1ac9bd6c99c8c553a0bd559d518620e8dbf
|
data/CHANGELOG.md
CHANGED
@@ -3,7 +3,7 @@ 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
|
+
- Support Sprockets >= 3.0 and config.assets.precompile = false
|
7
7
|
|
8
8
|
## [0.6.1] - 2015-08-06
|
9
9
|
### Fixed
|
data/README.md
CHANGED
@@ -4,10 +4,13 @@ Styling a SVG document with CSS for use on the web is most reliably achieved by
|
|
4
4
|
[adding classes to the document and
|
5
5
|
embedding](http://css-tricks.com/using-svg/) it inline in the HTML.
|
6
6
|
|
7
|
-
This gem is a little helper method (`inline_svg`) that reads an SVG document
|
8
|
-
image directory, applies a CSS class attribute to the root of the document and
|
7
|
+
This gem is a little 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
8
|
then embeds it into a view.
|
10
9
|
|
10
|
+
Inline SVG supports [Rails version 4.0.4](http://weblog.rubyonrails.org/2014/3/14/Rails-4-0-4-has-been-released/) and newer.
|
11
|
+
|
12
|
+
Want to embed SVGs with Javascript? You might like [RemoteSvg](https://github.com/jamesmartin/remote-svg), which features similar transforms but can also load SVGs from remote URLs (like S3 etc.).
|
13
|
+
|
11
14
|
## Changelog
|
12
15
|
|
13
16
|
All notable changes to this project are documented in the
|
@@ -40,7 +43,7 @@ and fingerprint your SVG files like any other Rails asset.
|
|
40
43
|
Here's an example of embedding an SVG document and applying a 'class' attribute in
|
41
44
|
HAML:
|
42
45
|
|
43
|
-
```
|
46
|
+
```haml
|
44
47
|
!!! 5
|
45
48
|
%html
|
46
49
|
%head
|
@@ -54,7 +57,7 @@ HAML:
|
|
54
57
|
Here's some CSS to target the SVG, resize it and turn it an attractive shade of
|
55
58
|
blue:
|
56
59
|
|
57
|
-
```
|
60
|
+
```css
|
58
61
|
.some-class {
|
59
62
|
display: block;
|
60
63
|
margin: 0 auto;
|
@@ -79,7 +82,7 @@ key | description
|
|
79
82
|
|
80
83
|
Example:
|
81
84
|
|
82
|
-
```
|
85
|
+
```ruby
|
83
86
|
inline_svg("some-document.svg", id: 'some-id', class: 'some-class', data: {some: "value"}, size: '30% * 20%', title: 'Some Title', desc:
|
84
87
|
'Some description', nocomment: true, preserve_aspect_ratio: 'xMaxYMax meet')
|
85
88
|
```
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Naive fallback asset finder for when sprockets >= 3.0 &&
|
2
|
+
# config.assets.precompile = false
|
3
|
+
# Thanks to @ryanswood for the original code:
|
4
|
+
# https://github.com/AbleHealth/inline_svg/commit/661bbb3bef7d1b4bd6ccd63f5f018305797b9509
|
5
|
+
module InlineSvg
|
6
|
+
class StaticAssetFinder
|
7
|
+
def self.find_asset(filename)
|
8
|
+
new(filename)
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(filename)
|
12
|
+
@filename = filename
|
13
|
+
end
|
14
|
+
|
15
|
+
def pathname
|
16
|
+
if ::Rails.application.config.assets.compile
|
17
|
+
::Rails.application.assets[@filename].pathname
|
18
|
+
else
|
19
|
+
manifest = ::Rails.application.assets_manifest
|
20
|
+
asset_path = manifest.assets[@filename]
|
21
|
+
unless asset_path.nil?
|
22
|
+
::Rails.root.join(manifest.directory, asset_path)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/inline_svg/version.rb
CHANGED
data/lib/inline_svg.rb
CHANGED
@@ -2,6 +2,7 @@ require "inline_svg/version"
|
|
2
2
|
require "inline_svg/action_view/helpers"
|
3
3
|
require "inline_svg/asset_file"
|
4
4
|
require "inline_svg/finds_asset_paths"
|
5
|
+
require "inline_svg/static_asset_finder"
|
5
6
|
require "inline_svg/transform_pipeline"
|
6
7
|
|
7
8
|
require "inline_svg/railtie" if defined?(Rails)
|
@@ -22,7 +23,10 @@ module InlineSvg
|
|
22
23
|
if finder.respond_to?(:find_asset)
|
23
24
|
@asset_finder = finder
|
24
25
|
else
|
25
|
-
|
26
|
+
# fallback to a naive static asset finder (sprokects >= 3.0 &&
|
27
|
+
# config.assets.precompile = false
|
28
|
+
# See: https://github.com/jamesmartin/inline_svg/issues/25
|
29
|
+
@asset_finder = InlineSvg::StaticAssetFinder
|
26
30
|
end
|
27
31
|
asset_finder
|
28
32
|
end
|
data/spec/inline_svg_spec.rb
CHANGED
@@ -33,12 +33,12 @@ describe InlineSvg do
|
|
33
33
|
expect(InlineSvg.configuration.asset_finder).to eq sprockets
|
34
34
|
end
|
35
35
|
|
36
|
-
it "
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
36
|
+
it "falls back to StaticAssetFinder when the provided asset finder does not implement #find_asset" do
|
37
|
+
InlineSvg.configure do |config|
|
38
|
+
config.asset_finder = 'Not a real asset finder'
|
39
|
+
end
|
40
|
+
|
41
|
+
expect(InlineSvg.configuration.asset_finder).to eq InlineSvg::StaticAssetFinder
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
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: 0.6.
|
4
|
+
version: 0.6.2
|
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: 2016-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -113,6 +113,7 @@ files:
|
|
113
113
|
- lib/inline_svg/asset_file.rb
|
114
114
|
- lib/inline_svg/finds_asset_paths.rb
|
115
115
|
- lib/inline_svg/railtie.rb
|
116
|
+
- lib/inline_svg/static_asset_finder.rb
|
116
117
|
- lib/inline_svg/transform_pipeline.rb
|
117
118
|
- lib/inline_svg/transform_pipeline/transformations.rb
|
118
119
|
- lib/inline_svg/transform_pipeline/transformations/class_attribute.rb
|
@@ -159,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
160
|
version: '0'
|
160
161
|
requirements: []
|
161
162
|
rubyforge_project:
|
162
|
-
rubygems_version: 2.
|
163
|
+
rubygems_version: 2.2.5
|
163
164
|
signing_key:
|
164
165
|
specification_version: 4
|
165
166
|
summary: Embeds an SVG document, inline.
|