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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 19495d84180ba9ab615643343f701ce704013006
4
- data.tar.gz: 329c2911542140bca2019879729fdf7c0bf14db1
2
+ SHA256:
3
+ metadata.gz: 6123888d6233c036411f7c2a69ab27d2bb338a0edf0d3bd51c8d8a7a0d9f24be
4
+ data.tar.gz: 483ef5ae45dd35142417f9209d723ba08a40d124039fe2ccd358752c655b26cd
5
5
  SHA512:
6
- metadata.gz: 73b47d36224242eaa821e4041576804190c87e2b71c4482548eef2de5d854b4993c4e03286ccc584183646588341c70c79b60580bc2369fe5d46c222cb28303c
7
- data.tar.gz: a469a380a39736e1b4c33eb214758c13d3339563a4d9c22152f1d5a9762a43a30e0bcf34f6eaffe1581d7e999e4b925a2664ae435a9613b7777ae8942d060ff1
6
+ metadata.gz: 6818b3d608768b623161dd9040590a0d5e1f5f75c3ae91905565a7b47d882a2bf46efb58191e5675f62a9a959e84cf58e8b458ae2c752393b4abdf79f7b99f37
7
+ data.tar.gz: 2e4a0707d00ed505fb4b099a58126f83b8b9f2f7ecbe679797e6adff32ee576fb235e6ea55ed712baf32676bd45d16e791bf9d123fa7fbaa07a330218bcacf63
data/.travis.yml CHANGED
@@ -1,6 +1,4 @@
1
1
  language: ruby
2
- sudo: false
3
- dist: trusty
4
2
 
5
3
  addons:
6
4
  apt:
@@ -8,8 +6,8 @@ addons:
8
6
  - graphviz
9
7
 
10
8
  rvm:
11
- - 2.1
12
- - 2.2
13
9
  - 2.3
14
10
  - 2.4
11
+ - 2.5
12
+ - 2.6
15
13
  - ruby-head
data/examples/demo.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require_relative 'lib/graphviz.rb'
3
+ require_relative '../lib/graphviz'
4
4
 
5
5
  # Hello
6
6
  # |
@@ -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
 
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Graphviz
22
- VERSION = "1.0.0"
22
+ VERSION = "1.1.0"
23
23
  end
@@ -20,35 +20,54 @@
20
20
 
21
21
  require 'graphviz'
22
22
 
23
- module Graphviz::GraphSpec
24
- SAMPLE_GRAPH_DOT = <<-EOF
25
- digraph "G" {
26
- "Foo"[shape="box3d", color="red"];
27
- "Bar";
28
- "Foo" -> "Bar";
29
- }
30
- EOF
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
- describe Graphviz::Graph do
33
- it "should construct a simple graph" do
34
- foo = subject.add_node("Foo")
35
- foo.add_node("Bar")
36
-
37
- foo.attributes[:shape] = 'box3d'
38
- foo.attributes[:color] = 'red'
39
-
40
- expect(subject.to_dot).to be == SAMPLE_GRAPH_DOT
41
-
42
- # Process the graph to output:
43
- Graphviz::output(subject, :path => "test.pdf")
44
-
45
- expect(File.exist? "test.pdf").to be true
46
- end
47
-
48
- it 'should raise an error the executable is installed' do
49
- expect do
50
- Graphviz.output(subject, :dot => 'foobarbaz')
51
- end.to raise_error(Errno::ENOENT, 'No such file or directory - foobarbaz')
52
- end
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.0.0
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: 2017-10-18 00:00:00.000000000 Z
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.12
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.