inline_svg 1.2.0 → 1.3.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/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +421 -0
- data/CHANGELOG.md +35 -1
- data/README.md +46 -9
- data/Rakefile +7 -0
- data/inline_svg.gemspec +1 -0
- data/lib/inline_svg/action_view/helpers.rb +29 -6
- data/lib/inline_svg/cached_asset_file.rb +17 -3
- data/lib/inline_svg/id_generator.rb +9 -2
- data/lib/inline_svg/io_resource.rb +4 -3
- data/lib/inline_svg/transform_pipeline/transformations/aria_attributes.rb +16 -19
- data/lib/inline_svg/transform_pipeline/transformations/aria_hidden.rb +9 -0
- data/lib/inline_svg/transform_pipeline/transformations/aria_hidden_attribute.rb +9 -0
- data/lib/inline_svg/transform_pipeline/transformations/class_attribute.rb +5 -6
- data/lib/inline_svg/transform_pipeline/transformations/data_attributes.rb +4 -5
- data/lib/inline_svg/transform_pipeline/transformations/description.rb +7 -6
- data/lib/inline_svg/transform_pipeline/transformations/height.rb +3 -4
- data/lib/inline_svg/transform_pipeline/transformations/id_attribute.rb +3 -4
- data/lib/inline_svg/transform_pipeline/transformations/no_comment.rb +4 -4
- data/lib/inline_svg/transform_pipeline/transformations/preserve_aspect_ratio.rb +3 -4
- data/lib/inline_svg/transform_pipeline/transformations/size.rb +4 -5
- data/lib/inline_svg/transform_pipeline/transformations/style_attribute.rb +11 -0
- data/lib/inline_svg/transform_pipeline/transformations/title.rb +7 -6
- data/lib/inline_svg/transform_pipeline/transformations/transformation.rb +13 -0
- data/lib/inline_svg/transform_pipeline/transformations/width.rb +3 -4
- data/lib/inline_svg/transform_pipeline/transformations.rb +4 -0
- data/lib/inline_svg/version.rb +1 -1
- data/lib/inline_svg.rb +16 -9
- data/spec/cached_asset_file_spec.rb +12 -0
- data/spec/files/static_assets/assets0/known-document-two.svg +1 -0
- data/spec/helpers/inline_svg_spec.rb +46 -1
- data/spec/id_generator_spec.rb +5 -3
- data/spec/inline_svg_spec.rb +10 -0
- data/spec/transformation_pipeline/transformations/aria_attributes_spec.rb +6 -6
- data/spec/transformation_pipeline/transformations/aria_hidden_attribute_spec.rb +12 -0
- data/spec/transformation_pipeline/transformations/height_spec.rb +9 -0
- data/spec/transformation_pipeline/transformations/style_attribute_spec.rb +26 -0
- data/spec/transformation_pipeline/transformations/title_spec.rb +9 -0
- data/spec/transformation_pipeline/transformations/transformation_spec.rb +39 -0
- data/spec/transformation_pipeline/transformations_spec.rb +5 -1
- metadata +30 -3
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'inline_svg'
|
2
|
+
require 'inline_svg/transform_pipeline'
|
3
|
+
|
4
|
+
describe InlineSvg::TransformPipeline::Transformations::Transformation do
|
5
|
+
context "#with_svg" do
|
6
|
+
it "returns a Nokogiri::XML::Document representing the parsed document fragment" do
|
7
|
+
document = Nokogiri::XML::Document.parse("<svg>Some document</svg>")
|
8
|
+
|
9
|
+
transformation = InlineSvg::TransformPipeline::Transformations::Transformation.new(:irrelevant)
|
10
|
+
expect(transformation.with_svg(document).to_html).to eq(
|
11
|
+
"<svg>Some document</svg>\n"
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "yields to the block when the document contains an SVG element" do
|
16
|
+
document = Nokogiri::XML::Document.parse("<svg>Some document</svg>")
|
17
|
+
svg = document.at_css("svg")
|
18
|
+
|
19
|
+
transformation = InlineSvg::TransformPipeline::Transformations::Transformation.new(:irrelevant)
|
20
|
+
|
21
|
+
returned_document = nil
|
22
|
+
expect do |b|
|
23
|
+
returned_document = transformation.with_svg(document, &b)
|
24
|
+
end.to yield_control
|
25
|
+
|
26
|
+
expect(returned_document.to_s).to match(/<svg>Some document<\/svg>/)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "does not yield if the document does not contain an SVG element at the root" do
|
30
|
+
document = Nokogiri::XML::Document.parse("<foo>bar</foo><svg>Some document</svg>")
|
31
|
+
|
32
|
+
transformation = InlineSvg::TransformPipeline::Transformations::Transformation.new(:irrelevant)
|
33
|
+
|
34
|
+
expect do |b|
|
35
|
+
transformation.with_svg(document, &b)
|
36
|
+
end.not_to yield_control
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -15,6 +15,7 @@ describe InlineSvg::TransformPipeline::Transformations do
|
|
15
15
|
transformations = InlineSvg::TransformPipeline::Transformations.lookup(
|
16
16
|
nocomment: 'irrelevant',
|
17
17
|
class: 'irrelevant',
|
18
|
+
style: 'irrelevant',
|
18
19
|
title: 'irrelevant',
|
19
20
|
desc: 'irrelevant',
|
20
21
|
size: 'irrelevant',
|
@@ -24,11 +25,13 @@ describe InlineSvg::TransformPipeline::Transformations do
|
|
24
25
|
data: 'irrelevant',
|
25
26
|
preserve_aspect_ratio: 'irrelevant',
|
26
27
|
aria: 'irrelevant',
|
28
|
+
aria_hidden: "true"
|
27
29
|
)
|
28
30
|
|
29
31
|
expect(transformations.map(&:class)).to match_array([
|
30
32
|
InlineSvg::TransformPipeline::Transformations::NoComment,
|
31
33
|
InlineSvg::TransformPipeline::Transformations::ClassAttribute,
|
34
|
+
InlineSvg::TransformPipeline::Transformations::StyleAttribute,
|
32
35
|
InlineSvg::TransformPipeline::Transformations::Title,
|
33
36
|
InlineSvg::TransformPipeline::Transformations::Description,
|
34
37
|
InlineSvg::TransformPipeline::Transformations::Size,
|
@@ -37,7 +40,8 @@ describe InlineSvg::TransformPipeline::Transformations do
|
|
37
40
|
InlineSvg::TransformPipeline::Transformations::IdAttribute,
|
38
41
|
InlineSvg::TransformPipeline::Transformations::DataAttributes,
|
39
42
|
InlineSvg::TransformPipeline::Transformations::PreserveAspectRatio,
|
40
|
-
InlineSvg::TransformPipeline::Transformations::AriaAttributes
|
43
|
+
InlineSvg::TransformPipeline::Transformations::AriaAttributes,
|
44
|
+
InlineSvg::TransformPipeline::Transformations::AriaHiddenAttribute
|
41
45
|
])
|
42
46
|
end
|
43
47
|
|
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.3.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: 2017-
|
11
|
+
date: 2017-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: activesupport
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,6 +130,8 @@ extensions: []
|
|
116
130
|
extra_rdoc_files: []
|
117
131
|
files:
|
118
132
|
- ".gitignore"
|
133
|
+
- ".rubocop.yml"
|
134
|
+
- ".rubocop_todo.yml"
|
119
135
|
- CHANGELOG.md
|
120
136
|
- Gemfile
|
121
137
|
- LICENSE.txt
|
@@ -135,6 +151,8 @@ files:
|
|
135
151
|
- lib/inline_svg/transform_pipeline.rb
|
136
152
|
- lib/inline_svg/transform_pipeline/transformations.rb
|
137
153
|
- lib/inline_svg/transform_pipeline/transformations/aria_attributes.rb
|
154
|
+
- lib/inline_svg/transform_pipeline/transformations/aria_hidden.rb
|
155
|
+
- lib/inline_svg/transform_pipeline/transformations/aria_hidden_attribute.rb
|
138
156
|
- lib/inline_svg/transform_pipeline/transformations/class_attribute.rb
|
139
157
|
- lib/inline_svg/transform_pipeline/transformations/data_attributes.rb
|
140
158
|
- lib/inline_svg/transform_pipeline/transformations/description.rb
|
@@ -143,6 +161,7 @@ files:
|
|
143
161
|
- lib/inline_svg/transform_pipeline/transformations/no_comment.rb
|
144
162
|
- lib/inline_svg/transform_pipeline/transformations/preserve_aspect_ratio.rb
|
145
163
|
- lib/inline_svg/transform_pipeline/transformations/size.rb
|
164
|
+
- lib/inline_svg/transform_pipeline/transformations/style_attribute.rb
|
146
165
|
- lib/inline_svg/transform_pipeline/transformations/title.rb
|
147
166
|
- lib/inline_svg/transform_pipeline/transformations/transformation.rb
|
148
167
|
- lib/inline_svg/transform_pipeline/transformations/width.rb
|
@@ -150,6 +169,7 @@ files:
|
|
150
169
|
- spec/asset_file_spec.rb
|
151
170
|
- spec/cached_asset_file_spec.rb
|
152
171
|
- spec/files/example.svg
|
172
|
+
- spec/files/static_assets/assets0/known-document-two.svg
|
153
173
|
- spec/files/static_assets/assets0/known-document.svg
|
154
174
|
- spec/files/static_assets/assets0/some-document.svg
|
155
175
|
- spec/files/static_assets/assets1/known-document.svg
|
@@ -161,6 +181,7 @@ files:
|
|
161
181
|
- spec/inline_svg_spec.rb
|
162
182
|
- spec/io_resource_spec.rb
|
163
183
|
- spec/transformation_pipeline/transformations/aria_attributes_spec.rb
|
184
|
+
- spec/transformation_pipeline/transformations/aria_hidden_attribute_spec.rb
|
164
185
|
- spec/transformation_pipeline/transformations/class_attribute_spec.rb
|
165
186
|
- spec/transformation_pipeline/transformations/data_attributes_spec.rb
|
166
187
|
- spec/transformation_pipeline/transformations/description_spec.rb
|
@@ -168,7 +189,9 @@ files:
|
|
168
189
|
- spec/transformation_pipeline/transformations/id_attribute_spec.rb
|
169
190
|
- spec/transformation_pipeline/transformations/preserve_aspect_ratio_spec.rb
|
170
191
|
- spec/transformation_pipeline/transformations/size_spec.rb
|
192
|
+
- spec/transformation_pipeline/transformations/style_attribute_spec.rb
|
171
193
|
- spec/transformation_pipeline/transformations/title_spec.rb
|
194
|
+
- spec/transformation_pipeline/transformations/transformation_spec.rb
|
172
195
|
- spec/transformation_pipeline/transformations/width_spec.rb
|
173
196
|
- spec/transformation_pipeline/transformations_spec.rb
|
174
197
|
homepage: https://github.com/jamesmartin/inline_svg
|
@@ -191,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
214
|
version: '0'
|
192
215
|
requirements: []
|
193
216
|
rubyforge_project:
|
194
|
-
rubygems_version: 2.
|
217
|
+
rubygems_version: 2.6.11
|
195
218
|
signing_key:
|
196
219
|
specification_version: 4
|
197
220
|
summary: Embeds an SVG document, inline.
|
@@ -199,6 +222,7 @@ test_files:
|
|
199
222
|
- spec/asset_file_spec.rb
|
200
223
|
- spec/cached_asset_file_spec.rb
|
201
224
|
- spec/files/example.svg
|
225
|
+
- spec/files/static_assets/assets0/known-document-two.svg
|
202
226
|
- spec/files/static_assets/assets0/known-document.svg
|
203
227
|
- spec/files/static_assets/assets0/some-document.svg
|
204
228
|
- spec/files/static_assets/assets1/known-document.svg
|
@@ -210,6 +234,7 @@ test_files:
|
|
210
234
|
- spec/inline_svg_spec.rb
|
211
235
|
- spec/io_resource_spec.rb
|
212
236
|
- spec/transformation_pipeline/transformations/aria_attributes_spec.rb
|
237
|
+
- spec/transformation_pipeline/transformations/aria_hidden_attribute_spec.rb
|
213
238
|
- spec/transformation_pipeline/transformations/class_attribute_spec.rb
|
214
239
|
- spec/transformation_pipeline/transformations/data_attributes_spec.rb
|
215
240
|
- spec/transformation_pipeline/transformations/description_spec.rb
|
@@ -217,6 +242,8 @@ test_files:
|
|
217
242
|
- spec/transformation_pipeline/transformations/id_attribute_spec.rb
|
218
243
|
- spec/transformation_pipeline/transformations/preserve_aspect_ratio_spec.rb
|
219
244
|
- spec/transformation_pipeline/transformations/size_spec.rb
|
245
|
+
- spec/transformation_pipeline/transformations/style_attribute_spec.rb
|
220
246
|
- spec/transformation_pipeline/transformations/title_spec.rb
|
247
|
+
- spec/transformation_pipeline/transformations/transformation_spec.rb
|
221
248
|
- spec/transformation_pipeline/transformations/width_spec.rb
|
222
249
|
- spec/transformation_pipeline/transformations_spec.rb
|