pxgraphviz 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 70f73184b1cef8e81842516e538451db8d8560579ae2ef32e4df8bf90d48d459
4
- data.tar.gz: af7d1eeb5592936825ba4865eed0c6573641140669d53a0a11edab252594a8aa
3
+ metadata.gz: 8ec769baa44cc90b7da7bb62a0856f87da40246ffaa5096051e58eed34d783b1
4
+ data.tar.gz: d471f35e76cc4993a38405c5dba1e162401402811661a8b71148c41f746e2760
5
5
  SHA512:
6
- metadata.gz: 3378a5d20a452a3d2f9edc6f33add84ef84d5eb3c8936e9980bd0e8b7d1bef76a6b42b49896e8fbbe3832ac07ba0a2381f181b9fe50f815f3cf87e0f6531097c
7
- data.tar.gz: ddf70aa9c62d18e4083d0ffa9f9012f91936cfd91537fe99c74496a7b5400759bafd69915020c9c11149d2f8dc2898f5ac2c6fe2d2cbb712cf15d99f56d71e2a
6
+ metadata.gz: 807f06da5f13d2194f8a0c75444c62ac59bc06990956282a71d075e1c70df86cc8c83a2daf21531757a1e137ed2f2edfea269a61f43fd1823f1d526d4b33321e
7
+ data.tar.gz: dea35e397915adc20147b7884b649b01563d616884e9a8f06856f93074071cb646ff42357bf8f391237c58f1f2c3e57acffe5acc34b8ab9bc32629778f63d6b5
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/pxgraphviz.rb CHANGED
@@ -5,6 +5,22 @@
5
5
 
6
6
  require 'polyrex'
7
7
  require 'graphvizml'
8
+ require 'rxfreader'
9
+
10
+
11
+ module RegGem
12
+
13
+ def self.register()
14
+ '
15
+ hkey_gems
16
+ doctype
17
+ pxgraphviz
18
+ require pxgraphviz
19
+ class PxGraphViz
20
+ media_type svg
21
+ '
22
+ end
23
+ end
8
24
 
9
25
 
10
26
  class PxGraphViz < GraphVizML
@@ -12,63 +28,65 @@ class PxGraphViz < GraphVizML
12
28
 
13
29
  attr_reader :doc, :px
14
30
 
