svgle 0.4.2 → 0.4.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +2 -2
  4. data/lib/svgle.rb +73 -61
  5. metadata +31 -28
  6. metadata.gz.sig +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 0035b7a329d0266d7835eb7abb684e63f4059388
4
- data.tar.gz: c118282a95b4e8be45cedb0b911ebfc29e75eba9
2
+ SHA256:
3
+ metadata.gz: 4e75a2b4aa745a539a340cc99365feb7f225068856f1ae47326e5da19a4d3176
4
+ data.tar.gz: 1dc30b3366df5b9bf7d6f0fca5bddaf37a6b683245e8366b051eeaa7f45993a2
5
5
  SHA512:
6
- metadata.gz: 9740c63b294f97e323630499930c2cfb49ae506b8da931d14d50ebb0aec34805d010b2ad0d18b142014381f2ce43813f783ee6478b27e41f5c60d0f4e79babfc
7
- data.tar.gz: 47a2a349c85171a7b24e20236351931082e231452d8bee3c02dc76e93d768b50d4ff6d19f625a02f9c42bf64d971055114def226d08f00736ee92760556560a1
6
+ metadata.gz: 9a08e9a791925659dce44744b13226b28c4c709dba7eebd0c4acfcd9b5d011725ee3e356e168b653951393ad511e6618aeae17b8503fc52a73cfb819d7ebbac5
7
+ data.tar.gz: deea6aaa44eb88b97047de85e1d3c8c709850c6ff6deec9965daed0dc299584b4d45abbbb8f5d1136833c1648df17bf626490b2ead3bb7f0797ef9ebc64fdc15
Binary file
data.tar.gz.sig CHANGED
@@ -1,2 +1,2 @@
1
- 0���q��oU��Y*�ź���GPd9�ƭ
2
- ��I'��?N��̣)�L"����_���d�"�a\��!S0�S�*cC�2�v���5277t"�]�:��! U���Y��.�� �q�{y��:*$��� w���v'6.���l���.?���fmH�Pӗ���������}�q��5ά�8by^s�볖ekqQX���\���A� ycx��a�H�t
1
+ C=mu� iN�E^���y܇��r�G/�a��qw^IJn�:� s��Z���/������2׿!\]A~ӵ3{��5zr(�2{�j^�:y�Ȅ?���o2��S�:<�n�
2
+ ��W$���a$���UC��'��S���<�ǒ��T���pR������!~x u:�QgUG��f�?���.�
@@ -16,8 +16,9 @@ require 'domle'
16
16
  # http://stackoverflow.com/questions/7946187/point-and-ellipse-rotated-position-test-algorithm
17
17
  # computational geometry - ruby http://sourceforge.net/projects/ruby-comp-geom/
18
18
 
19
- DEFAULT_CSS = <<CSS
19
+ DEFAULT_SVGLE_CSS = <<CSS
20
20
 
21
+ g {background-color: orange}
21
22
  svg {background-color: white}
22
23
  rect {fill: yellow}
23
24
  line, polyline {stroke: green; stroke-width: 3}
@@ -28,36 +29,50 @@ CSS
28
29
 
29
30
 
30
31
  class Svgle < Domle
32
+
33
+
34
+ class SvgElement < Element
35
+
36
+ @attr_map = {}
37
+ attr_reader :attr_map
38
+
39
+ attr2_accessor *%i(stroke stroke-width)
40
+
41
+
42
+ end
31
43
 
44
+ class Shape < SvgElement
45
+ attr2_accessor *%i(fill)
46
+ end
32
47
 
33
- class A < Element
48
+ class A < SvgElement
34
49
  # undecided how to implement this
35
50
  # see http://stackoverflow.com/questions/12422668/getting-xlinkhref-attribute-of-the-svg-image-element-dynamically-using-js-i
36
51
  #attr2_accessor *%i(href)
37
52
  end
38
53
 
39
- class Circle < Element
40
- attr2_accessor *%i(cx cy r stroke stroke-width)
54
+ class Circle < Shape
55
+ attr2_accessor *%i(cx cy r)
41
56
  def boundary()
42
57
  [0,0,0,0]
43
58
  end
44
59
  end
45
60
 
46
- class Ellipse < Element
61
+ class Ellipse < Shape
47
62
  attr2_accessor *%i(cx cy rx ry)
48
63
  def boundary()
49
64
  [0,0,0,0]
50
65
  end
51
66
  end
52
67
 
53
- class G < Element
68
+ class G < SvgElement
54
69
  attr2_accessor *%i(fill opacity)
55
70
  def boundary()
56
71
  [0,0,0,0]
57
72
  end
58
73
  end
59
74
 
60
- class Line < Element
75
+ class Line < SvgElement
61
76
  attr2_accessor *%i(x1 y1 x2 y2)
62
77
 
63
78
  def boundary()
@@ -65,7 +80,7 @@ class Svgle < Domle
65
80
  end
66
81
  end
67
82
 
68
- class Image < Element
83
+ class Image < SvgElement
69
84
 
70
85
  attr2_accessor *%i(x y width height xlink:href src)
71
86
 
@@ -79,10 +94,9 @@ class Svgle < Domle
79
94
  @src = s
80
95
 
81
96
  self.attributes[:'xlink:href'] = if s =~ /^http/ then
82
-
83
- r, _ = RXFHelper.read(s)
84
- filepath = '/tmp/' + File.basename(s)
85
- File.write filepath, r
97
+
98
+ filepath = Tempfile.new('svgle').path + File.basename(s)
99
+ File.write filepath, RXFHelper.read(s).first
86
100
 
87
101
  filepath
88
102
 
@@ -94,30 +108,30 @@ class Svgle < Domle
94
108
 
95
109
  end
96
110
 
97
- class Path < Element
98
- attr2_accessor *%i(d stroke stroke-width fill)
111
+ class Path < Shape
112
+ attr2_accessor *%i(d)
99
113
  def boundary()
100
114
  [0,0,0,0]
101
115
  end
102
116
  end
103
117
 
104
- class Polygon < Element
118
+ class Polygon < Shape
105
119
  attr2_accessor *%i(points)
106
120
  def boundary()
107
121
  [0,0,0,0]
108
122
  end
109
123
  end
110
124
 
111
- class Polyline < Element
125
+ class Polyline < Shape
112
126
  attr2_accessor *%i(points)
113
127
  def boundary()
114
128
  [0,0,0,0]
115
129
  end
116
130
  end
117
131
 
118
- class Rect < Element
132
+ class Rect < Shape
119
133
 
120
- attr2_accessor *%i(x y width height rx ry)
134
+ attr2_accessor *%i(x y rx ry)
121
135
 
122
136
  def boundary()
123
137
  x1, y1, w, h = [x, y, width, height].map(&:to_i)
@@ -126,71 +140,69 @@ class Svgle < Domle
126
140
 
127
141
  end
128
142
 
129
- class Svg < Element
143
+ class Svg < SvgElement
130
144
  attr2_accessor *%i(width height background-color)
131
145
  def boundary()
132
146
  [0,0,0,0]
133
147
  end
134
148
  end
149
+
135
150
 
136
- class Text < Element
151
+ class Text < SvgElement
152
+
137
153
  attr2_accessor *%i(x y fill)
154
+
138
155
  def boundary()
139
156
  [0,0,0,0]
140
157
  end
158
+
159
+ def text=(raw_s)
160
+
161
+ oldval = @child_elements.first
162
+
163
+ r = super(raw_s)
164
+ @obj.text = raw_s if oldval != raw_s
165
+
166
+ return r
167
+
168
+ end
141
169
  end
142
170
 
171
+ def initialize(src='<svg/>', callback: nil, rexle: self, debug: false)
172
+ super(src, callback: callback, rexle: rexle, debug: debug)
173
+ end
174
+
143
175
  def inspect()
144
176
  "#<Svgle:%s>" % [self.object_id]
145
177
  end
146
178
 
147
179
 
148
- private
149
-
150
- def find_add_css()
151
-
152
- # add the default CSS
153
-
154
- add_css DEFAULT_CSS
155
-
156
-
157
- @doc.root.xpath('//style').each {|e| add_css e.text }
158
-
159
- # check for an external CSS file
160
- if @instructions and @instructions.any? then
161
-
162
- hrefs = @instructions.inject([]) do |r,x|
163
-
164
- if x[0] =~ /xml-stylesheet/i and x[1] =~ /text\/css/i then
165
-
166
- r << x[1][/href\s*=\s*["']([^'"]+)/,1]
167
- else
168
- r
169
- end
170
- end
171
-
172
- add_css hrefs.map{|x| RXFHelper.read(x).first}.join
173
-
174
- end
180
+ protected
181
+
182
+ def add_default_css()
183
+ add_css Object.const_get self.class.to_s + '::' + 'DEFAULT_' +
184
+ self.class.to_s.upcase + '_CSS'
185
+ add_inline_css()
186
+ end
175
187
 
176
- end
188
+ private
177
189
 
178
190
  def defined_elements()
179
191
  {
180
- circle: Svgle::Circle,
181
- ellipse: Svgle::Ellipse,
182
- line: Svgle::Line,
183
- g: Svgle::G,
184
- image: Svgle::Image,
185
- svg: Svgle::Svg,
186
- script: Svgle::Script,
187
- style: Svgle::Style,
192
+ circle: Circle,
193
+ ellipse: Ellipse,
194
+ line: Line,
195
+ g: G,
196
+ image: Image,
197
+ svg: Svg,
198
+ script: Script,
199
+ style: Style,
188
200
  doc: Rexle::Element,
189
- polygon: Svgle::Polygon,
190
- polyline: Svgle::Polyline,
191
- path: Svgle::Path,
192
- rect: Svgle::Rect,
193
- text: Svgle::Text
201
+ polygon: Polygon,
202
+ polyline: Polyline,
203
+ path: Path,
204
+ rect: Rect,
205
+ text: Text
194
206
  }
195
207
  end
196
208
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svgle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -10,28 +10,32 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
- YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
- 8ixkARkWAmV1MB4XDTE3MDEyNjE4MjgwM1oXDTE4MDEyNjE4MjgwM1owSDESMBAG
16
- A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
- EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
- ggEBAPLlRY/KPKxHmV0CFzZjZGKnLesqubDIqf3cUET+1RUeMKzJsPw/7XTH5Fac
19
- mxe5+vUWIOSpfbluPJYHgHwOoVZXwwOV/mzGVkVnfTL+AuHqZtlkRWPXDZ//Xhul
20
- JgcN0iTiQU5wf6gJDdJeoc36K0RqbFCgA+9Q1M3IU3i8zAHlO3VWmRakqmqR+/9S
21
- kVs2htCGqgKnKA45KJdIAiYTYEdOZ5BqqrRReDVF1O7VUhcfrf+BPkjGswP1mDxd
22
- 6XjjGROHLf46FBlip3pAa0vOUOT1OAc/yD4Gamqi5cR2vq3E4U8bXjGIrRUtkirG
23
- wsSQdURVWS67Mv/AYo6iU13T2u0CAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
24
- DwQEAwIEsDAdBgNVHQ4EFgQUiMCQNsTPK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36
+ qG+QACUIuvQdA+C3SKv19pE2
33
37
  -----END CERTIFICATE-----
34
- date: 2017-01-26 00:00:00.000000000 Z
38
+ date: 2020-06-07 00:00:00.000000000 Z
35
39
  dependencies:
36
40
  - !ruby/object:Gem::Dependency
37
41
  name: domle
@@ -39,20 +43,20 @@ dependencies:
39
43
  requirements:
40
44
  - - "~>"
41
45
  - !ruby/object:Gem::Version
42
- version: '0.1'
46
+ version: '0.2'
43
47
  - - ">="
44
48
  - !ruby/object:Gem::Version
45
- version: 0.1.0
49
+ version: 0.2.1
46
50
  type: :runtime
47
51
  prerelease: false
48
52
  version_requirements: !ruby/object:Gem::Requirement
49
53
  requirements:
50
54
  - - "~>"
51
55
  - !ruby/object:Gem::Version
52
- version: '0.1'
56
+ version: '0.2'
53
57
  - - ">="
54
58
  - !ruby/object:Gem::Version
55
- version: 0.1.0
59
+ version: 0.2.1
56
60
  description:
57
61
  email: james@jamesrobertson.eu
58
62
  executables: []
@@ -79,8 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
83
  - !ruby/object:Gem::Version
80
84
  version: '0'
81
85
  requirements: []
82
- rubyforge_project:
83
- rubygems_version: 2.6.8
86
+ rubygems_version: 3.0.3
84
87
  signing_key:
85
88
  specification_version: 4
86
89
  summary: Svgle (SVG + Domle) generates an SVG Document Object Model from the given
metadata.gz.sig CHANGED
@@ -1,2 +1,2 @@
1
- ��n��N�>o ��M}o��fJZ����N;Q�|[hc��Z���j��M��;��
2
- ee(š���,?odkYTW��@��b}�wlf�����~�Xd ��U��,����bI63!*/������������F�IK
1
+ �}z��X���hcg�j{|ӯ"��j&[� ٘�]�">�)��?��I�+:���Y"��dqf�[-D:���%A��kߧ"�����RI�%��YuޟT��Qr�8�9�{�-�rU�Űau�q�H��?[y�����?��0��G�/t�5�әL���}8�Ƹ�~����h�θ�)�b&S"���e���.']\�߇�k�f^�ãw�� 5�N#���I/R�~�q��M,@�W���uH������e���v`�0 ��1
2
+ �߰�$�v�&�]3y��-����.d"�t���pz)12@X�W\��XS�o�d������ZZ�@�0Ƹ�&J}�K3�ju$�=��!s ̛�OE�Gy l—#�9?�cn���5!+n