graphvizml 0.5.5 → 0.5.6

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
  SHA1:
3
- metadata.gz: de0694551027289ed8fa1585ad6b6c623ec452ba
4
- data.tar.gz: 126a11754c78559bf196baab8c64df3f4f893981
3
+ metadata.gz: cc88f0980d16f4c6ac702127b4038b4df8fe9076
4
+ data.tar.gz: d73d374242d788856f689bf0016c619803391bb3
5
5
  SHA512:
6
- metadata.gz: 583cc6f8a779814a1388b734439b799342661490abd92472de500b9e1154eb11553ff71996640f106be09f73e4051ba6789b6469344d1a93a6676d6e460c33e0
7
- data.tar.gz: 74f5895b91a83eecfbda1e3b0da57c3fca2a76fe67e135c32d3175c01504aeca370432f3b1508c072d6eacbebed4a05f2e41c64d34e8ac619e412fdfb5ebd184
6
+ metadata.gz: 2e476405816dd40ee6a31a0ac09f1103092e6fb75d35a8747f0e9868a9df34d56fc95d9a90f2f4807814ec143e6d8998d36f2246c56302a561da4cc57b6aa082
7
+ data.tar.gz: 0d5ba3b20ed75906ac73805013403bacec88d215c3fc40c44705b494aeb698903b4562e4475d42d8a900db136ca8cf06af52766a03b040061ce48118ecdbf8b3
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/graphvizml.rb CHANGED
@@ -105,38 +105,56 @@ class GraphVizML
105
105
 
106
106
  def build_from_nodes(doc)
107
107
 
108
-
109
108
  g = Graphviz::Graph.new format_summary_attributes(doc.root.attributes)
110
109
 
111
-
112
110
  # add the nodes
113
111
 
114
- nodes = doc.root.xpath('//a | //node').inject({}) do |r,e|
112
+ nodes = doc.root.xpath('//node').inject({}) do |r,e|
115
113
 
116
114
  r.merge fetch_node(e)
117
115
 
118
- end
116
+ end
117
+
118
+ a = doc.root.element('style/text()').strip.split(/}/).map do |entry|
119
+
120
+ raw_selector,raw_styles = entry.split(/{/,2)
121
+
122
+ h = raw_styles.strip.split(/;/).inject({}) do |r, x|
123
+ k, v = x.split(/:/,2).map(&:strip)
124
+ r.merge(k.to_sym => v)
125
+ end
126
+
127
+ [raw_selector.split(/,\s*/).map(&:strip), h]
128
+ end
129
+
130
+ edge_style = a.find {|x| x[0].grep(/edge/).any?}.last
131
+
132
+
119
133
 
120
134
  # add the edges
121
135
 
122
136
  id_1 = nodes.first[0]
123
137
  nodes[id_1][-1] = g.add_node(nodes[id_1][0])
124
-
138
+
125
139
 
126
140
  doc.root.each_recursive do |node|
127
-
128
- node.xpath('node').each do |child|
141
+
142
+ next unless node.name == 'node'
143
+
144
+ node.xpath('a | node').each do |childx|
129
145
 
146
+ child = childx.name == 'node' ? childx : childx.element('node')
130
147
  id1, id2 = node.object_id, child.object_id
131
148
 
132
149
  label = child.attributes[:connection].to_s
133
- #puts "adding edge id1: %s id2: %s label: %s" % [id1, id2, label]
150
+
134
151
  nodes[id2][-1] ||= nodes[id1].last.add_node(nodes[id2][0])
135
152
  attributes = child.style.merge({label: label})
136
-
153
+
137
154
  conn = nodes[id1][-1].connections.last
138
155
  conn.attributes[:label] = label
139
- child.style.each {|key,val| conn.attributes[key] = m(val) }
156
+
157
+ edge_style.each {|key,val| conn.attributes[key] = m(val) }
140
158
 
141
159
  end
142
160
  end
@@ -147,20 +165,16 @@ class GraphVizML
147
165
 
148
166
  end
149
167
 
150
- def fetch_node(e)
168
+ def fetch_node(node)
169
+
170
+ h = node.attributes
151
171
 
152
- node = if e.name == 'a' then
172
+ if node.parent.name == 'a' then
153
173
 
154
- url = e.attributes[:href]
155
- child = e.element 'node'
156
- child.attributes[:url] = url
174
+ url = node.parent.attributes[:href]
175
+ h[:url] = url if url
157
176
 
158
- child
159
- else
160
- e
161
- end
162
-
163
- h = node.attributes
177
+ end
164
178
 
165
179
  id = h[:gid] || node.object_id
166
180
  label = node.text('label')
@@ -181,8 +195,9 @@ class GraphVizML
181
195
  def format_attributes(nodes)
182
196
 
183
197
  nodes.each do |id, x|
184
-
198
+
185
199
  _, attributes, obj = x
200
+ next unless obj
186
201
  attributes.each {|key, val| obj.attributes[key] = m(val) }
187
202
 
188
203
  end
data.tar.gz.sig CHANGED
@@ -1,2 +1 @@
1
- ݡ7���VQ=5��?�����@��v׷�NcfJ� ��wKLx1-{f����0]��u ��RAϚ4��U��ɳ���� c�@꿢��]����c��s��$�%fM��l�SX�lOy3��9���eK�k2��E?��akf����,W�W��E��ê������4\� '��&7��
2
- 7���q��}�bh�:��őj5�k�e�܏N�!ft���Dž �a�D��
1
+ ���� ���e��TF�����W(ɮ'yi��,��<�ډ[lBr����c
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphvizml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  0fBBWVqwHyWs77T9gCuDZmQrw2NmfyhNWhBw0iljBXo7WLDNB3x0nP6mYTzk47O8
32
32
  sL5FGYJNgQqFlw==
33
33
  -----END CERTIFICATE-----
34
- date: 2017-09-10 00:00:00.000000000 Z
34
+ date: 2017-09-16 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: domle
metadata.gz.sig CHANGED
Binary file