15
- def initialize(s, style: nil, debug: false, fill: '#778833',
31
+ def initialize(obj=nil, style: nil, debug: false, fill: '#778833',
16
32
  stroke: '#999999', text_color: '#ffeecc')
17
33
 
18
- @px = s =~ /^<\?/ ? Polyrex.new.import(s) : Polyrex.new(s)
34
+ if obj then
19
35
 
20
- @type = @px.summary[:type] == 'digraph' ? 'dir: forward;' : 'dir: none;'
21
- @shape = @px.summary[:shape] || 'ellipse;'
22
-
23
- style ||= default_stylesheet()
24
- doc = Rexslt.new(xslt_stylesheet(), @px.to_xml)\
25
- .to_doc.root.element('nodes')
26
-
27
- doc.root.elements.first.insert_before Rexle::Element.new('style')\
28
- .add_text style
29
- @doc = doc
30
- puts 'pxgraphviz: before super'.info if debug
36
+ s = RXFReader.read(obj).first
37
+ @doc = import_string(s)
38
+
39
+ puts 'pxgraphviz: before super'.info if debug
40
+
41
+ super(@doc, debug: debug, fill: fill,
42
+ stroke: stroke, text_color: text_color)
43
+
44
+ end
31
45
 
32
- super(doc, debug: debug, fill: fill,
33
- stroke: stroke, text_color: text_color)
34
-
35
46
  @css = "
36
- .node ellipse {stroke: #{stroke}; fill: #{fill}}
47
+ .node polygon {stroke: #{stroke}; fill: #{fill}}
37
48
  .node text {fill: #{text_color}}
38
49
  .edge path {stroke: #{stroke}}
39
50
  .edge polygon {stroke: #{stroke}; fill: #{stroke}}
40
51
  "
41
-
42
- end
43
-
44
-
52
+
53
+ end
54
+
55
+ def import(s)
56
+ s2 = RXFReader.read(s).first
57
+ @doc = import_string s2
58
+ @g = build_from_nodes Domle.new(@doc.root.xml)
59
+ self
60
+ end
61
+
62
+
45
63
  protected
46
-
64
+
47
65
  def default_stylesheet()
48
66
 
49
67
  <<STYLE
50
- node {
51
- color: #ddaa66;
52
- fillcolor: #778833;
53
- fontcolor: #ffeecc;
68
+ node {
69
+ color: #ddaa66;
70
+ fillcolor: #{@fill};
71
+ fontcolor: #{@text_color};
54
72
  fontname: 'Trebuchet MS';
55
- fontsize: 8;
73
+ fontsize: 8;
56
74
  margin: 0.0;
57
- penwidth: 1;
75
+ penwidth: 1;
58
76
  style: filled;
59
- shape: #{@shape};
77
+ shape: #{@shape};
60
78
  }
61
-
79
+
62
80
  a node {
63
- color: #0011ee;
81
+ color: #0011ee;
64
82
  }
65
83
 
66
84
  edge {
67
85
  arrowsize: 0.5;
68
- color: #999999;
69
- fontcolor: #444444;
70
- fontname: Verdana;
71
- fontsize: 8;
86
+ color: #{@stroke};
87
+ fontcolor: #444444;
88
+ fontname: Verdana;
89
+ fontsize: 8;
72
90
  #{@type}
73
91
  weight: 1;
74
92
  }
@@ -76,11 +94,65 @@ STYLE
76
94
 
77
95
  end
78
96
 
97
+
79
98
  private
80
-
99
+
100
+ def import_string(s)
101
+
102
+ @px = if s =~ /<\?pxgraphviz\b/ then
103
+
104
+ header = "<?polyrex schema='items[type, shape]/item[label, connection]' delimiter =' # '?>
105
+ type: digraph
106
+ shape: box
107
+ "
108
+ s2 = s.slice!(/<\?pxgraphviz\b[^>]*\?>/)
109
+
110
+ if s2 then
111
+
112
+ attributes = %w(id fill stroke text_color).inject({}) do |r, keyword|
113
+ found = s2[/(?<=#{keyword}=['"])[^'"]+/]
114
+ found ? r.merge(keyword.to_sym => found) : r
115
+ end
116
+
117
+ fill, stroke, text_color = %i(fill stroke text_color).map do |x|
118
+ attributes[x] ? attributes[x] : method(x).call
119
+ end
120
+
121
+ @css = "
122
+ .node ellipse {stroke: #{stroke}; fill: #{fill}}
123
+ .node text {fill: #{text_color}}
124
+ .edge path {stroke: #{stroke}}
125
+ .edge polygon {stroke: #{stroke}; fill: #{stroke}}
126
+ "
127
+
128
+ end
129
+ s3 = header + s
130
+ puts 's3: ' + s3.inspect if @debug
131
+ Polyrex.new.import(s3)
132
+
133
+ else
134
+
135
+ Polyrex.new(s)
136
+
137
+ end
138
+
139
+ @type = @px.summary[:type] == 'digraph' ? 'dir: forward;' : 'dir: none;'
140
+ @shape = @px.summary[:shape] || 'ellipse;'
141
+
142
+ @style ||= default_stylesheet()
143
+ doc = Rexslt.new(xslt_stylesheet(), @px.to_xml)\
144
+ .to_doc.root.element('nodes')
145
+
146
+ doc.root.elements.first.insert_before Rexle::Element.new('style')\
147
+ .add_text @style
148
+
149
+ doc
150
+
151
+ end
152
+
81
153
  def xslt_stylesheet()
82
-
83
- <<XSLT
154
+
155
+ <<XSLT
84
156
  <?xml version="1.0" encoding="UTF-8"?>
85
157
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
86
158
  <xsl:output method="xml" indent="yes" />
@@ -114,12 +186,12 @@ STYLE
114
186
  <xsl:element name="a">
115
187
  <xsl:attribute name="href">
116
188
  <xsl:value-of select="summary/url"/>
117
- </xsl:attribute>
189
+ </xsl:attribute>
118
190
  <xsl:call-template name='node'/>
119
191
  </xsl:element>
120
192
 
121
193
  </xsl:when>
122
- <xsl:otherwise>
194
+ <xsl:otherwise>
123
195
 
124
196
  <xsl:call-template name='node'/>
125
197
 
@@ -136,33 +208,33 @@ STYLE
136
208
 
137
209
  <xsl:template name='node'>
138
210
  <xsl:element name="node">
139
-
211
+
140
212
  <xsl:attribute name="shape">
141
213
  <xsl:value-of select="summary/shape"/>
142
214
  </xsl:attribute>
143
-
215
+
144
216
  <xsl:if test="summary/id">
145
217
  <xsl:attribute name="id">
146
218
  <xsl:value-of select="summary/id"/>
147
219
  </xsl:attribute>
148
220
  </xsl:if>
149
-
221
+
150
222
  <xsl:if test="summary/class">
151
223
  <xsl:attribute name="class">
152
224
  <xsl:value-of select="summary/class"/>
153
225
  </xsl:attribute>
154
226
  </xsl:if>
155
-
227
+
156
228
  <xsl:if test="summary/connection">
157
229
  <xsl:attribute name="connection">
158
230
  <xsl:value-of select="summary/connection"/>
159
231
  </xsl:attribute>
160
- </xsl:if>
161
-
232
+ </xsl:if>
233
+
162
234
  <xsl:apply-templates select='summary'/>
163
235
  <xsl:apply-templates select='records'/>
164
236
 
165
- </xsl:element>
237
+ </xsl:element>
166
238
  </xsl:template>
167
239
 
168
240
  </xsl:stylesheet>
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pxgraphviz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -11,31 +11,31 @@ cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
13
  MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
14
- YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTkwNjA5MjEzOTE3WhcN
15
- MjAwNjA4MjEzOTE3WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
- cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQC4WgMZ
17
- e8riZEJtUZOk0m7zdNgVdI9tUhwz0TvyIMcXy+CXdyLhBXlotsqBYluCKuPDv+Ev
18
- XEgzTpT9GxUY/k3W4BCGlV/+/GAnnMmYbNnWwQDXO3au3TxLzRo9QtAamr2LlcXf
19
- r6SyQU2HOF5uzgxpmIuj/Fva2qQKkX373pcOOIeaWR2Xv4QMYrTKikhFRxS6TLJo
20
- 3p4x5xadq85ixScBJPs1SAUgCq0T9mLtTTiEBfArqKhKOSs8scIK7CTLqQz64I8X
21
- IXPtntGQJoUpp0aMaPdkcQxXI4Vx9piyWQOKSPhn53u1H4QtY4fzvb0+jPNAxq/K
22
- 4OYFrdlxEPe/NiXCSgjw1af0Ht382BqCwdhrzV2vhYefg9u3wUyZp8auFhY55k3+
23
- 005EYJOTG/bfspWw+nR/RCWLcYjEts0l7+O++8yWJGgsk4TyW/LbjOcEv/mGDGP/
24
- p2Ai+wcfXwZ7h5Eoh7/6TmWHmHT2OnN1of+ZB9Bi/1yvady+yGzB3DDgRJkCAw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NFWsOQTVWyhLDSvj4aG2fFZ4sYMOD8zJHrxl
35
+ Kw5MEmLLND9M4uj/YjCJaxgvkZ9u4iTBMNldKFS8X5Go7qOpzee47emfjxes++nS
36
+ 6hgbEtPQ0Tr9VNd2zW1qmLkG
37
37
  -----END CERTIFICATE-----
38
- date: 2019-06-10 00:00:00.000000000 Z
38
+ date: 2022-02-23 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: polyrex
@@ -43,42 +43,42 @@ dependencies:
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '1.2'
46
+ version: '1.4'
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 1.2.1
49
+ version: 1.4.0
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - "~>"
55
55
  - !ruby/object:Gem::Version
56
- version: '1.2'
56
+ version: '1.4'
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: 1.2.1
59
+ version: 1.4.0
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: graphvizml
62
62
  requirement: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - "~>"
65
65
  - !ruby/object:Gem::Version
66
- version: '0.6'
66
+ version: '0.7'
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: 0.6.3
69
+ version: 0.7.1
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: '0.6'
76
+ version: '0.7'
77
77
  - - ">="
78
78
  - !ruby/object:Gem::Version
79
- version: 0.6.3
79
+ version: 0.7.1
80
80
  description:
81
- email: james@jamesrobertson.eu
81
+ email: digital.robertson@gmail.com
82
82
  executables: []
83
83
  extensions: []
84
84
  extra_rdoc_files: []
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
105
  requirements: []
106
- rubygems_version: 3.0.1
106
+ rubygems_version: 3.2.22
107
107
  signing_key:
108
108
  specification_version: 4
109
109
  summary: Generates a GraphViz Markup Language file from a Polyrex document
metadata.gz.sig CHANGED
Binary file