inline_svg 0.12.1 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0491a6e65ea3cac66dc9612b22a0a7a2715bb668
4
- data.tar.gz: 31d0110574f801a1f3cc77916decb92edc997513
3
+ metadata.gz: 7004d185bef2b924f18a066874654c38df4def32
4
+ data.tar.gz: b88ad5893b28740772c3561c2ec10b49f16354e8
5
5
  SHA512:
6
- metadata.gz: b58b3ca89ab12aba85a60e6073e835aa335b1d7a8e6e6af9218a63c0342eadc4cdd2d905b08a88b9c53d0535c65b8706a48f3d29e0113b8e989d8708d4c70286
7
- data.tar.gz: dd349c539a96ebeaf27dc71bcdc1c9cd7da6a4d54e07911272a5bf4896c28587a0d56c61e49eea6689e71917b020595b595982da27ea00a73ac75aa3ef70cf15
6
+ metadata.gz: d2cd936da88bd368aa88e7da0ef68791523c3c386d746e094c7e8f3df4b8b9dd3dc2293529d10ee80a42273a82f45ae69c356d55c2ada0ead4c59fcdfe64ed33
7
+ data.tar.gz: efdcb9cdbd557a06a0b689563b469df1fb1d7e8d78b62cc7cad97f70e26fb6f0c2d72f624ae7b36301a45298326ee043c401cc34b8e3bded752a886a14d62def
@@ -5,6 +5,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
5
5
  ## [Unreleased][unreleased]
6
6
  - Nothing
7
7
 
8
+ ## [1.0.0] - 2017-04-7
9
+ ### Added
10
+ - Remove dependency on `Loofah` while maintaining basic `nocomment` transform
11
+
8
12
  ## [0.12.1] - 2017-03-24
9
13
  ### Added
10
14
  - Relax dependency on `Nokogiri` to allow users to upgrade to v1.7x, preventing
@@ -136,7 +140,8 @@ transformations](https://github.com/jamesmartin/inline_svg/blob/master/README.md
136
140
  ### Added
137
141
  - Basic Railtie and view helper to inline SVG documents to Rails views.
138
142
 
139
- [unreleased]: https://github.com/jamesmartin/inline_svg/compare/v0.12.1...HEAD
143
+ [unreleased]: https://github.com/jamesmartin/inline_svg/compare/v1.0.0...HEAD
144
+ [1.0.0]: https://github.com/jamesmartin/inline_svg/compare/v0.12.1...v1.0.0
140
145
  [0.12.1]: https://github.com/jamesmartin/inline_svg/compare/v0.12.0...v0.12.1
141
146
  [0.12.0]: https://github.com/jamesmartin/inline_svg/compare/v0.11.1...v0.12.0
142
147
  [0.11.1]: https://github.com/jamesmartin/inline_svg/compare/v0.11.0...v0.11.1
data/README.md CHANGED
@@ -4,13 +4,11 @@ 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 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
7
+ 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
8
8
  then embeds it into a view.
9
9
 
10
10
  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)).
11
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
-
14
12
  ## Changelog
15
13
 
