sevgi 0.0.0

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.
Files changed (82) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +9 -0
  3. data/LICENSE +674 -0
  4. data/README.md +15 -0
  5. data/bin/sevgi +136 -0
  6. data/lib/sevgi/errors.rb +11 -0
  7. data/lib/sevgi/external.rb +8 -0
  8. data/lib/sevgi/function.rb +35 -0
  9. data/lib/sevgi/geometry/elements/rect.rb +133 -0
  10. data/lib/sevgi/geometry/elements/segment.rb +102 -0
  11. data/lib/sevgi/geometry/elements.rb +41 -0
  12. data/lib/sevgi/geometry/equation/line/diagonal.rb +90 -0
  13. data/lib/sevgi/geometry/equation/line/horizontal.rb +15 -0
  14. data/lib/sevgi/geometry/equation/line/vertical.rb +52 -0
  15. data/lib/sevgi/geometry/equation/line.rb +38 -0
  16. data/lib/sevgi/geometry/equation.rb +3 -0
  17. data/lib/sevgi/geometry/errors.rb +5 -0
  18. data/lib/sevgi/geometry/external.rb +15 -0
  19. data/lib/sevgi/geometry/operation/align.rb +40 -0
  20. data/lib/sevgi/geometry/operation/sweep.rb +52 -0
  21. data/lib/sevgi/geometry/operation.rb +28 -0
  22. data/lib/sevgi/geometry/point.rb +62 -0
  23. data/lib/sevgi/geometry.rb +10 -0
  24. data/lib/sevgi/graphics/attribute.rb +125 -0
  25. data/lib/sevgi/graphics/canvas.rb +51 -0
  26. data/lib/sevgi/graphics/content.rb +72 -0
  27. data/lib/sevgi/graphics/document/base.rb +51 -0
  28. data/lib/sevgi/graphics/document/default.rb +19 -0
  29. data/lib/sevgi/graphics/document/html.rb +11 -0
  30. data/lib/sevgi/graphics/document/inkscape.rb +17 -0
  31. data/lib/sevgi/graphics/document/minimal.rb +11 -0
  32. data/lib/sevgi/graphics/document.rb +53 -0
  33. data/lib/sevgi/graphics/element.rb +85 -0
  34. data/lib/sevgi/graphics/external.rb +15 -0
  35. data/lib/sevgi/graphics/mixtures/core.rb +81 -0
  36. data/lib/sevgi/graphics/mixtures/duplicate.rb +36 -0
  37. data/lib/sevgi/graphics/mixtures/hatch.rb +21 -0
  38. data/lib/sevgi/graphics/mixtures/identify.rb +93 -0
  39. data/lib/sevgi/graphics/mixtures/inkscape.rb +15 -0
  40. data/lib/sevgi/graphics/mixtures/lint.rb +33 -0
  41. data/lib/sevgi/graphics/mixtures/render.rb +149 -0
  42. data/lib/sevgi/graphics/mixtures/replicate.rb +125 -0
  43. data/lib/sevgi/graphics/mixtures/save.rb +23 -0
  44. data/lib/sevgi/graphics/mixtures/transform.rb +78 -0
  45. data/lib/sevgi/graphics/mixtures/underscore.rb +21 -0
  46. data/lib/sevgi/graphics/mixtures/validate.rb +27 -0
  47. data/lib/sevgi/graphics/mixtures/wrappers.rb +63 -0
  48. data/lib/sevgi/graphics/mixtures.rb +16 -0
  49. data/lib/sevgi/graphics.rb +10 -0
  50. data/lib/sevgi/internal/constant.rb +5 -0
  51. data/lib/sevgi/internal/dim.rb +13 -0
  52. data/lib/sevgi/internal/function/file.rb +30 -0
  53. data/lib/sevgi/internal/function/float.rb +35 -0
  54. data/lib/sevgi/internal/function/formula.rb +71 -0
  55. data/lib/sevgi/internal/function/math.rb +43 -0
  56. data/lib/sevgi/internal/function/string.rb +13 -0
  57. data/lib/sevgi/internal/function.rb +7 -0
  58. data/lib/sevgi/internal/list.rb +27 -0
  59. data/lib/sevgi/internal/locate.rb +47 -0
  60. data/lib/sevgi/internal/margin.rb +23 -0
  61. data/lib/sevgi/internal/minitest/script.rb +50 -0
  62. data/lib/sevgi/internal/minitest/shell.rb +71 -0
  63. data/lib/sevgi/internal/minitest/suite.rb +35 -0
  64. data/lib/sevgi/internal/minitest.rb +5 -0
  65. data/lib/sevgi/internal/paper.rb +26 -0
  66. data/lib/sevgi/internal.rb +10 -0
  67. data/lib/sevgi/standard/conform.rb +55 -0
  68. data/lib/sevgi/standard/data/attribute.rb +496 -0
  69. data/lib/sevgi/standard/data/element.rb +269 -0
  70. data/lib/sevgi/standard/data/specification.rb +1841 -0
  71. data/lib/sevgi/standard/data.rb +79 -0
  72. data/lib/sevgi/standard/errors.rb +28 -0
  73. data/lib/sevgi/standard/model.rb +82 -0
  74. data/lib/sevgi/standard.rb +26 -0
  75. data/lib/sevgi/utensils/external.rb +22 -0
  76. data/lib/sevgi/utensils/grid.rb +49 -0
  77. data/lib/sevgi/utensils/ruler.rb +47 -0
  78. data/lib/sevgi/utensils/tsquare.rb +28 -0
  79. data/lib/sevgi/utensils.rb +7 -0
  80. data/lib/sevgi/version.rb +5 -0
  81. data/lib/sevgi.rb +10 -0
  82. metadata +127 -0
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sevgi
4
+ module Test
5
+ class Suite
6
+ def initialize(rootdir)
7
+ @scripts = load(rootdir)
8
+ end
9
+
10
+ def [](suite)
11
+ (@cache ||= {})[suite] ||= @scripts.select { |script| script.suite == suite.to_s }
12
+ end
13
+
14
+ def suites
15
+ @suites ||= @scripts.map(&:suite).uniq
16
+ end
17
+
18
+ NON_VALIDS = ["gotcha"]
19
+
20
+ def non_valids
21
+ NON_VALIDS.map { self[_1] }.flatten
22
+ end
23
+
24
+ def valids
25
+ suites.reject { NON_VALIDS.include?(_1) }.map { self[_1] }.flatten
26
+ end
27
+
28
+ private
29
+
30
+ def load(rootdir)
31
+ Dir["#{rootdir}/**/*.sevgi"].grep_v(%r{(/_|/lib/|/library/)}).map { Script.new(_1) }
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "minitest/script"
4
+ require_relative "minitest/shell"
5
+ require_relative "minitest/suite"
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sevgi
4
+ Paper = {
5
+ a3: Dim[297.0, 420.0],
6
+ a4: Dim[210.0, 297.0],
7
+ a5: Dim[148.5, 210.0],
8
+ a6: Dim[105.0, 148.5],
9
+ a7: Dim[74.25, 105.0],
10
+ b3: Dim[353.0, 500.0],
11
+ b4: Dim[250.0, 353.0],
12
+ b5: Dim[176.5, 250.0],
13
+ b6: Dim[125.0, 176.5],
14
+ b7: Dim[88.25, 125.0],
15
+ large: Dim[130.0, 210.0],
16
+ passport: Dim[88.0, 125.0],
17
+ pocket: Dim[90.0, 140.0],
18
+ travelers: Dim[110.0, 210.0],
19
+ us: Dim[215.9, 279.4],
20
+ xlarge: Dim[190.0, 250.0],
21
+ }.tap do
22
+ def _1.default_proc = proc { |_, key| ArgumentError.("No such paper: #{key}") }
23
+
24
+ def _1.default = :a4
25
+ end.freeze
26
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "internal/function"
4
+
5
+ require_relative "internal/constant"
6
+ require_relative "internal/dim"
7
+ require_relative "internal/list"
8
+ require_relative "internal/locate"
9
+ require_relative "internal/margin"
10
+ require_relative "internal/paper"
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sevgi
4
+ module Standard
5
+ class Conform
6
+ require_relative "model"
7
+
8
+ attr_reader :element, :spec
9
+
10
+ def initialize(element)
11
+ InvalidElementsError.(element) unless (@spec = Specification[@element = element])
12
+
13
+ raise(NotImplementedError, "No model specified: #{element}") unless spec[:model]
14
+ raise(NotImplementedError, "Model unimplemented: #{spec[:model]}") unless Model.const_defined?(spec[:model])
15
+
16
+ extend(Model.const_get(spec[:model]))
17
+
18
+ raise(NotImplementedError, "Unimplemented apply method: #{spec[:model]}") unless respond_to?(:apply)
19
+ end
20
+
21
+ def call(attributes: nil, cdata: nil, elements: nil)
22
+ if attributes
23
+ unrecognized = concerning_attributes(attributes) - spec[:attributes]
24
+
25
+ InvalidAttributesError.(element, unrecognized) unless unrecognized.empty?
26
+ end
27
+
28
+ apply(cdata:, elements:)
29
+
30
+ true
31
+ end
32
+
33
+ private
34
+
35
+ def concerning_attributes(attributes)
36
+ attributes.reject do |attribute|
37
+ attribute.start_with?("_") ||
38
+ attribute == :xmlns ||
39
+ attribute.start_with?("data-") ||
40
+ (attribute.to_s.include?(":") && !attribute.start_with?("xlink:") && !attribute.start_with?("xml:"))
41
+ end
42
+ end
43
+
44
+ @cache = {}
45
+
46
+ class << self
47
+ def call(element, attributes: nil, cdata: nil, elements: nil)
48
+ (@cache[element] ||= new(element)).call(attributes:, cdata:, elements:)
49
+ end
50
+ end
51
+ end
52
+
53
+ private_constant :Conform, :Model
54
+ end
55
+ end
@@ -0,0 +1,496 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sevgi
4
+ module Standard
5
+ module Attribute
6
+ import(
7
+ Animation: %i[
8
+ accelerate
9
+ accumulate
10
+ additive
11
+ attributeName
12
+ attributeType
13
+ autoReverse
14
+ begin
15
+ by
16
+ calcMode
17
+ decelerate
18
+ dur
19
+ end
20
+ fill
21
+ from
22
+ keySplines
23
+ keyTimes
24
+ max
25
+ min
26
+ onbegin
27
+ onend
28
+ onrepeat
29
+ repeatCount
30
+ repeatDur
31
+ restart
32
+ to
33
+ values
34
+ ],
35
+
36
+ AnimationAddition: %i[
37
+ accumulate
38
+ additive
39
+ ],
40
+
41
+ AnimationAttributeTarget: %i[
42
+ attributeName
43
+ attributeType
44
+ ],
45
+
46
+ AnimationValue: %i[
47
+ accelerate
48
+ autoReverse
49
+ by
50
+ calcMode
51
+ decelerate
52
+ from
53
+ keySplines
54
+ keyTimes
55
+ to
56
+ values
57
+ ],
58
+
59
+ AnimationTiming: %i[
60
+ begin
61
+ dur
62
+ end
63
+ fill
64
+ max
65
+ min
66
+ repeatCount
67
+ repeatDur
68
+ restart
69
+ ],
70
+
71
+ Aria: %i[
72
+ aria-activedescendant
73
+ aria-atomic
74
+ aria-autocomplete
75
+ aria-busy
76
+ aria-checked
77
+ aria-colcount
78
+ aria-colindex
79
+ aria-colspan
80
+ aria-controls
81
+ aria-current
82
+ aria-describedby
83
+ aria-details
84
+ aria-disabled
85
+ aria-dropeffect
86
+ aria-errormessage
87
+ aria-expanded
88
+ aria-flowto
89
+ aria-grabbed
90
+ aria-haspopup
91
+ aria-hidden
92
+ aria-invalid
93
+ aria-keyshortcuts
94
+ aria-label
95
+ aria-labelledby
96
+ aria-level
97
+ aria-live
98
+ aria-modal
99
+ aria-multiline
100
+ aria-multiselectable
101
+ aria-orientation
102
+ aria-owns
103
+ aria-placeholder
104
+ aria-posinset
105
+ aria-pressed
106
+ aria-readonly
107
+ aria-relevant
108
+ aria-required
109
+ aria-roledescription
110
+ aria-rowcount
111
+ aria-rowindex
112
+ aria-rowspan
113
+ aria-selected
114
+ aria-setsize
115
+ aria-sort
116
+ aria-valuemax
117
+ aria-valuemin
118
+ aria-valuenow
119
+ aria-valuetext
120
+ ],
121
+
122
+ ConditionalProcessing: %i[
123
+ requiredExtensions
124
+ requiredFeatures
125
+ systemLanguage
126
+ ],
127
+
128
+ Core: %i[
129
+ autofocus
130
+ id
131
+ lang
132
+ tabindex
133
+ xml:base
134
+ xml:lang
135
+ xml:space
136
+ ],
137
+
138
+ EventAnimation: %i[
139
+ onbegin
140
+ onend
141
+ onrepeat
142
+ ],
143
+
144
+ EventDocument: %i[
145
+ onabort
146
+ onerror
147
+ onresize
148
+ onscroll
149
+ onunload
150
+ ],
151
+
152
+ EventDocumentElement: %i[
153
+ oncopy
154
+ oncut
155
+ onpaste
156
+ ],
157
+
158
+ EventGlobal: %i[
159
+ oncancel
160
+ oncanplay
161
+ oncanplaythrough
162
+ onchange
163
+ onclick
164
+ onclose
165
+ oncuechange
166
+ ondblclick
167
+ ondrag
168
+ ondragend
169
+ ondragenter
170
+ ondragleave
171
+ ondragover
172
+ ondragstart
173
+ ondrop
174
+ ondurationchange
175
+ onemptied
176
+ onended
177
+ onerror
178
+ onfocus
179
+ oninput
180
+ oninvalid
181
+ onkeydown
182
+ onkeypress
183
+ onkeyup
184
+ onload
185
+ onloadeddata
186
+ onloadedmetadata
187
+ onloadstart
188
+ onmousedown
189
+ onmouseenter
190
+ onmouseleave
191
+ onmousemove
192
+ onmouseout
193
+ onmouseover
194
+ onmouseup
195
+ onmousewheel
196
+ onpause
197
+ onplay
198
+ onplaying
199
+ onprogress
200
+ onratechange
201
+ onreset
202
+ onresize
203
+ onscroll
204
+ onseeked
205
+ onseeking
206
+ onselect
207
+ onshow
208
+ onstalled
209
+ onsubmit
210
+ onsuspend
211
+ ontimeupdate
212
+ ontoggle
213
+ onvolumechange
214
+ onwaiting
215
+ ],
216
+
217
+ EventGraphical: %i[
218
+ onactivate
219
+ onfocusin
220
+ onfocusout
221
+ ],
222
+
223
+ FilterPrimitive: %i[
224
+ height
225
+ result
226
+ width
227
+ x
228
+ y
229
+ ],
230
+
231
+ FilterTransferFunction: %i[
232
+ amplitude
233
+ exponent
234
+ intercept
235
+ offset
236
+ slope
237
+ tableValues
238
+ type
239
+ ],
240
+
241
+ Presentation: %i[
242
+ alignment-baseline
243
+ baseline-shift
244
+ clip
245
+ clip-path
246
+ clip-rule
247
+ color
248
+ color-interpolation
249
+ color-interpolation-filters
250
+ color-profile
251
+ color-rendering
252
+ cursor
253
+ direction
254
+ display
255
+ dominant-baseline
256
+ enable-background
257
+ fill
258
+ fill-opacity
259
+ fill-rule
260
+ filter
261
+ flood-color
262
+ flood-opacity
263
+ font-family
264
+ font-size
265
+ font-size-adjust
266
+ font-stretch
267
+ font-style
268
+ font-variant
269
+ font-weight
270
+ glyph-orientation-horizontal
271
+ glyph-orientation-vertical
272
+ image-rendering
273
+ kerning
274
+ letter-spacing
275
+ lighting-color
276
+ marker-end
277
+ marker-mid
278
+ marker-start
279
+ mask
280
+ opacity
281
+ overflow
282
+ pointer-events
283
+ shape-rendering
284
+ stop-color
285
+ stop-opacity
286
+ stroke
287
+ stroke-dasharray
288
+ stroke-dashoffset
289
+ stroke-linecap
290
+ stroke-linejoin
291
+ stroke-miterlimit
292
+ stroke-opacity
293
+ stroke-width
294
+ text-anchor
295
+ text-decoration
296
+ text-rendering
297
+ transform
298
+ transform-origin
299
+ unicode-bidi
300
+ vector-effect
301
+ visibility
302
+ word-spacing
303
+ writing-mode
304
+ ],
305
+
306
+ Style: %i[
307
+ class
308
+ style
309
+ ],
310
+
311
+ Xlink: %i[
312
+ xlink:actuate
313
+ xlink:arcrole
314
+ xlink:href
315
+ xlink:role
316
+ xlink:show
317
+ xlink:title
318
+ xlink:type
319
+ ],
320
+
321
+ # Uncategorized attributes (for the sake of completeness)
322
+
323
+ Uncategorized: %i[
324
+ accent-height
325
+ alphabetic
326
+ arabic-form
327
+ ascent
328
+ azimuth
329
+ baseFrequency
330
+ baseProfile
331
+ bbox
332
+ bias
333
+ cap-height
334
+ clipPathUnits
335
+ contentScriptType
336
+ contentStyleType
337
+ crossorigin
338
+ cx
339
+ cy
340
+ d
341
+ decoding
342
+ descent
343
+ diffuseConstant
344
+ divisor
345
+ download
346
+ dx
347
+ dy
348
+ edgeMode
349
+ elevation
350
+ externalResourcesRequired
351
+ filterRes
352
+ filterUnits
353
+ format
354
+ fr
355
+ fx
356
+ fy
357
+ g1
358
+ g2
359
+ glyph-name
360
+ glyphRef
361
+ gradientTransform
362
+ gradientUnits
363
+ hanging
364
+ hatchContentUnits
365
+ hatchUnits
366
+ horiz-adv-x
367
+ horiz-origin-x
368
+ horiz-origin-y
369
+ href
370
+ hreflang
371
+ ideographic
372
+ in
373
+ in2
374
+ k
375
+ k1
376
+ k2
377
+ k3
378
+ k4
379
+ kernelMatrix
380
+ kernelUnitLength
381
+ keyPoints
382
+ lengthAdjust
383
+ limitingConeAngle
384
+ local
385
+ markerHeight
386
+ markerUnits
387
+ markerWidth
388
+ maskContentUnits
389
+ maskUnits
390
+ mathematical
391
+ media
392
+ method
393
+ mode
394
+ name
395
+ numOctaves
396
+ operator
397
+ order
398
+ orient
399
+ orientation
400
+ origin
401
+ overline-position
402
+ overline-thickness
403
+ panose-1
404
+ path
405
+ pathLength
406
+ patternContentUnits
407
+ patternTransform
408
+ patternUnits
409
+ ping
410
+ pitch
411
+ playbackorder
412
+ points
413
+ pointsAtX
414
+ pointsAtY
415
+ pointsAtZ
416
+ preserveAlpha
417
+ preserveAspectRatio
418
+ primitiveUnits
419
+ r
420
+ radius
421
+ refX
422
+ refY
423
+ referrerpolicy
424
+ rel
425
+ rendering-intent
426
+ role
427
+ rotate
428
+ rx
429
+ ry
430
+ scale
431
+ seed
432
+ side
433
+ spacing
434
+ specularConstant
435
+ specularExponent
436
+ spreadMethod
437
+ startOffset
438
+ stdDeviation
439
+ stemh
440
+ stemv
441
+ stitchTiles
442
+ strikethrough-position
443
+ strikethrough-thickness
444
+ string
445
+ surfaceScale
446
+ target
447
+ targetX
448
+ targetY
449
+ textLength
450
+ timelinebegin
451
+ title
452
+ u1
453
+ u2
454
+ underline-position
455
+ underline-thickness
456
+ unicode
457
+ unicode-range
458
+ units-per-em
459
+ v-alphabetic
460
+ v-hanging
461
+ v-ideographic
462
+ v-mathematical
463
+ version
464
+ vert-adv-y
465
+ vert-origin-x
466
+ vert-origin-y
467
+ viewBox
468
+ viewTarget
469
+ widths
470
+ x-height
471
+ x1
472
+ x2
473
+ xChannelSelector
474
+ y1
475
+ y2
476
+ yChannelSelector
477
+ z
478
+ zoomAndPan
479
+ ],
480
+
481
+ # Deprecated attributes
482
+
483
+ Deprecated: %i[
484
+ accent-height
485
+ alphabetic
486
+ amplitude
487
+ arabic-form
488
+ ascent
489
+ attributeType
490
+ baseProfile
491
+ bbox
492
+ ],
493
+ )
494
+ end
495
+ end
496
+ end