pxgraphviz 0.5.1 → 0.5.2
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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/pxgraphviz.rb +90 -19
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a78ce580851bb82d22fa2fb8cae46f76b00983960ae6c5a5eb2a1b9a1a8345e2
|
4
|
+
data.tar.gz: ecb6566e9be469c2af046ea6be9fb80334a4c6bdbd94ce2bd7529224d6f39c24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3c0eaf7ca54185fff20f64523bc34ed8a18d411dd61b63b03f5771a87a3ea86084f4a3e01ad6f7ee11e409ea3a2095b2128e95e30a16b5a987d84a96dcf5878
|
7
|
+
data.tar.gz: ffa438ed496981f3d213c83f920d2cd3fd38ff5ceb712aefd96fce90a462e1886da551ea17427a583dbc18f21739562d1d6209224591dc0390ff7cc4bf5a68be
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/pxgraphviz.rb
CHANGED
@@ -7,38 +7,55 @@ require 'polyrex'
|
|
7
7
|
require 'graphvizml'
|
8
8
|
|
9
9
|
|
10
|
+
module RegGem
|
11
|
+
|
12
|
+
def self.register()
|
13
|
+
'
|
14
|
+
hkey_gems
|
15
|
+
doctype
|
16
|
+
pxgraphviz
|
17
|
+
require pxgraphviz
|
18
|
+
class PxGraphViz
|
19
|
+
media_type svg
|
20
|
+
'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
|
10
25
|
class PxGraphViz < GraphVizML
|
11
26
|
using ColouredText
|
12
27
|
|
13
28
|
attr_reader :doc, :px
|
14
29
|
|
15
|
-
def initialize(
|
30
|
+
def initialize(obj=nil, style: nil, debug: false, fill: '#778833',
|
16
31
|
stroke: '#999999', text_color: '#ffeecc')
|
17
32
|
|
18
|
-
|
33
|
+
if obj then
|
19
34
|
|
20
|
-
|
21
|
-
|
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
|
35
|
+
s = RXFHelper.read(obj).first
|
36
|
+
@doc = import_string(s)
|
31
37
|
|
32
|
-
|
33
|
-
|
38
|
+
puts 'pxgraphviz: before super'.info if debug
|
39
|
+
|
40
|
+
super(@doc, debug: debug, fill: fill,
|
41
|
+
stroke: stroke, text_color: text_color)
|
42
|
+
|
43
|
+
end
|
34
44
|
|
35
45
|
@css = "
|
36
|
-
.node
|
46
|
+
.node polygon {stroke: #{stroke}; fill: #{fill}}
|
37
47
|
.node text {fill: #{text_color}}
|
38
48
|
.edge path {stroke: #{stroke}}
|
39
49
|
.edge polygon {stroke: #{stroke}; fill: #{stroke}}
|
40
50
|
"
|
41
51
|
|
52
|
+
end
|
53
|
+
|
54
|
+
def import(s)
|
55
|
+
s2 = RXFHelper.read(s).first
|
56
|
+
@doc = import_string s2
|
57
|
+
@g = build_from_nodes Domle.new(@doc.root.xml)
|
58
|
+
self
|
42
59
|
end
|
43
60
|
|
44
61
|
|
@@ -49,8 +66,8 @@ class PxGraphViz < GraphVizML
|
|
49
66
|
<<STYLE
|
50
67
|
node {
|
51
68
|
color: #ddaa66;
|
52
|
-
fillcolor: #
|
53
|
-
fontcolor: #
|
69
|
+
fillcolor: #{@fill};
|
70
|
+
fontcolor: #{@text_color};
|
54
71
|
fontname: 'Trebuchet MS';
|
55
72
|
fontsize: 8;
|
56
73
|
margin: 0.0;
|
@@ -65,7 +82,7 @@ class PxGraphViz < GraphVizML
|
|
65
82
|
|
66
83
|
edge {
|
67
84
|
arrowsize: 0.5;
|
68
|
-
color: #
|
85
|
+
color: #{@stroke};
|
69
86
|
fontcolor: #444444;
|
70
87
|
fontname: Verdana;
|
71
88
|
fontsize: 8;
|
@@ -76,8 +93,62 @@ STYLE
|
|
76
93
|
|
77
94
|
end
|
78
95
|
|
96
|
+
|
79
97
|
private
|
80
98
|
|
99
|
+
def import_string(s)
|
100
|
+
|
101
|
+
@px = if s =~ /<\?pxgraphviz\b/ then
|
102
|
+
|
103
|
+
header = "<?polyrex schema='items[type, shape]/item[label, connection]' delimiter =' # '?>
|
104
|
+
type: digraph
|
105
|
+
shape: box
|
106
|
+
"
|
107
|
+
s2 = s.slice!(/<\?pxgraphviz\b[^>]*\?>/)
|
108
|
+
|
109
|
+
if s2 then
|
110
|
+
|
111
|
+
attributes = %w(id fill stroke text_color).inject({}) do |r, keyword|
|
112
|
+
found = s2[/(?<=#{keyword}=['"])[^'"]+/]
|
113
|
+
found ? r.merge(keyword.to_sym => found) : r
|
114
|
+
end
|
115
|
+
|
116
|
+
fill, stroke, text_color = %i(fill stroke text_color).map do |x|
|
117
|
+
attributes[x] ? attributes[x] : method(x).call
|
118
|
+
end
|
119
|
+
|
120
|
+
@css = "
|
121
|
+
.node ellipse {stroke: #{stroke}; fill: #{fill}}
|
122
|
+
.node text {fill: #{text_color}}
|
123
|
+
.edge path {stroke: #{stroke}}
|
124
|
+
.edge polygon {stroke: #{stroke}; fill: #{stroke}}
|
125
|
+
"
|
126
|
+
|
127
|
+
end
|
128
|
+
s3 = header + s
|
129
|
+
puts 's3: ' + s3.inspect if @debug
|
130
|
+
Polyrex.new.import(s3)
|
131
|
+
|
132
|
+
else
|
133
|
+
|
134
|
+
Polyrex.new(s)
|
135
|
+
|
136
|
+
end
|
137
|
+
|
138
|
+
@type = @px.summary[:type] == 'digraph' ? 'dir: forward;' : 'dir: none;'
|
139
|
+
@shape = @px.summary[:shape] || 'ellipse;'
|
140
|
+
|
141
|
+
style ||= default_stylesheet()
|
142
|
+
doc = Rexslt.new(xslt_stylesheet(), @px.to_xml)\
|
143
|
+
.to_doc.root.element('nodes')
|
144
|
+
|
145
|
+
doc.root.elements.first.insert_before Rexle::Element.new('style')\
|
146
|
+
.add_text style
|
147
|
+
|
148
|
+
doc
|
149
|
+
|
150
|
+
end
|
151
|
+
|
81
152
|
def xslt_stylesheet()
|
82
153
|
|
83
154
|
<<XSLT
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|