victor 0.3.3 → 0.3.4
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 +19 -0
- data/lib/victor/svg_base.rb +12 -11
- data/lib/victor/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f308143350a9236bbdf1c046de94a94728ecd90051004482e78cf9734484ef6
|
4
|
+
data.tar.gz: 36b35af10ea11a1bc39063384c6a23e247c257d0364edb24b5914cfd73029a88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 353fd957d007ad7dd020f84a8866634a799e39ae94ba2ea65edf4eb09b6e8a354aa09961492a6cac0a530bcee5e904738df13bffc68c3b00f983348844adc074
|
7
|
+
data.tar.gz: 3993f70f671cb4097e83279bc4b5b68d510aa74a40ae320960d56b4a6b1aa537270893975c473cbf66a263496cea39398cd742b217af6b327b595edef84ea36b
|
data/README.md
CHANGED
@@ -27,6 +27,7 @@ directly to SVG elements.
|
|
27
27
|
* [CSS](#css)
|
28
28
|
* [Tagless Elements](#tagless-elements)
|
29
29
|
* [XML Encoding](#xml-encoding)
|
30
|
+
* [XML Newlines](#xml-newlines)
|
30
31
|
* [DSL Syntax](#dsl-syntax)
|
31
32
|
* [Using with Rails](#using-with-rails)
|
32
33
|
* [Related Projects](#related-projects)
|
@@ -431,6 +432,24 @@ end
|
|
431
432
|
|
432
433
|
See the [xml encoding example](https://github.com/DannyBen/victor/tree/master/examples#18-xml-encoding).
|
433
434
|
|
435
|
+
|
436
|
+
### XML Newlines
|
437
|
+
|
438
|
+
By default, the generated SVGs will have a newline glue between the elements.
|
439
|
+
You can change this (for example, to an empty string) if the default newlines
|
440
|
+
are not appropriate for your use case.
|
441
|
+
|
442
|
+
```ruby
|
443
|
+
svg = Victor::SVG.new glue: ''
|
444
|
+
```
|
445
|
+
|
446
|
+
The glue can also be provided when rendering or saving the output:
|
447
|
+
|
448
|
+
```ruby
|
449
|
+
svg.save 'filename', glue: ''
|
450
|
+
svg.render glue: ''
|
451
|
+
```
|
452
|
+
|
434
453
|
### DSL Syntax
|
435
454
|
|
436
455
|
Victor also supports a DSL-like syntax. To use it, simply `require 'victor/script'`.
|
data/lib/victor/svg_base.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Victor
|
2
2
|
|
3
3
|
class SVGBase
|
4
|
-
attr_accessor :template
|
4
|
+
attr_accessor :template, :glue
|
5
5
|
attr_reader :content, :svg_attributes
|
6
6
|
|
7
7
|
def initialize(attributes = nil, &block)
|
@@ -20,11 +20,11 @@ module Victor
|
|
20
20
|
attributes[:width] ||= "100%"
|
21
21
|
attributes[:height] ||= "100%"
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
@template = attributes[:template] || @template || :default
|
24
|
+
@glue = attributes[:glue] || @glue || "\n"
|
25
|
+
|
26
|
+
attributes.delete :template
|
27
|
+
attributes.delete :glue
|
28
28
|
|
29
29
|
@svg_attributes = Attributes.new attributes
|
30
30
|
end
|
@@ -72,25 +72,26 @@ module Victor
|
|
72
72
|
@css = defs
|
73
73
|
end
|
74
74
|
|
75
|
-
def render(template: nil)
|
75
|
+
def render(template: nil, glue: nil)
|
76
76
|
@template = template if template
|
77
|
+
@glue = glue if glue
|
77
78
|
css_handler = CSS.new css
|
78
79
|
|
79
80
|
svg_template % {
|
80
81
|
css: css_handler,
|
81
82
|
style: css_handler.render,
|
82
83
|
attributes: svg_attributes,
|
83
|
-
content:
|
84
|
+
content: to_s
|
84
85
|
}
|
85
86
|
end
|
86
87
|
|
87
88
|
def to_s
|
88
|
-
content.join
|
89
|
+
content.join glue
|
89
90
|
end
|
90
91
|
|
91
|
-
def save(filename, template: nil)
|
92
|
+
def save(filename, template: nil, glue: nil)
|
92
93
|
filename = "#{filename}.svg" unless filename =~ /\..{2,4}$/
|
93
|
-
File.write filename, render(template: template)
|
94
|
+
File.write filename, render(template: template, glue: glue)
|
94
95
|
end
|
95
96
|
|
96
97
|
protected
|
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.3.
|
4
|
+
version: 0.3.4
|
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:
|
11
|
+
date: 2022-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Build SVG images with ease
|
14
14
|
email: db@dannyben.com
|
@@ -40,14 +40,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 2.
|
43
|
+
version: 2.6.0
|
44
44
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
requirements: []
|
50
|
-
rubygems_version: 3.
|
50
|
+
rubygems_version: 3.3.14
|
51
51
|
signing_key:
|
52
52
|
specification_version: 4
|
53
53
|
summary: SVG Builder
|