graphvizml 0.2.1 → 0.2.2

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: febd83b16af433c07a734388b45f56e68790e5e1
4
- data.tar.gz: 19d83ae5a7bb14426f119c5d31c0717e356f5337
3
+ metadata.gz: 39ea97ac12a4a601926f83b5337f0325b749f1ba
4
+ data.tar.gz: b67e291b4bcb8ee2db0223f9b506ebd943bce346
5
5
  SHA512:
6
- metadata.gz: 8cc1a9cfef615c6901441023c40c852725f72c8fe6376e8c11cda8956f95ed85f74bd43ae9e078f2cd6e492de70753d8236a341f043d572ff0cb1c3b36c1f40e
7
- data.tar.gz: cbed869e1969b87ee818d36b2039c7a30dbde297776a44aeac86bd2ebba1899c57d271783f1ec0ad378caf9158119fec43b19916ed8625f021b13b0e9ed1dda3
6
+ metadata.gz: 91e66ab9af6fface7d8122ae888e7a01d6f540967b24ef0055b85c3192e9c1bb158735bfe6ecc237b3f2a57c58609f76c6602064249b46cda1c30b4943d90288
7
+ data.tar.gz: 2f04f948869723991efb05e001282611bcffc11499bf7326e3ed68b371a8fb36c67e73b1742dd8cf50a869919602fd214b94aa5b85439a17c7c078a223fec2c3
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/graphvizml.rb CHANGED
@@ -4,38 +4,48 @@
4
4
 
5
5
 
6
6
  require 'rexle'
7
- require 'graphviz' # this loads the ruby-graphviz gem
7
+ require 'graphviz'
8
+
8
9
 
9
10
  class GraphVizML
10
11
 
12
+ attr_reader :g
11
13
 
12
14
  def initialize(obj)
13
-
14
- @g = GraphViz::new( "structs", "type" => "graph" )
15
- @g[:rankdir] = "LR"
16
15
 
17
- if obj.is_a? String then
18
-
19
- @filename = obj
20
- @doc = Rexle.new(File.read @filename)
16
+ @doc = if obj.is_a? String then
17
+
18
+ Rexle.new(File.read @filename=obj)
21
19
 
22
20
  elsif obj.is_a? Rexle
23
21
 
24
22
  @filename = 'gvml.xml'
25
- @doc = obj
23
+ obj
26
24
 
27
25
  end
28
26
 
27
+ h = @doc.root.attributes
28
+
29
+ type = h.has_key?(:type) ? h[:type].to_sym : :graph
30
+ direction = h.has_key?(:direction) ? h[:direction].to_s.upcase : 'LR'
31
+
32
+ @g = GraphViz::new( :G, type: type)
33
+ @g[:rankdir] = direction
34
+
29
35
  build()
30
36
 
31
37
  end
32
38
 
39
+ # writes to a PNG file (not a PNG blob)
40
+ #
33
41
  def to_png(filename=@filename.sub(/\.xml$/,'.png'))
34
- @g.output( png: filename )
42
+ @g.output( :png => filename )
35
43
  end
36
44
 
45
+ # writes to a SVG file (not an SVG blob)
46
+ #
37
47
  def to_svg(filename=@filename.sub(/\.xml$/,'.svg'))
38
- @g.output( svg: filename )
48
+ @g.output( :svg => filename )
39
49
  end
40
50
 
41
51
  private
@@ -70,7 +80,11 @@ class GraphVizML
70
80
  # add the nodes
71
81
 
72
82
  e_nodes.root.xpath('records/node').each do |node|
73
- @g.add_node(node.attribute('id').to_s).label = node.text('label')
83
+
84
+ id = node.attribute('id').to_s
85
+ label = node.text('label')
86
+ #puts "adding node id: %s label: %s" % [id, label]
87
+ @g.add_node(id).label = label
74
88
  end
75
89
 
76
90
  # add the edges
@@ -78,9 +92,13 @@ class GraphVizML
78
92
  e_edges.root.xpath('records/edge').each do |edge|
79
93
 
80
94
  a = edge.xpath('records/node')
81
- @g.add_edge(a[0].attribute('id').to_s,
82
- a[1].attribute('id').to_s).label = edge.text('summary/label').to_s
95
+ id1, id2 = a[0].attribute('id').to_s, a[1].attribute('id').to_s
96
+ label = edge.text('summary/label').to_s
97
+ #puts "adding edge id1: %s id2: %s label: %s" % [id1, id2, label]
98
+ @g.add_edge(id1, id2).label = label
83
99
  end
100
+
101
+ :build
84
102
  end
85
103
 
86
104
  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.2.1
4
+ version: 0.2.2
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-22 00:00:00.000000000 Z
34
+ date: 2017-08-31 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rexle
metadata.gz.sig CHANGED
Binary file