graphviz 0.4.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +0 -2
- data/Gemfile +5 -1
- data/Guardfile +3 -3
- data/README.md +0 -1
- data/graphviz.gemspec +6 -6
- data/lib/graphviz.rb +19 -30
- data/lib/graphviz/graph.rb +4 -4
- data/lib/graphviz/version.rb +1 -1
- data/spec/graphviz/graph_spec.rb +6 -0
- data/spec/spec_helper.rb +2 -0
- metadata +20 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19495d84180ba9ab615643343f701ce704013006
|
4
|
+
data.tar.gz: 329c2911542140bca2019879729fdf7c0bf14db1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73b47d36224242eaa821e4041576804190c87e2b71c4482548eef2de5d854b4993c4e03286ccc584183646588341c70c79b60580bc2369fe5d46c222cb28303c
|
7
|
+
data.tar.gz: a469a380a39736e1b4c33eb214758c13d3339563a4d9c22152f1d5a9762a43a30e0bcf34f6eaffe1581d7e999e4b925a2664ae435a9613b7777ae8942d060ff1
|
data/.rspec
CHANGED
data/Gemfile
CHANGED
data/Guardfile
CHANGED
@@ -6,7 +6,7 @@ clearing :on
|
|
6
6
|
ENV['COVERAGE'] = 'y'
|
7
7
|
|
8
8
|
guard :rspec, cmd: "bundle exec rspec" do
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
watch(%r{^spec/.+_spec\.rb$})
|
10
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
11
|
+
watch("spec/spec_helper.rb") { "spec" }
|
12
12
|
end
|
data/README.md
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
Graphviz is a graph visualisation system. This gem is a lightweight interface for generating graphs with Graphviz.
|
4
4
|
|
5
5
|
[](https://travis-ci.org/ioquatix/graphviz)
|
6
|
-
[](https://codeclimate.com/github/ioquatix/graphviz)
|
7
6
|
[](https://coveralls.io/r/ioquatix/graphviz)
|
8
7
|
|
9
8
|
## Installation
|
data/graphviz.gemspec
CHANGED
@@ -1,7 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'graphviz/version'
|
1
|
+
|
2
|
+
require_relative 'lib/graphviz/version'
|
5
3
|
|
6
4
|
Gem::Specification.new do |spec|
|
7
5
|
spec.name = "graphviz"
|
@@ -12,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
12
10
|
Graphviz is a graph visualisation system. This gem is a lightweight interface for generating graphs with Graphviz.
|
13
11
|
EOF
|
14
12
|
spec.summary = "A lightweight interface for generating graphs with Graphviz."
|
15
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "https://github.com/ioquatix/graphviz"
|
16
14
|
spec.license = "MIT"
|
17
15
|
|
18
16
|
spec.files = `git ls-files`.split($/)
|
@@ -22,8 +20,10 @@ Gem::Specification.new do |spec|
|
|
22
20
|
|
23
21
|
spec.has_rdoc = 'yard'
|
24
22
|
|
23
|
+
spec.add_dependency 'process-pipeline'
|
24
|
+
|
25
25
|
spec.add_development_dependency "yard"
|
26
26
|
spec.add_development_dependency "bundler", "~> 1.3"
|
27
|
-
spec.add_development_dependency "rspec", "~> 3.
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.6"
|
28
28
|
spec.add_development_dependency "rake"
|
29
29
|
end
|
data/lib/graphviz.rb
CHANGED
@@ -21,51 +21,40 @@
|
|
21
21
|
require_relative "graphviz/version"
|
22
22
|
require_relative "graphviz/graph"
|
23
23
|
|
24
|
+
require 'process/pipeline'
|
25
|
+
|
24
26
|
module Graphviz
|
25
|
-
# Signals that the process exited with a non-zero status.
|
26
|
-
class OutputError < StandardError
|
27
|
-
end
|
28
|
-
|
29
27
|
# Outputs the graph using the +dot+ executable.
|
30
28
|
# @return [String] any data generated by the command unless an output path is specified.
|
31
29
|
#
|
32
|
-
# @option options [String] :
|
30
|
+
# @option options [String] :format ('pdf') The output format (e.g. pdf).
|
33
31
|
# @option options [String] :path The output path, if not specified data is returned.
|
34
32
|
# @option options [String] :dot ('dot') The +dot+ executable to use.
|
35
|
-
def self.output(graph,
|
36
|
-
|
37
|
-
|
38
|
-
output_format = options[:format]
|
33
|
+
def self.output(graph, path: nil, format: 'pdf', dot: 'dot')
|
34
|
+
output_format = format
|
39
35
|
|
40
|
-
if
|
36
|
+
if path
|
41
37
|
# Grab the output format from the file name:
|
42
|
-
if
|
38
|
+
if path =~ /\.(.*?)$/
|
43
39
|
output_format ||= $1
|
44
40
|
end
|
45
|
-
|
46
|
-
output_file = File.open(options[:path], "w")
|
47
|
-
else
|
48
|
-
output_file = IO.pipe
|
49
41
|
end
|
50
42
|
|
51
43
|
output, input = IO.pipe
|
52
|
-
|
53
|
-
|
54
|
-
output.close
|
44
|
+
pipeline = Process::Pipeline.(dot, "-T#{output_format}")
|
55
45
|
|
56
|
-
|
57
|
-
|
58
|
-
input.close
|
59
|
-
|
60
|
-
_, status = Process.wait2(pid)
|
61
|
-
|
62
|
-
if status != 0
|
63
|
-
raise OutputError.new("dot exited with status #{status}")
|
64
|
-
end
|
46
|
+
writer = Thread.new do
|
47
|
+
graph.dump_graph(input)
|
65
48
|
|
66
|
-
|
67
|
-
|
68
|
-
|
49
|
+
input.close
|
50
|
+
end
|
51
|
+
|
52
|
+
if path
|
53
|
+
pipeline.write(path, input: output)
|
54
|
+
else
|
55
|
+
return pipeline.read(input: output)
|
69
56
|
end
|
57
|
+
ensure
|
58
|
+
writer.join
|
70
59
|
end
|
71
60
|
end
|
data/lib/graphviz/graph.rb
CHANGED
@@ -68,10 +68,10 @@ module Graphviz
|
|
68
68
|
end
|
69
69
|
|
70
70
|
# @return [String] Output the graph using the dot format.
|
71
|
-
def to_dot(options
|
71
|
+
def to_dot(**options)
|
72
72
|
buffer = StringIO.new
|
73
73
|
|
74
|
-
dump_graph(buffer,
|
74
|
+
dump_graph(buffer, **options)
|
75
75
|
|
76
76
|
return buffer.string
|
77
77
|
end
|
@@ -92,7 +92,7 @@ module Graphviz
|
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
-
def dump_edges(buffer, indent, options)
|
95
|
+
def dump_edges(buffer, indent, **options)
|
96
96
|
@edges.each do |edge|
|
97
97
|
edge_attributes_text = dump_attributes(edge.attributes)
|
98
98
|
|
@@ -101,7 +101,7 @@ module Graphviz
|
|
101
101
|
end
|
102
102
|
|
103
103
|
# Dump the entire graph and all subgraphs to dot text format.
|
104
|
-
def dump_graph(buffer, indent, options)
|
104
|
+
def dump_graph(buffer, indent = "", **options)
|
105
105
|
format = graph_format(options)
|
106
106
|
|
107
107
|
buffer.puts "#{indent}#{format} #{dump_value(self.identifier)} {"
|
data/lib/graphviz/version.rb
CHANGED
data/spec/graphviz/graph_spec.rb
CHANGED
@@ -44,5 +44,11 @@ digraph "G" {
|
|
44
44
|
|
45
45
|
expect(File.exist? "test.pdf").to be true
|
46
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
|
47
53
|
end
|
48
54
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphviz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.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-
|
11
|
+
date: 2017-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: process-pipeline
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: yard
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +58,14 @@ dependencies:
|
|
44
58
|
requirements:
|
45
59
|
- - "~>"
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version: 3.
|
61
|
+
version: '3.6'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
66
|
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version: 3.
|
68
|
+
version: '3.6'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rake
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -91,7 +105,7 @@ files:
|
|
91
105
|
- spec/graphviz/edge_spec.rb
|
92
106
|
- spec/graphviz/graph_spec.rb
|
93
107
|
- spec/spec_helper.rb
|
94
|
-
homepage:
|
108
|
+
homepage: https://github.com/ioquatix/graphviz
|
95
109
|
licenses:
|
96
110
|
- MIT
|
97
111
|
metadata: {}
|
@@ -111,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
125
|
version: '0'
|
112
126
|
requirements: []
|
113
127
|
rubyforge_project:
|
114
|
-
rubygems_version: 2.6.
|
128
|
+
rubygems_version: 2.6.12
|
115
129
|
signing_key:
|
116
130
|
specification_version: 4
|
117
131
|
summary: A lightweight interface for generating graphs with Graphviz.
|
@@ -119,4 +133,3 @@ test_files:
|
|
119
133
|
- spec/graphviz/edge_spec.rb
|
120
134
|
- spec/graphviz/graph_spec.rb
|
121
135
|
- spec/spec_helper.rb
|
122
|
-
has_rdoc: yard
|