gviz 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/README.md +2 -0
- data/Rakefile +5 -0
- data/gviz.gemspec +2 -0
- data/lib/gviz.rb +4 -0
- data/lib/gviz/core.rb +5 -4
- data/lib/gviz/edge.rb +2 -1
- data/lib/gviz/version.rb +1 -1
- data/spec/gviz_command_spec.rb +1 -1
- data/spec/gviz_edge_spec.rb +14 -0
- data/spec/gviz_spec.rb +70 -3
- data/spec/spec_helper.rb +3 -0
- metadata +31 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b24e07887d8c7f4d4337ec7de04cfdec4f1ea10d
|
4
|
+
data.tar.gz: 79ca3e661bc0e17025907bb475d08d854ec75dfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d489810c365bf0159f82a09832c49e03ee39e8df515264b029069044befb31033a7d5fb4b0c76b7a809718aac5b582fae97cb287e9726cec25e5383dd8fc69c8
|
7
|
+
data.tar.gz: 96f0516da3abf0f01bd6d6e789f08984255b37b42554287be871ecba4eba3261f186f65508b7baefebafe81140e204e18d8308af9fbe523cc2ab2befdb00ff08
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Gviz
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.org/melborne/Gviz.png?branch=master)](https://travis-ci.org/melborne/Gviz)
|
4
|
+
|
3
5
|
Ruby's interface of graphviz. It generate a dot file with simple ruby's syntax. Some implementations of `Gviz` are inspired by Ryan Davis's [Graph](https://github.com/seattlerb/graph 'seattlerb/graph').
|
4
6
|
|
5
7
|
## Installation
|
data/Rakefile
CHANGED
data/gviz.gemspec
CHANGED
@@ -18,5 +18,7 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
gem.required_ruby_version = '>=2.0.0'
|
20
20
|
gem.add_development_dependency 'rspec'
|
21
|
+
gem.add_development_dependency "bundler", "~> 1.5"
|
22
|
+
gem.add_development_dependency "rake"
|
21
23
|
gem.add_dependency 'thor'
|
22
24
|
end
|
data/lib/gviz.rb
CHANGED
@@ -11,6 +11,10 @@ def Graph(name=:G, type=:digraph, &blk)
|
|
11
11
|
Gviz.new(name, type).graph(&blk)
|
12
12
|
end
|
13
13
|
|
14
|
+
# This value will be changed to ':graph' only when Graph initiate with :graph type.
|
15
|
+
# then effect globally to edge connectors from '->' to '--'.
|
16
|
+
$graph_type = :digraph
|
17
|
+
|
14
18
|
%w(core node edge version system_extension command).each do |lib|
|
15
19
|
require 'gviz/' + lib
|
16
20
|
end
|
data/lib/gviz/core.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
class Gviz
|
2
|
-
attr_reader :gnode_attrs, :gedge_attrs, :graph_attrs, :subgraphs, :ranks
|
2
|
+
attr_reader :gnode_attrs, :gedge_attrs, :graph_attrs, :subgraphs, :ranks, :name
|
3
3
|
def initialize(name=:G, type=:digraph)
|
4
4
|
@name, @type = name, type
|
5
|
+
$graph_type = type.intern if type.intern==:graph
|
5
6
|
@edges = {}
|
6
7
|
@nodes = {}
|
7
8
|
@gnode_attrs = {}
|
@@ -10,7 +11,7 @@ class Gviz
|
|
10
11
|
@subgraphs = []
|
11
12
|
@ranks = []
|
12
13
|
end
|
13
|
-
|
14
|
+
|
14
15
|
# Access to all defined node objects.
|
15
16
|
def nodeset
|
16
17
|
@nodes.values
|
@@ -108,8 +109,8 @@ class Gviz
|
|
108
109
|
# add :a => :b
|
109
110
|
# end
|
110
111
|
#
|
111
|
-
def subgraph(&blk)
|
112
|
-
Gviz.new(
|
112
|
+
def subgraph(name=:"cluster#{subgraphs.size}", &blk)
|
113
|
+
Gviz.new(name, :subgraph).tap do |graph|
|
113
114
|
subgraphs << graph
|
114
115
|
graph.instance_eval &blk
|
115
116
|
end
|
data/lib/gviz/edge.rb
CHANGED
data/lib/gviz/version.rb
CHANGED
data/spec/gviz_command_spec.rb
CHANGED
data/spec/gviz_edge_spec.rb
CHANGED
@@ -84,4 +84,18 @@ describe Gviz::Edge do
|
|
84
84
|
end
|
85
85
|
end
|
86
86
|
end
|
87
|
+
|
88
|
+
describe "#to_s" do
|
89
|
+
context "when type of graph is 'graph'" do
|
90
|
+
before do
|
91
|
+
$graph_type = :graph
|
92
|
+
end
|
93
|
+
it "returns undirected graph edges" do
|
94
|
+
expect(Gviz::Edge.new('a_b').to_s).to eq "a -- b"
|
95
|
+
end
|
96
|
+
after() do
|
97
|
+
$graph_type = :digraph
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
87
101
|
end
|
data/spec/gviz_spec.rb
CHANGED
@@ -195,7 +195,7 @@ describe Gviz do
|
|
195
195
|
its(:size) { should eq 1 }
|
196
196
|
end
|
197
197
|
|
198
|
-
context "when add
|
198
|
+
context "when add two" do
|
199
199
|
before do
|
200
200
|
gv.subgraph { add :main => [:a, :b] }
|
201
201
|
gv.subgraph { add :main => [:a, :b] }
|
@@ -204,9 +204,31 @@ describe Gviz do
|
|
204
204
|
its(:size) { should eq 2 }
|
205
205
|
end
|
206
206
|
|
207
|
+
context "without name" do
|
208
|
+
before do
|
209
|
+
@sub1 = gv.subgraph { add :main => [:a, :b] }
|
210
|
+
@sub2 = gv.subgraph { add :main => [:a, :b] }
|
211
|
+
end
|
212
|
+
it "returns a default name" do
|
213
|
+
expect(@sub1.name).to eq :cluster0
|
214
|
+
expect(@sub2.name).to eq :cluster1
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
context "with a name" do
|
219
|
+
before do
|
220
|
+
@sub1 = gv.subgraph(:cluA) { add :main => [:a, :b] }
|
221
|
+
@sub2 = gv.subgraph(:cluB) { add :main => [:a, :b] }
|
222
|
+
end
|
223
|
+
it "returns passed name" do
|
224
|
+
expect(@sub1.name).to eq :cluA
|
225
|
+
expect(@sub2.name).to eq :cluB
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
207
229
|
context "it has a name other than `cluster**`" do
|
208
|
-
it "raise an error" do
|
209
|
-
->{ gv.subgraph(:clu) {} }.
|
230
|
+
it "not raise an error" do
|
231
|
+
->{ gv.subgraph(:clu) {} }.should_not raise_error
|
210
232
|
end
|
211
233
|
end
|
212
234
|
end
|
@@ -507,6 +529,51 @@ describe Gviz do
|
|
507
529
|
EOS
|
508
530
|
end
|
509
531
|
end
|
532
|
+
|
533
|
+
context "for undirected graph" do
|
534
|
+
before do
|
535
|
+
@gv = Gviz.new(:G, :graph)
|
536
|
+
@gv.add :main => [:init, :parse]
|
537
|
+
@gv.add :init => :printf
|
538
|
+
end
|
539
|
+
subject { @gv.to_s }
|
540
|
+
it do
|
541
|
+
should eq ~<<-EOS
|
542
|
+
graph G {
|
543
|
+
main;
|
544
|
+
init;
|
545
|
+
parse;
|
546
|
+
printf;
|
547
|
+
main -- init;
|
548
|
+
main -- parse;
|
549
|
+
init -- printf;
|
550
|
+
}
|
551
|
+
EOS
|
552
|
+
end
|
553
|
+
|
554
|
+
context "with subgraph" do
|
555
|
+
before do
|
556
|
+
@gv = Gviz.new(:G, :graph)
|
557
|
+
@gv.route(:a => :b)
|
558
|
+
@gv.subgraph { route :c => :d }
|
559
|
+
end
|
560
|
+
subject { @gv.to_s }
|
561
|
+
it do
|
562
|
+
should eql ~<<-EOS
|
563
|
+
graph G {
|
564
|
+
subgraph cluster0 {
|
565
|
+
c;
|
566
|
+
d;
|
567
|
+
c -- d;
|
568
|
+
}
|
569
|
+
a;
|
570
|
+
b;
|
571
|
+
a -- b;
|
572
|
+
}
|
573
|
+
EOS
|
574
|
+
end
|
575
|
+
end
|
576
|
+
end
|
510
577
|
end
|
511
578
|
end
|
512
579
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gviz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kyoendo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -24,6 +24,34 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: thor
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -47,6 +75,7 @@ extensions: []
|
|
47
75
|
extra_rdoc_files: []
|
48
76
|
files:
|
49
77
|
- ".gitignore"
|
78
|
+
- ".travis.yml"
|
50
79
|
- Gemfile
|
51
80
|
- LICENSE.txt
|
52
81
|
- README.md
|