graphviz 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +2 -4
- data/examples/demo.rb +1 -1
- data/lib/graphviz/graph.rb +17 -0
- data/lib/graphviz/version.rb +1 -1
- data/spec/graphviz/graph_spec.rb +48 -29
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6123888d6233c036411f7c2a69ab27d2bb338a0edf0d3bd51c8d8a7a0d9f24be
|
4
|
+
data.tar.gz: 483ef5ae45dd35142417f9209d723ba08a40d124039fe2ccd358752c655b26cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6818b3d608768b623161dd9040590a0d5e1f5f75c3ae91905565a7b47d882a2bf46efb58191e5675f62a9a959e84cf58e8b458ae2c752393b4abdf79f7b99f37
|
7
|
+
data.tar.gz: 2e4a0707d00ed505fb4b099a58126f83b8b9f2f7ecbe679797e6adff32ee576fb235e6ea55ed712baf32676bd45d16e791bf9d123fa7fbaa07a330218bcacf63
|
data/.travis.yml
CHANGED
data/examples/demo.rb
CHANGED
data/lib/graphviz/graph.rb
CHANGED
@@ -61,6 +61,23 @@ module Graphviz
|
|
61
61
|
return subgraph
|
62
62
|
end
|
63
63
|
|
64
|
+
# Finds all nodes with a given name
|
65
|
+
#
|
66
|
+
# @param [String] node_name the name to look for
|
67
|
+
# @return [Array<Graphviz::Node>, nil] list of all found nodes or nil
|
68
|
+
def get_node(node_name)
|
69
|
+
@nodes.select{ |k, v| v.name == node_name}.values
|
70
|
+
end
|
71
|
+
|
72
|
+
# Determines if a node with a given name exists in the graph
|
73
|
+
#
|
74
|
+
# @param [String] node_name the name to look for
|
75
|
+
# @return [Boolean] if node exists in graph
|
76
|
+
def node_exists?(node_name)
|
77
|
+
@nodes.select{ |k, v| v.name == node_name}.any?
|
78
|
+
end
|
79
|
+
|
80
|
+
|
64
81
|
def << node
|
65
82
|
@nodes[node.name] = node
|
66
83
|
|
data/lib/graphviz/version.rb
CHANGED
data/spec/graphviz/graph_spec.rb
CHANGED
@@ -20,35 +20,54 @@
|
|
20
20
|
|
21
21
|
require 'graphviz'
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
23
|
+
RSpec.describe Graphviz::Graph do
|
24
|
+
let(:sample_graph_dot) do
|
25
|
+
<<~EOF
|
26
|
+
digraph "G" {
|
27
|
+
"Foo"[shape="box3d", color="red"];
|
28
|
+
"Bar";
|
29
|
+
"Foo" -> "Bar";
|
30
|
+
}
|
31
|
+
EOF
|
32
|
+
end
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
34
|
+
it "should construct a simple graph" do
|
35
|
+
foo = subject.add_node("Foo")
|
36
|
+
foo.add_node("Bar")
|
37
|
+
|
38
|
+
foo.attributes[:shape] = 'box3d'
|
39
|
+
foo.attributes[:color] = 'red'
|
40
|
+
|
41
|
+
expect(subject.to_dot).to be == sample_graph_dot
|
42
|
+
|
43
|
+
# Process the graph to output:
|
44
|
+
Graphviz::output(subject, :path => "test.pdf")
|
45
|
+
|
46
|
+
expect(File.exist? "test.pdf").to be true
|
47
|
+
end
|
48
|
+
|
49
|
+
it "gets a node" do
|
50
|
+
foo = subject.add_node('Foo')
|
51
|
+
bar = subject.add_node('Bar')
|
52
|
+
bar.add_node('Baz')
|
53
|
+
expect(subject.get_node('Baz')).to be_an(Array)
|
54
|
+
expect(subject.get_node('Baz').size).to eq 1
|
55
|
+
expect(subject.get_node('Foo').first).to be_a(Graphviz::Node)
|
56
|
+
expect(subject.get_node('Nothing')).to be_an(Array)
|
57
|
+
expect(subject.get_node('Nothing').size).to eq 0
|
58
|
+
end
|
59
|
+
|
60
|
+
it "checks if a node exists" do
|
61
|
+
foo = subject.add_node('Foo')
|
62
|
+
bar = subject.add_node('Bar')
|
63
|
+
bar.add_node('Baz')
|
64
|
+
expect(subject.node_exists?('Baz')).to be true
|
65
|
+
expect(subject.node_exists?('Nothing')).to be false
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should raise an error the executable is installed' do
|
69
|
+
expect do
|
70
|
+
Graphviz.output(subject, :dot => 'foobarbaz')
|
71
|
+
end.to raise_error(Errno::ENOENT, 'No such file or directory - foobarbaz')
|
53
72
|
end
|
54
73
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphviz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: process-pipeline
|
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
125
|
version: '0'
|
126
126
|
requirements: []
|
127
127
|
rubyforge_project:
|
128
|
-
rubygems_version: 2.6
|
128
|
+
rubygems_version: 2.7.6
|
129
129
|
signing_key:
|
130
130
|
specification_version: 4
|
131
131
|
summary: A lightweight interface for generating graphs with Graphviz.
|