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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3ab9a6ec4d306435db96592402c93d4e2746815d
4
- data.tar.gz: 141d01be0f201f81285c758d217df94d0d34d17e
3
+ metadata.gz: df3b4f9e7e9dc7a1bb1c3f9fc0442c5032772570
4
+ data.tar.gz: d74223b0a785b75df5aa6ada63c8eaf10b66a2cd
5
5
  SHA512:
6
- metadata.gz: 8d1128773dee3e2b1d7a7ea29d1201247cb74ed8bc65e2f75cfbe2eedc00939aa4becd1041061718e171fa0b693689fb7ae331e0d7b5eee83471b8bdca83f8c8
7
- data.tar.gz: d891316e6792c0be6f6821f81c6b1d3e05bc63fca2b5e897641efb7087ed17af5cb94e326d2f593f8d75826024b3bd3131d3f90d0abe3e9d93c5e2402f2955be
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, [:pointer, :string], :string
55
- attach_function :agstrfree, [:pointer, :string], :int
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 graph(name, attrs = {})
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);
@@ -1,3 +1,3 @@
1
1
  module GV
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -54,21 +54,21 @@ describe Graph do
54
54
  end
55
55
  end
56
56
 
57
- describe :graph do
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 subgraph" do
63
- @graph.graph('test').must_be_kind_of SubGraph
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.graph('test', color: 'green')[:color].must_equal 'green'
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.graph('test') do |g|
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
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.2
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-24 00:00:00.000000000 Z
11
+ date: 2015-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler