inline_svg 1.3.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of inline_svg might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/.travis.yml +8 -0
- data/CHANGELOG.md +10 -0
- data/README.md +9 -0
- data/circle.yml +1 -1
- data/inline_svg.gemspec +1 -1
- data/lib/inline_svg.rb +9 -0
- data/lib/inline_svg/action_view/helpers.rb +2 -1
- data/lib/inline_svg/id_generator.rb +3 -1
- data/lib/inline_svg/transform_pipeline/transformations.rb +4 -1
- data/lib/inline_svg/version.rb +1 -1
- data/spec/helpers/inline_svg_spec.rb +16 -0
- data/spec/id_generator_spec.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 52f5490767e351a088411f8254fb15e480581f7ea1bdff75a2215381c9fb2b78
|
4
|
+
data.tar.gz: f99942d0bd757bfe3dae3b9d4b0020f66241c1303c918b9d959e59b858b53135
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26f337f5bfc1dcd438ec10a7d4d4fd0a3404a57bc9563cb1b0ec3a0fa119f18f1fd95436be80f682a0f9d4a43dd3876fe5a79589a875192a6dc302801e486c13
|
7
|
+
data.tar.gz: f273c2270832a82a1edf9a964f1e52f63fc6a0f8156967e7fea29bc04b11767b70ddd3a26ef2cb152e8af0804fc769f03d28d4876ed9fb8472380f0670cab83b
|
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,16 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
5
5
|
## [Unreleased][unreleased]
|
6
6
|
- Nothing
|
7
7
|
|
8
|
+
## [1.4.0] - 2019-04-19
|
9
|
+
### Fixed
|
10
|
+
- Prevent invalid XML names being generated via IdGenerator
|
11
|
+
[#87](https://github.com/jamesmartin/inline_svg/issues/87)
|
12
|
+
Thanks, [@endorfin](https://github.com/endorfin)
|
13
|
+
|
14
|
+
### Added
|
15
|
+
- Raise error on file not found (if configured)
|
16
|
+
[#93](https://github.com/jamesmartin/inline_svg/issues/93)
|
17
|
+
|
8
18
|
## [1.3.1] - 2017-12-14
|
9
19
|
### Fixed
|
10
20
|
- Allow Ruby < 2.1 to work with `CachedAssetFile`
|
data/README.md
CHANGED
@@ -294,6 +294,15 @@ Which would instead render:
|
|
294
294
|
<svg class='svg-not-found'><!-- SVG file not found: 'some-missing-file.svg' --></svg>
|
295
295
|
```
|
296
296
|
|
297
|
+
Alternatively, `inline_svg` can be configured to raise an exception when a file
|
298
|
+
is not found:
|
299
|
+
|
300
|
+
```ruby
|
301
|
+
InlineSvg.configure do |config|
|
302
|
+
config.raise_on_file_not_found = true
|
303
|
+
end
|
304
|
+
```
|
305
|
+
|
297
306
|
## Contributing
|
298
307
|
|
299
308
|
1. Fork it ( [http://github.com/jamesmartin/inline_svg/fork](http://github.com/jamesmartin/inline_svg/fork) )
|
data/circle.yml
CHANGED
data/inline_svg.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency "bundler", "~>
|
21
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
22
22
|
spec.add_development_dependency "rake"
|
23
23
|
spec.add_development_dependency "rspec", "~> 3.2"
|
24
24
|
spec.add_development_dependency "rspec_junit_formatter", "0.2.2"
|
data/lib/inline_svg.rb
CHANGED
@@ -21,6 +21,7 @@ module InlineSvg
|
|
21
21
|
@custom_transformations = {}
|
22
22
|
@asset_file = InlineSvg::AssetFile
|
23
23
|
@svg_not_found_css_class = nil
|
24
|
+
@raise_on_file_not_found = false
|
24
25
|
end
|
25
26
|
|
26
27
|
def asset_file=(custom_asset_file)
|
@@ -61,6 +62,14 @@ module InlineSvg
|
|
61
62
|
@custom_transformations.merge!(Hash[ *[options.fetch(:attribute, :no_attribute), options] ])
|
62
63
|
end
|
63
64
|
|
65
|
+
def raise_on_file_not_found=(value)
|
66
|
+
@raise_on_file_not_found = value
|
67
|
+
end
|
68
|
+
|
69
|
+
def raise_on_file_not_found?
|
70
|
+
!!@raise_on_file_not_found
|
71
|
+
end
|
72
|
+
|
64
73
|
private
|
65
74
|
|
66
75
|
def incompatible_transformation?(klass)
|
@@ -7,7 +7,8 @@ module InlineSvg
|
|
7
7
|
def inline_svg(filename, transform_params={})
|
8
8
|
begin
|
9
9
|
svg_file = read_svg(filename)
|
10
|
-
rescue InlineSvg::AssetFile::FileNotFound
|
10
|
+
rescue InlineSvg::AssetFile::FileNotFound => error
|
11
|
+
raise error if InlineSvg.configuration.raise_on_file_not_found?
|
11
12
|
return placeholder(filename) unless transform_params[:fallback].present?
|
12
13
|
|
13
14
|
if transform_params[:fallback].present?
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'digest'
|
2
|
+
|
1
3
|
module InlineSvg
|
2
4
|
class IdGenerator
|
3
5
|
class Randomness
|
@@ -9,7 +11,7 @@ module InlineSvg
|
|
9
11
|
|
10
12
|
def self.generate(base, salt, randomness: Randomness)
|
11
13
|
bytes = Digest::SHA1.digest("#{base}-#{salt}-#{randomness.call}")
|
12
|
-
Digest.hexencode(bytes).to_i(16).to_s(36)
|
14
|
+
'a' + Digest.hexencode(bytes).to_i(16).to_s(36)
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
@@ -40,8 +40,11 @@ module InlineSvg::TransformPipeline::Transformations
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def self.lookup(transform_params)
|
43
|
+
return [] unless transform_params.any? || custom_transformations.any?
|
44
|
+
|
45
|
+
transform_params_with_defaults = params_with_defaults(transform_params)
|
43
46
|
all_transformations.map { |name, definition|
|
44
|
-
value =
|
47
|
+
value = transform_params_with_defaults[name]
|
45
48
|
definition.fetch(:transform, no_transform).create_with_value(value) if value
|
46
49
|
}.compact
|
47
50
|
end
|
data/lib/inline_svg/version.rb
CHANGED
@@ -20,6 +20,22 @@ describe InlineSvg::ActionView::Helpers do
|
|
20
20
|
InlineSvg.reset_configuration!
|
21
21
|
end
|
22
22
|
|
23
|
+
context "and configured to raise" do
|
24
|
+
it "raises an exception" do
|
25
|
+
InlineSvg.configure do |config|
|
26
|
+
config.raise_on_file_not_found = true
|
27
|
+
end
|
28
|
+
|
29
|
+
allow(InlineSvg::AssetFile).to receive(:named).
|
30
|
+
with('some-missing-file.svg').
|
31
|
+
and_raise(InlineSvg::AssetFile::FileNotFound.new)
|
32
|
+
|
33
|
+
expect {
|
34
|
+
helper.inline_svg('some-missing-file.svg')
|
35
|
+
}.to raise_error(InlineSvg::AssetFile::FileNotFound)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
23
39
|
it "returns an empty, html safe, SVG document as a placeholder" do
|
24
40
|
allow(InlineSvg::AssetFile).to receive(:named).
|
25
41
|
with('some-missing-file.svg').
|
data/spec/id_generator_spec.rb
CHANGED
@@ -5,6 +5,6 @@ describe InlineSvg::IdGenerator do
|
|
5
5
|
randomizer = -> { "some-random-value" }
|
6
6
|
|
7
7
|
expect(InlineSvg::IdGenerator.generate("some-base", "some-salt", randomness: randomizer)).
|
8
|
-
to eq("
|
8
|
+
to eq("at2c17mkqnvopy36iccxspura7wnreqf")
|
9
9
|
end
|
10
10
|
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.4.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:
|
11
|
+
date: 2019-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- ".gitignore"
|
133
133
|
- ".rubocop.yml"
|
134
134
|
- ".rubocop_todo.yml"
|
135
|
+
- ".travis.yml"
|
135
136
|
- CHANGELOG.md
|
136
137
|
- Gemfile
|
137
138
|
- LICENSE.txt
|
@@ -214,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
214
215
|
version: '0'
|
215
216
|
requirements: []
|
216
217
|
rubyforge_project:
|
217
|
-
rubygems_version: 2.6
|
218
|
+
rubygems_version: 2.7.6
|
218
219
|
signing_key:
|
219
220
|
specification_version: 4
|
220
221
|
summary: Embeds an SVG document, inline.
|