16
14
  This project adheres to [Semantic Versioning](http://semver.org). All notable changes are documented in the
@@ -76,10 +74,10 @@ key | description
76
74
  `id` | set a ID attribute on the SVG
77
75
  `class` | set a CSS class attribute on the SVG
78
76
  `data` | add data attributes to the SVG (supply as a hash)
79
- `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%"`
77
+ `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%"`
80
78
  `title` | add a \<title\> node inside the top level of the SVG document
81
79
  `desc` | add a \<desc\> node inside the top level of the SVG document
82
- `nocomment` | remove comment tags (and other unsafe/unknown tags) from svg (uses the [Loofah](https://github.com/flavorjones/loofah) gem)
80
+ `nocomment` | remove comment tags from the SVG document
83
81
  `preserve_aspect_ratio` | adds a `preserveAspectRatio` attribute to the SVG
84
82
  `aria` | adds common accessibility attributes to the SVG (see [PR #34](https://github.com/jamesmartin/inline_svg/pull/34#issue-152062674) for details)
85
83
 
@@ -26,5 +26,4 @@ Gem::Specification.new do |spec|
26
26
 
27
27
  spec.add_runtime_dependency "activesupport", ">= 3.0"
28
28
  spec.add_runtime_dependency "nokogiri", ">= 1.6"
29
- spec.add_runtime_dependency "loofah", ">= 2.0"
30
29
  end
@@ -10,6 +10,5 @@ module InlineSvg
10
10
  end
11
11
 
12
12
  require 'nokogiri'
13
- require 'loofah'
14
13
  require 'inline_svg/id_generator'
15
14
  require 'inline_svg/transform_pipeline/transformations'
@@ -2,8 +2,11 @@ module InlineSvg::TransformPipeline
2
2
  module Transformations
3
3
  class NoComment < Transformation
4
4
  def transform(doc)
5
- doc = Loofah::HTML::DocumentFragment.parse(doc.to_html)
6
- doc.scrub!(:strip)
5
+ doc = Nokogiri::XML::Document.parse(doc.to_html)
6
+ doc.xpath("//comment()").each do |comment|
7
+ comment.remove
8
+ end
9
+ doc
7
10
  end
8
11
  end
9
12
  end
@@ -1,3 +1,3 @@
1
1
  module InlineSvg
2
- VERSION = "0.12.1"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -41,7 +41,7 @@ describe InlineSvg::ActionView::Helpers do
41
41
  context "and no options" do
42
42
  it "returns a html safe version of the file's contents" do
43
43
  example_file = <<-SVG
44
- <svg xmlns="http://www.w3.org/2000/svg" role="presentation" xml:lang="en"><!-- This is a comment --></svg>
44
+ <svg xmlns="http://www.w3.org/2000/svg" xml:lang="en"><!-- This is a comment --></svg>
45
45
  SVG
46
46
  allow(InlineSvg::AssetFile).to receive(:named).with('some-file').and_return(example_file)
47
47
  expect(helper.inline_svg('some-file')).to eq example_file
@@ -77,7 +77,7 @@ SVG
77
77
  context "and the 'nocomment' option" do
78
78
  it "strips comments and other unknown/unsafe nodes from the output" do
79
79
  input_svg = <<-SVG
80
- <svg xmlns="http://www.w3.org/2000/svg" role="presentation" xml:lang="en"><!-- This is a comment --></svg>
80
+ <svg xmlns="http://www.w3.org/2000/svg" xml:lang="en"><!-- This is a comment --></svg>
81
81
  SVG
82
82
  expected_output = <<-SVG
83
83
  <svg xmlns="http://www.w3.org/2000/svg" xml:lang="en"></svg>
@@ -90,11 +90,10 @@ SVG
90
90
  context "and all options" do
91
91
  it "applies all expected transformations to the output" do
92
92
  input_svg = <<-SVG
93
- <svg xmlns="http://www.w3.org/2000/svg" role="presentation" xml:lang="en"><!-- This is a comment --></svg>
93
+ <svg xmlns="http://www.w3.org/2000/svg" xml:lang="en"><!-- This is a comment --></svg>
94
94
  SVG
95
95
  expected_output = <<-SVG
96
- <svg xmlns="http://www.w3.org/2000/svg" xml:lang="en"><title>A title</title>
97
- <desc>A description</desc></svg>
96
+ <svg xmlns="http://www.w3.org/2000/svg" xml:lang="en"><title>A title</title><desc>A description</desc></svg>
98
97
  SVG
99
98
  allow(InlineSvg::AssetFile).to receive(:named).with('some-file').and_return(input_svg)
100
99
  expect(helper.inline_svg('some-file', title: 'A title', desc: 'A description', nocomment: true)).to eq expected_output
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.12.1
4
+ version: 1.0.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-03-23 00:00:00.000000000 Z
11
+ date: 2017-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -108,20 +108,6 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '1.6'
111
- - !ruby/object:Gem::Dependency
112
- name: loofah
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '2.0'
118
- type: :runtime
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '2.0'
125
111
  description: Get an SVG into your view and then style it with CSS.
126
112
  email:
127
113
  - inline_svg@jmrtn.com