inline_svg 0.11.0 → 0.11.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7fb6e64ae5311883892613c4a6b3eebf128961b6
4
- data.tar.gz: 40f3eb0a9198ff40838f3df4fe93937a3ef1dd9c
3
+ metadata.gz: 03af7d5bbffb013be526892939230f59115d147f
4
+ data.tar.gz: 5ec5c3bf3efd03be4b65940e91e42677b61e0222
5
5
  SHA512:
6
- metadata.gz: 2a6d3430898827a14e0b34dfe018efe8f99991dd7362f758e63973e75d577d7cb6116ee8cb981a1534dfd7283fd170e9bbef36ad13325f7fc482423c86de0314
7
- data.tar.gz: 126adaf50a5d41ea9225c3497cf2df7ee20c231caf33f653773ddc03d8cb5b2c32bf51248ac5bbd1cff9e19ca494422cccfadf7136530d08826b71e74d9cc17b
6
+ metadata.gz: 9b2ac5b8b8c784642822510229dbe42c9ede8a48824c7f357bed960e106a1439b5ae30060ccaecf198379e5a87bef0b9e2b40c7f233925ca4fc6b63e15b86626
7
+ data.tar.gz: 804cf57efaaee53e5de5b85c97330c56f17d7cbf5c73e46b2b7cad41d700747201e687c09dbe2158f65dcd374ac8e90264856ed05500884577b4ea21c594ef95
@@ -5,6 +5,13 @@ This project adheres to [Semantic Versioning](http://semver.org/).
5
5
  ## [Unreleased][unreleased]
6
6
  - Nothing
7
7
 
8
+ ## [0.11.1] - 2016-11-22
9
+ ### Fixed
10
+ - Dasherize data attribute names:
11
+ [#51](https://github.com/jamesmartin/inline_svg/issues/51)
12
+ - Prevent ID collisions between `desc` and `title` attrs:
13
+ [#52](https://github.com/jamesmartin/inline_svg/pull/52)
14
+
8
15
  ## [0.11.0] - 2016-07-24
9
16
  ### Added
10
17
  - Priority ordering for transformations
@@ -117,7 +124,8 @@ transformations](https://github.com/jamesmartin/inline_svg/blob/master/README.md
117
124
  ### Added
118
125
  - Basic Railtie and view helper to inline SVG documents to Rails views.
119
126
 
120
- [unreleased]: https://github.com/jamesmartin/inline_svg/compare/v0.11.0...HEAD
127
+ [unreleased]: https://github.com/jamesmartin/inline_svg/compare/v0.11.1...HEAD
128
+ [0.11.1]: https://github.com/jamesmartin/inline_svg/compare/v0.11.0...v0.11.1
121
129
  [0.11.0]: https://github.com/jamesmartin/inline_svg/compare/v0.10.0...v0.11.0
122
130
  [0.10.0]: https://github.com/jamesmartin/inline_svg/compare/v0.9.1...v0.10.0
123
131
  [0.9.1]: https://github.com/jamesmartin/inline_svg/compare/v0.9.0...v0.9.1
data/README.md CHANGED
@@ -13,7 +13,7 @@ Want to embed SVGs with Javascript? You might like [RemoteSvg](https://github.co
13
13
 
14
14
  ## Changelog
15
15
 
16
- This project adheres to [Semantic Versioning](http://sermver.org). All notable changes are documented in the
16
+ This project adheres to [Semantic Versioning](http://semver.org). All notable changes are documented in the
17
17
  [CHANGELOG](https://github.com/jamesmartin/inline_svg/blob/master/CHANGELOG.md).
18
18
 
19
19
  ## Installation
@@ -26,9 +26,9 @@ module InlineSvg::TransformPipeline::Transformations
26
26
 
27
27
  def element_id_for(base, element)
28
28
  if element['id'].nil?
29
- InlineSvg::IdGenerator.generate(base, value)
29
+ InlineSvg::IdGenerator.generate(base, element.text)
30
30
  else
31
- InlineSvg::IdGenerator.generate(element['id'], value)
31
+ InlineSvg::IdGenerator.generate(element['id'], element.text)
32
32
  end
33
33
  end
34
34
  end
@@ -4,13 +4,19 @@ module InlineSvg::TransformPipeline::Transformations
4
4
  doc = Nokogiri::XML::Document.parse(doc.to_html)
5
5
  svg = doc.at_css 'svg'
6
6
  with_valid_hash_from(self.value).each_pair do |name, data|
7
- svg["data-#{name}"] = data
7
+ svg["data-#{dasherize(name)}"] = data
8
8
  end
9
9
  doc
10
10
  end
11
11
 
12
+ private
13
+
12
14
  def with_valid_hash_from(hash)
13
15
  Hash.try_convert(hash) || {}
14
16
  end
17
+
18
+ def dasherize(string)
19
+ string.to_s.gsub(/_/, "-")
20
+ end
15
21
  end
16
22
  end
@@ -1,3 +1,3 @@
1
1
  module InlineSvg
2
- VERSION = "0.11.0"
2
+ VERSION = "0.11.1"
3
3
  end
@@ -13,9 +13,9 @@ describe InlineSvg::TransformPipeline::Transformations::AriaAttributes do
13
13
  context "aria-labelledby attribute" do
14
14
  it "adds 'title' when a title element is present" do
15
15
  document = Nokogiri::XML::Document.parse('<svg><title>Some title</title>Some document</svg>')
16
- transformation = InlineSvg::TransformPipeline::Transformations::AriaAttributes.create_with_value("some-salt")
16
+ transformation = InlineSvg::TransformPipeline::Transformations::AriaAttributes.create_with_value(true)
17
17
 
18
- expect(InlineSvg::IdGenerator).to receive(:generate).with("title", "some-salt").
18
+ expect(InlineSvg::IdGenerator).to receive(:generate).with("title", "Some title").
19
19
  and_return("some-id")
20
20
 
21
21
  expect(transformation.transform(document).to_html).to eq(
@@ -25,9 +25,9 @@ describe InlineSvg::TransformPipeline::Transformations::AriaAttributes do
25
25
 
26
26
  it "adds 'desc' when a description element is present" do
27
27
  document = Nokogiri::XML::Document.parse('<svg><desc>Some description</desc>Some document</svg>')
28
- transformation = InlineSvg::TransformPipeline::Transformations::AriaAttributes.create_with_value("some-salt")
28
+ transformation = InlineSvg::TransformPipeline::Transformations::AriaAttributes.create_with_value(true)
29
29
 
30
- expect(InlineSvg::IdGenerator).to receive(:generate).with("desc", "some-salt").
30
+ expect(InlineSvg::IdGenerator).to receive(:generate).with("desc", "Some description").
31
31
  and_return("some-id")
32
32
 
33
33
  expect(transformation.transform(document).to_html).to eq(
@@ -37,11 +37,11 @@ describe InlineSvg::TransformPipeline::Transformations::AriaAttributes do
37
37
 
38
38
  it "adds both 'desc' and 'title' when title and description elements are present" do
39
39
  document = Nokogiri::XML::Document.parse('<svg><title>Some title</title><desc>Some description</desc>Some document</svg>')
40
- transformation = InlineSvg::TransformPipeline::Transformations::AriaAttributes.create_with_value("some-salt")
40
+ transformation = InlineSvg::TransformPipeline::Transformations::AriaAttributes.create_with_value(true)
41
41
 
42
- expect(InlineSvg::IdGenerator).to receive(:generate).with("title", "some-salt").
42
+ expect(InlineSvg::IdGenerator).to receive(:generate).with("title", "Some title").
43
43
  and_return("some-id")
44
- expect(InlineSvg::IdGenerator).to receive(:generate).with("desc", "some-salt").
44
+ expect(InlineSvg::IdGenerator).to receive(:generate).with("desc", "Some description").
45
45
  and_return("some-other-id")
46
46
 
47
47
  expect(transformation.transform(document).to_html).to eq(
@@ -51,11 +51,11 @@ describe InlineSvg::TransformPipeline::Transformations::AriaAttributes do
51
51
 
52
52
  it "uses existing IDs when they exist" do
53
53
  document = Nokogiri::XML::Document.parse('<svg><title id="my-title">Some title</title><desc id="my-desc">Some description</desc>Some document</svg>')
54
- transformation = InlineSvg::TransformPipeline::Transformations::AriaAttributes.create_with_value("some-salt")
54
+ transformation = InlineSvg::TransformPipeline::Transformations::AriaAttributes.create_with_value(true)
55
55
 
56
- expect(InlineSvg::IdGenerator).to receive(:generate).with("my-title", "some-salt").
56
+ expect(InlineSvg::IdGenerator).to receive(:generate).with("my-title", "Some title").
57
57
  and_return("some-id")
58
- expect(InlineSvg::IdGenerator).to receive(:generate).with("my-desc", "some-salt").
58
+ expect(InlineSvg::IdGenerator).to receive(:generate).with("my-desc", "Some description").
59
59
  and_return("some-other-id")
60
60
 
61
61
  expect(transformation.transform(document).to_html).to eq(
@@ -10,6 +10,24 @@ describe InlineSvg::TransformPipeline::Transformations::DataAttributes do
10
10
  )
11
11
  end
12
12
 
13
+ it "dasherizes the data attribute name" do
14
+ document = Nokogiri::XML::Document.parse('<svg>Some document</svg>')
15
+ transformation = InlineSvg::TransformPipeline::Transformations::DataAttributes.create_with_value({some_name: "value"})
16
+
17
+ expect(transformation.transform(document).to_html).to eq(
18
+ "<svg data-some-name=\"value\">Some document</svg>\n"
19
+ )
20
+ end
21
+
22
+ it "dasherizes a data attribute name with multiple parts" do
23
+ document = Nokogiri::XML::Document.parse('<svg>Some document</svg>')
24
+ transformation = InlineSvg::TransformPipeline::Transformations::DataAttributes.create_with_value({some_other_name: "value"})
25
+
26
+ expect(transformation.transform(document).to_html).to eq(
27
+ "<svg data-some-other-name=\"value\">Some document</svg>\n"
28
+ )
29
+ end
30
+
13
31
  context "when multiple data attributes are supplied" do
14
32
  it "adds data attributes to the SVG for each supplied value" do
15
33
  document = Nokogiri::XML::Document.parse('<svg>Some document</svg>')
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.11.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Martin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-01 00:00:00.000000000 Z
11
+ date: 2016-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler