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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 26ed6f42266187f65af641382518c0d00e2eabd8
4
- data.tar.gz: 3ac7a918a5f7da7288fec080a712b572eddecfbb
3
+ metadata.gz: 19495d84180ba9ab615643343f701ce704013006
4
+ data.tar.gz: 329c2911542140bca2019879729fdf7c0bf14db1
5
5
  SHA512:
6
- metadata.gz: 23e5b1deba81bd053beb0dab4c03450b16324df909999233d5a344f8e205682d412f1d27c3c80a81693b0dbbdadcaae3eb463dda72f7eb9b1d6f16b235420602
7
- data.tar.gz: 82088298acc5dd68c759a1ae87ed5c40a15d7b863da5e643e9d402d94c2ffa465dc124608bb058e69570c492c9a9fcd985c3a9d6943a6973325f29e1b04063a6
6
+ metadata.gz: 73b47d36224242eaa821e4041576804190c87e2b71c4482548eef2de5d854b4993c4e03286ccc584183646588341c70c79b60580bc2369fe5d46c222cb28303c
7
+ data.tar.gz: a469a380a39736e1b4c33eb214758c13d3339563a4d9c22152f1d5a9762a43a30e0bcf34f6eaffe1581d7e999e4b925a2664ae435a9613b7777ae8942d060ff1
data/.rspec CHANGED
@@ -1,5 +1,3 @@
1
- --color
2
1
  --format documentation
3
- --backtrace
4
2
  --require spec_helper
5
3
  --warnings
data/Gemfile CHANGED
@@ -5,5 +5,9 @@ gemspec
5
5
 
6
6
  group :development do
7
7
  gem "guard-rspec"
8
- gem "simplecov"
8
+ end
9
+
10
+ group :test do
11
+ gem 'simplecov'
12
+ gem 'coveralls', require: false
9
13
  end
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
- watch(%r{^spec/.+_spec\.rb$})
10
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
11
- watch("spec/spec_helper.rb") { "spec" }
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
  [![Build Status](https://travis-ci.org/ioquatix/graphviz.svg)](https://travis-ci.org/ioquatix/graphviz)
6
- [![Code Climate](https://codeclimate.com/github/ioquatix/graphviz.svg)](https://codeclimate.com/github/ioquatix/graphviz)
7
6
  [![Coverage Status](https://coveralls.io/repos/ioquatix/graphviz/badge.svg)](https://coveralls.io/r/ioquatix/graphviz)
8
7
 
9
8
  ## Installation
@@ -1,7 +1,5 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
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.4.0"
27
+ spec.add_development_dependency "rspec", "~> 3.6"
28
28
  spec.add_development_dependency "rake"
29
29
  end
@@ -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] :output_format ('pdf') The output format (e.g. pdf).
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, options = {})
36
- text = graph.to_dot
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 options[:path]
36
+ if path
41
37
  # Grab the output format from the file name:
42
- if options[:path] =~ /\.(.*?)$/
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
- pid = Process.spawn(options[:dot] || "dot", "-T#{output_format}", :out => output_file, :in => output)
53
-
54
- output.close
44
+ pipeline = Process::Pipeline.(dot, "-T#{output_format}")
55
45
 
56
- # Send graph data to process:
57
- input.write(text)
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
- # Did we use a local pipe for output?
67
- if Array === output_file
68
- return task.output.read
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
@@ -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, "", options)
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)} {"
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Graphviz
22
- VERSION = "0.4.0"
22
+ VERSION = "1.0.0"
23
23
  end
@@ -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
@@ -19,6 +19,8 @@ end
19
19
  require "bundler/setup"
20
20
  require "graphviz"
21
21
 
22
+ Thread.abort_on_exception = true
23
+
22
24
  RSpec.configure do |config|
23
25
  # Enable flags like --only-failures and --next-failure
24
26
  config.example_status_persistence_file_path = ".rspec_status"
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.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-04-24 00:00:00.000000000 Z
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.4.0
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.4.0
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.10
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