victor 0.2.7 → 0.2.8
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.
- checksums.yaml +4 -4
- data/README.md +26 -0
- data/lib/victor/svg_base.rb +12 -1
- data/lib/victor/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b819817dc11fa725b667d3aadd3eb3a66dc2b7ab9f270fc33fda29ef93c46a86
|
4
|
+
data.tar.gz: ab063e0c9fb41c7d87ab0b18cb397b509b7a43bc441cf10649997ede67c52942
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 723688dd6bdd524fe2576218a6e634a7aecc6a7b44c59368f6cfa631a7eb6a032ab6974c7a45353baf911152a19e6be2347de93ea4740b66610f32e9a05e6f71
|
7
|
+
data.tar.gz: 3a8f921fc4475b882a6626009acd6cb13322180e305e8f1e16a47654d4f6125ae33870fa161aaa8da0ad40756d8823355dc94ae0961e46b26ff98383bd4341fb
|
data/README.md
CHANGED
@@ -28,6 +28,7 @@ Table of Contents
|
|
28
28
|
* [SVG Templates](#svg-templates)
|
29
29
|
* [CSS](#css)
|
30
30
|
* [Tagless Elements](#tagless-elements)
|
31
|
+
* [XML Encoding](#xml-encoding)
|
31
32
|
* [Using with Rails](#using-with-rails)
|
32
33
|
* [Related Projects](#related-projects)
|
33
34
|
|
@@ -350,6 +351,31 @@ end
|
|
350
351
|
See the [targless elements example](https://github.com/DannyBen/victor/tree/master/examples#16-tagless-elements).
|
351
352
|
|
352
353
|
|
354
|
+
XML Encoding
|
355
|
+
--------------------------------------------------
|
356
|
+
|
357
|
+
Plain text values are encoded automatically:
|
358
|
+
|
359
|
+
```ruby
|
360
|
+
svg.build do
|
361
|
+
text "Ben & Jerry's"
|
362
|
+
end
|
363
|
+
# <text>Ben & Jerry's</text>
|
364
|
+
```
|
365
|
+
|
366
|
+
If you need to use the raw, unencoded string, add `!` to the element's name:
|
367
|
+
|
368
|
+
```ruby
|
369
|
+
svg.build do
|
370
|
+
text! "Ben & Jerry's"
|
371
|
+
end
|
372
|
+
# <text>Ben & Jerry's</text>
|
373
|
+
```
|
374
|
+
|
375
|
+
See the [xml encoding example](https://github.com/DannyBen/victor/tree/master/examples#17-xml-encoding).
|
376
|
+
|
377
|
+
|
378
|
+
|
353
379
|
Using with Rails
|
354
380
|
--------------------------------------------------
|
355
381
|
|
data/lib/victor/svg_base.rb
CHANGED
@@ -28,12 +28,23 @@ module Victor
|
|
28
28
|
value = nil
|
29
29
|
end
|
30
30
|
|
31
|
+
escape = true
|
32
|
+
|
33
|
+
if name.to_s.end_with? '!'
|
34
|
+
escape = false
|
35
|
+
name = name[0..-2]
|
36
|
+
end
|
37
|
+
|
31
38
|
attributes = Attributes.new attributes
|
32
39
|
empty_tag = name.to_s == '_'
|
33
40
|
|
34
41
|
if block_given? || value
|
35
42
|
content.push "<#{name} #{attributes}".strip + ">" unless empty_tag
|
36
|
-
|
43
|
+
if value
|
44
|
+
content.push(escape ? value.to_s.encode(xml: :text) : value)
|
45
|
+
else
|
46
|
+
yield
|
47
|
+
end
|
37
48
|
content.push "</#{name}>" unless empty_tag
|
38
49
|
else
|
39
50
|
content.push "<#{name} #{attributes}/>"
|
data/lib/victor/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: victor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Build SVG images with ease
|
14
14
|
email: db@dannyben.com
|
@@ -45,7 +45,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0'
|
47
47
|
requirements: []
|
48
|
-
rubygems_version: 3.0.
|
48
|
+
rubygems_version: 3.0.4
|
49
49
|
signing_key:
|
50
50
|
specification_version: 4
|
51
51
|
summary: SVG Builder
|