gv 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gv.rb +15 -3
- data/lib/gv/version.rb +1 -1
- data/spec/graph_spec.rb +7 -7
- data/spec/render.png +0 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df3b4f9e7e9dc7a1bb1c3f9fc0442c5032772570
|
4
|
+
data.tar.gz: d74223b0a785b75df5aa6ada63c8eaf10b66a2cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61070b8eac8e61b06d970495df79d49efb46f6612e425228d02ed5c364effb5e0fc9b64f22ac0915db171478f8b86e355f326eadb03e85670fcecdac3d8c24a2
|
7
|
+
data.tar.gz: 8ddeec3c092d86be9f144fa83926a1251456ac7536d1d308e4638c387ef77925001226e3ef7d5ab90b18bfa1609118f5c3cf761e86c48b31f791ac54397e261f
|
data/lib/gv.rb
CHANGED
@@ -51,8 +51,8 @@ module GV
|
|
51
51
|
attach_function :agget, [:pointer, :string], :string
|
52
52
|
|
53
53
|
attach_function :agsafeset, [:pointer, :string, :string, :string], :pointer
|
54
|
-
attach_function :agstrdup_html, [
|
55
|
-
attach_function :agstrfree, [
|
54
|
+
attach_function :agstrdup_html, [AGraph.by_ref, :string], :pointer
|
55
|
+
attach_function :agstrfree, [AGraph.by_ref, :pointer], :int
|
56
56
|
|
57
57
|
attach_function :agisdirected, [AGraph.by_ref], :int
|
58
58
|
attach_function :agisstrict, [AGraph.by_ref], :int
|
@@ -63,6 +63,14 @@ module GV
|
|
63
63
|
|
64
64
|
attr_reader :graph
|
65
65
|
|
66
|
+
def html(string)
|
67
|
+
ptr = FFI.agstrdup_html(graph.ptr, string)
|
68
|
+
string = ptr.read_string
|
69
|
+
FFI.agstrfree graph.ptr, ptr
|
70
|
+
|
71
|
+
string
|
72
|
+
end
|
73
|
+
|
66
74
|
def hash
|
67
75
|
ptr.hash
|
68
76
|
end
|
@@ -127,7 +135,7 @@ module GV
|
|
127
135
|
component Edge, [name, tail, head], attrs
|
128
136
|
end
|
129
137
|
|
130
|
-
def
|
138
|
+
def sub_graph(name, attrs = {})
|
131
139
|
graph = component SubGraph, [name], attrs
|
132
140
|
yield graph if block_given?
|
133
141
|
|
@@ -199,6 +207,10 @@ module GV
|
|
199
207
|
@ptr = ptr
|
200
208
|
end
|
201
209
|
|
210
|
+
def graph
|
211
|
+
self
|
212
|
+
end
|
213
|
+
|
202
214
|
def write(filename, format = 'png', layout = 'dot')
|
203
215
|
FFI.gvLayout(@@gvc, ptr, layout.to_s)
|
204
216
|
FFI.gvRenderFilename(@@gvc, ptr, format.to_s, filename);
|
data/lib/gv/version.rb
CHANGED
data/spec/graph_spec.rb
CHANGED
@@ -54,21 +54,21 @@ describe Graph do
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
describe :
|
57
|
+
describe :sub_graph do
|
58
58
|
before do
|
59
59
|
@graph = Graph.open 'test'
|
60
60
|
end
|
61
61
|
|
62
|
-
it "creates a new
|
63
|
-
@graph.
|
62
|
+
it "creates a new sub graph" do
|
63
|
+
@graph.sub_graph('test').must_be_kind_of SubGraph
|
64
64
|
end
|
65
65
|
|
66
66
|
it "sets given attributes" do
|
67
|
-
@graph.
|
67
|
+
@graph.sub_graph('test', color: 'green')[:color].must_equal 'green'
|
68
68
|
end
|
69
69
|
|
70
70
|
it "takes a block" do
|
71
|
-
graph = @graph.
|
71
|
+
graph = @graph.sub_graph('test') do |g|
|
72
72
|
g[:color] = 'green'
|
73
73
|
end
|
74
74
|
graph[:color].must_equal 'green'
|
@@ -106,7 +106,7 @@ describe Graph do
|
|
106
106
|
describe :render do
|
107
107
|
it "renders the graph to a string" do
|
108
108
|
graph = Graph.open 'test'
|
109
|
-
graph.edge 'e', graph.node('A'), graph.node('B', shape: 'polygon')
|
109
|
+
graph.edge 'e', graph.node('A'), graph.node('B', shape: 'polygon', label: graph.html('<b>bold</b>'))
|
110
110
|
data = graph.render
|
111
111
|
|
112
112
|
graph = nil
|
@@ -140,4 +140,4 @@ describe Edge do
|
|
140
140
|
@edge[:color] = 'green'
|
141
141
|
@edge[:color].must_equal 'green'
|
142
142
|
end
|
143
|
-
end
|
143
|
+
end
|
data/spec/render.png
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- furunkel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|