inline_svg 0.5.2 → 0.5.3
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 +7 -2
- data/README.md +11 -10
- data/lib/inline_svg/transform_pipeline/transformations.rb +3 -1
- data/lib/inline_svg/transform_pipeline/transformations/preserve_aspect_ratio.rb +10 -0
- data/lib/inline_svg/version.rb +1 -1
- data/spec/transformation_pipeline/transformations/preserve_aspect_ratio_spec.rb +11 -0
- data/spec/transformation_pipeline/transformations_spec.rb +4 -2
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bd0dc863ab3a27cdd10a6c7377b0a065792367a
|
4
|
+
data.tar.gz: 515ff976eac0d9b795d75a7906c9889a7c006b67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 030d7333cfc87e0bcbb0f47932a5e10405903aebaf55d2ceb350edbf11fcc4993dfd9eb95f37418a6aa34f67c60d79c365379aeadc874dddd4c94cd10f6d3ae0
|
7
|
+
data.tar.gz: bb3fd6d2022b283f8494472bbf5a1865a818b1fd22c1b0b265a0d8328913b53889a08acf83a1923bbd50465a42972ac1eb065f883906fd9464c5a259187e3a99
|
data/CHANGELOG.md
CHANGED
@@ -3,7 +3,11 @@ 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
|
-
Nothing.
|
6
|
+
- Nothing.
|
7
|
+
|
8
|
+
## [0.5.3] - 2015-06-22
|
9
|
+
### Added
|
10
|
+
- `preserveAspectRatio` transformation on SVG root node. Thanks, @paulozoom.
|
7
11
|
|
8
12
|
## [0.5.2] - 2015-04-03
|
9
13
|
### Fixed
|
@@ -52,7 +56,8 @@ Nothing.
|
|
52
56
|
### Added
|
53
57
|
- Basic Railtie and view helper to inline SVG documents to Rails views.
|
54
58
|
|
55
|
-
[unreleased]: https://github.com/jamesmartin/inline_svg/compare/v0.5.
|
59
|
+
[unreleased]: https://github.com/jamesmartin/inline_svg/compare/v0.5.3...HEAD
|
60
|
+
[0.5.3]: https://github.com/jamesmartin/inline_svg/compare/v0.5.2...v0.5.3
|
56
61
|
[0.5.2]: https://github.com/jamesmartin/inline_svg/compare/v0.5.1...v0.5.2
|
57
62
|
[0.5.1]: https://github.com/jamesmartin/inline_svg/compare/v0.5.0...v0.5.1
|
58
63
|
[0.5.0]: https://github.com/jamesmartin/inline_svg/compare/v0.4.0...v0.5.0
|
data/README.md
CHANGED
@@ -66,21 +66,22 @@ blue:
|
|
66
66
|
|
67
67
|
## Options
|
68
68
|
|
69
|
-
key
|
70
|
-
|
71
|
-
`id`
|
72
|
-
`class`
|
73
|
-
`data`
|
74
|
-
`size`
|
75
|
-
`title`
|
76
|
-
`desc`
|
77
|
-
`nocomment`
|
69
|
+
key | description
|
70
|
+
:---------------------- | :----------
|
71
|
+
`id` | set a ID attribute on the SVG
|
72
|
+
`class` | set a CSS class attribute on the SVG
|
73
|
+
`data` | add data attributes to the SVG (supply as a hash)
|
74
|
+
`size` | set width and height attributes on the SVG <br/> Can also be set using `height` and/or `width` attributes, which take precedence over `size` <br/> Supplied as "{Width} * {Height}" or "{Number}", so "30px*45px" becomes `width="30px"` and `height="45px"`, and "50%" becomes `width="50%"` and `height="50%"`
|
75
|
+
`title` | add a \<title\> node inside the top level of the SVG document
|
76
|
+
`desc` | add a \<desc\> node inside the top level of the SVG document
|
77
|
+
`nocomment` | remove comment tags (and other unsafe/unknown tags) from svg (uses the [Loofah](https://github.com/flavorjones/loofah) gem)
|
78
|
+
`preserve_aspect_ratio` | adds a `preserveAspectRatio` attribute to the SVG
|
78
79
|
|
79
80
|
Example:
|
80
81
|
|
81
82
|
```
|
82
83
|
inline_svg("some-document.svg", id: 'some-id', class: 'some-class', data: {some: "value"}, size: '30% * 20%', title: 'Some Title', desc:
|
83
|
-
'Some description', nocomment: true)
|
84
|
+
'Some description', nocomment: true, preserve_aspect_ratio: 'xMaxYMax meet')
|
84
85
|
```
|
85
86
|
|
86
87
|
## Contributing
|
@@ -9,7 +9,8 @@ module InlineSvg::TransformPipeline::Transformations
|
|
9
9
|
height: Height,
|
10
10
|
width: Width,
|
11
11
|
id: IdAttribute,
|
12
|
-
data: DataAttributes
|
12
|
+
data: DataAttributes,
|
13
|
+
preserve_aspect_ratio: PreserveAspectRatio
|
13
14
|
}
|
14
15
|
end
|
15
16
|
|
@@ -34,3 +35,4 @@ require 'inline_svg/transform_pipeline/transformations/height'
|
|
34
35
|
require 'inline_svg/transform_pipeline/transformations/width'
|
35
36
|
require 'inline_svg/transform_pipeline/transformations/id_attribute'
|
36
37
|
require 'inline_svg/transform_pipeline/transformations/data_attributes'
|
38
|
+
require 'inline_svg/transform_pipeline/transformations/preserve_aspect_ratio'
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module InlineSvg::TransformPipeline::Transformations
|
2
|
+
class PreserveAspectRatio < Transformation
|
3
|
+
def transform(doc)
|
4
|
+
doc = Nokogiri::XML::Document.parse(doc.to_html)
|
5
|
+
svg = doc.at_css 'svg'
|
6
|
+
svg['preserveAspectRatio'] = self.value
|
7
|
+
doc
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
data/lib/inline_svg/version.rb
CHANGED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'inline_svg/transform_pipeline'
|
2
|
+
|
3
|
+
describe InlineSvg::TransformPipeline::Transformations::PreserveAspectRatio do
|
4
|
+
it "adds preserveAspectRatio attribute to a SVG document" do
|
5
|
+
document = Nokogiri::XML::Document.parse('<svg>Some document</svg>')
|
6
|
+
transformation = InlineSvg::TransformPipeline::Transformations::PreserveAspectRatio.create_with_value("xMaxYMax meet")
|
7
|
+
expect(transformation.transform(document).to_html).to eq(
|
8
|
+
"<svg preserveAspectRatio=\"xMaxYMax meet\">Some document</svg>\n"
|
9
|
+
)
|
10
|
+
end
|
11
|
+
end
|
@@ -12,7 +12,8 @@ describe InlineSvg::TransformPipeline::Transformations do
|
|
12
12
|
height: 'irrelevant',
|
13
13
|
width: 'irrelevant',
|
14
14
|
id: 'irrelevant',
|
15
|
-
data: 'irrelevant'
|
15
|
+
data: 'irrelevant',
|
16
|
+
preserve_aspect_ratio: 'irrelevant',
|
16
17
|
)
|
17
18
|
|
18
19
|
expect(transformations.map(&:class)).to match_array([
|
@@ -24,7 +25,8 @@ describe InlineSvg::TransformPipeline::Transformations do
|
|
24
25
|
InlineSvg::TransformPipeline::Transformations::Height,
|
25
26
|
InlineSvg::TransformPipeline::Transformations::Width,
|
26
27
|
InlineSvg::TransformPipeline::Transformations::IdAttribute,
|
27
|
-
InlineSvg::TransformPipeline::Transformations::DataAttributes
|
28
|
+
InlineSvg::TransformPipeline::Transformations::DataAttributes,
|
29
|
+
InlineSvg::TransformPipeline::Transformations::PreserveAspectRatio
|
28
30
|
])
|
29
31
|
end
|
30
32
|
|
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.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Martin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -121,6 +121,7 @@ files:
|
|
121
121
|
- lib/inline_svg/transform_pipeline/transformations/height.rb
|
122
122
|
- lib/inline_svg/transform_pipeline/transformations/id_attribute.rb
|
123
123
|
- lib/inline_svg/transform_pipeline/transformations/no_comment.rb
|
124
|
+
- lib/inline_svg/transform_pipeline/transformations/preserve_aspect_ratio.rb
|
124
125
|
- lib/inline_svg/transform_pipeline/transformations/size.rb
|
125
126
|
- lib/inline_svg/transform_pipeline/transformations/title.rb
|
126
127
|
- lib/inline_svg/transform_pipeline/transformations/transformation.rb
|
@@ -134,6 +135,7 @@ files:
|
|
134
135
|
- spec/transformation_pipeline/transformations/data_attributes_spec.rb
|
135
136
|
- spec/transformation_pipeline/transformations/height_spec.rb
|
136
137
|
- spec/transformation_pipeline/transformations/id_attribute_spec.rb
|
138
|
+
- spec/transformation_pipeline/transformations/preserve_aspect_ratio_spec.rb
|
137
139
|
- spec/transformation_pipeline/transformations/size_spec.rb
|
138
140
|
- spec/transformation_pipeline/transformations/width_spec.rb
|
139
141
|
- spec/transformation_pipeline/transformations_spec.rb
|
@@ -170,6 +172,7 @@ test_files:
|
|
170
172
|
- spec/transformation_pipeline/transformations/data_attributes_spec.rb
|
171
173
|
- spec/transformation_pipeline/transformations/height_spec.rb
|
172
174
|
- spec/transformation_pipeline/transformations/id_attribute_spec.rb
|
175
|
+
- spec/transformation_pipeline/transformations/preserve_aspect_ratio_spec.rb
|
173
176
|
- spec/transformation_pipeline/transformations/size_spec.rb
|
174
177
|
- spec/transformation_pipeline/transformations/width_spec.rb
|
175
178
|
- spec/transformation_pipeline/transformations_spec.rb
|