graphvizml 0.1.2 → 0.2.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
  SHA1:
3
- metadata.gz: f5d3e64a89e4a8aca44de4b73ee8fdd67654f654
4
- data.tar.gz: 9bbf22a678f88328434bee2d25dab96f67c42de7
3
+ metadata.gz: fa1a602a47c8fd18ef15dca1bade19d3fff91b4f
4
+ data.tar.gz: e720cce356fe7729149af89fe81e3ac4ae8490b7
5
5
  SHA512:
6
- metadata.gz: 6eb862a9595478d7561ad7aa3d59af7128c3f6b98623b78d8348c8550606c3825d5f85198af44ddf0a10fb4746aa793d6f84697bb4a9a672b1a051af013937d6
7
- data.tar.gz: 243962484ebc442197d35be82b8b2191ba00de9f0cf1c9f148597cf5d8cb051c3c34b524775ef9ce947a2bc370f4c947ae950b8438ebc5cac7f6244364cf09ef
6
+ metadata.gz: 44f4558ce01e9cd7d72a484fb081c754ed7c6c1db5c4a04ce89be1b08a501a8be7bf6b49f556c0cb53eea9281a56734e873aed8bd471288e3bccbc109c3c7cbf
7
+ data.tar.gz: 98a20cd7ae810889f8755aa98cc69f1179d3277821aa12dfb6e794403cd6d02877ce41ca6d27e123551b59a23475dadf9ed71ba0db01a5f7918cb01df5720a2d
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/graphvizml.rb CHANGED
@@ -25,26 +25,43 @@ class GraphVizML
25
25
  @doc = obj
26
26
 
27
27
  end
28
+
29
+ build()
28
30
 
29
31
  end
30
32
 
31
33
  def to_png(filename=@filename.sub(/\.xml$/,'.png'))
32
-
33
- e_options = @doc.root.element 'options'
34
+ @g.output( png: filename )
35
+ end
36
+
37
+ private
38
+
39
+ def build
40
+
41
+ stylesheet = @doc.root.element('style').text
34
42
  e_nodes = @doc.root.element 'nodes'
35
43
  e_edges = @doc.root.element 'edges'
36
44
 
37
- # set global node options
45
+ # parse the stylesheet
38
46
 
39
- xpath_node = "records/option[summary/type='node']/records/attribute"
40
- e_options.root.xpath(xpath_node).each do |attribute|
41
- @g.node[attribute.text('name').to_sym] = attribute.text('value')
42
- end
47
+ a = stylesheet.split(/}/)[0..-2].map do |entry|
48
+
49
+ raw_selector,raw_styles = entry.split(/{/,2)
50
+
51
+ h = raw_styles.strip.split(/;/).inject({}) do |r, x|
52
+ k, v = x.split(/:/,2).map(&:strip)
53
+ r.merge(k.to_sym => v)
54
+ end
55
+
56
+ [raw_selector.split(/,\s*/).map(&:strip), h]
57
+ end
58
+
59
+ node_style = a.detect {|x| x.assoc 'node'}
60
+ node_style.last.each {|key, value| @g.node[key] = value } if node_style
61
+
62
+ edge_style = a.detect {|x| x.assoc 'edge'}
63
+ edge_style.last.each {|key, value| @g.edge[key] = value } if edge_style
43
64
 
44
- xpath_edge = "records/option[summary/type='edge']/records/attribute"
45
- e_options.root.xpath(xpath_edge).each do |attribute|
46
- @g.edge[attribute.text('name').to_sym] = attribute.text('value')
47
- end
48
65
 
49
66
  # add the nodes
50
67
 
@@ -59,13 +76,7 @@ class GraphVizML
59
76
  a = edge.xpath('records/node')
60
77
  @g.add_edge(a[0].attribute('id').to_s,
61
78
  a[1].attribute('id').to_s).label = edge.text('summary/label').to_s
62
- end
63
-
64
- # output the file
65
-
66
- out_type = e_edges.root.text('summary/output_type')
67
- out_file = e_edges.root.text('summary/output_file')
68
- @g.output( png: filename )
79
+ end
69
80
  end
70
81
 
71
- end
82
+ end
data.tar.gz.sig CHANGED
Binary file
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.1.2
4
+ version: 0.2.0
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-01-06 00:00:00.000000000 Z
34
+ date: 2017-01-07 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rexle
metadata.gz.sig CHANGED
Binary file