ruby-graphviz 1.0.9 → 1.1.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/.travis.yml +3 -2
- data/AUTHORS.rdoc +5 -1
- data/CHANGELOG.rdoc +10 -0
- data/README.rdoc +2 -1
- data/Rakefile +32 -24
- data/examples/sample70.rb +9 -0
- data/examples/sample71.rb +21 -0
- data/examples/sample72.rb +22 -0
- data/lib/ext/gvpr/dot2ruby.g +80 -62
- data/lib/graphviz.rb +51 -40
- data/lib/graphviz/attrs.rb +1 -1
- data/lib/graphviz/constants.rb +1 -1
- data/lib/graphviz/dot2ruby.rb +5 -2
- data/lib/graphviz/edge.rb +181 -176
- data/lib/graphviz/node.rb +6 -1
- data/lib/graphviz/theory.rb +7 -7
- data/lib/graphviz/utils.rb +6 -22
- data/ruby-graphviz.gemspec +1 -5
- data/test/helper.rb +13 -0
- data/test/test_dot_script.rb +45 -41
- data/test/test_examples.rb +20 -30
- data/test/test_graph.rb +14 -3
- data/test/test_search.rb +1 -4
- data/test/test_subgraph.rb +14 -3
- data/test/test_theory.rb +15 -5
- data/test/test_types.rb +1 -3
- data/test/test_utils_colors.rb +1 -3
- metadata +26 -53
- data/test/support.rb +0 -105
data/test/support.rb
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'test/unit'
|
3
|
-
begin
|
4
|
-
require 'ruby-debug'
|
5
|
-
rescue LoadError
|
6
|
-
end
|
7
|
-
require 'stringio'
|
8
|
-
|
9
|
-
root = File.expand_path('../../lib',__FILE__)
|
10
|
-
$:.unshift(root) unless $:.include?(root)
|
11
|
-
|
12
|
-
require 'graphviz'
|
13
|
-
|
14
|
-
# hack so that the example scripts don't unnecessarily unshift @todo
|
15
|
-
class << $:
|
16
|
-
def unshift path
|
17
|
-
include?(path) ? self : super # super will return self, too
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
module TestSupport
|
22
|
-
extend self
|
23
|
-
|
24
|
-
# @todo move to app?
|
25
|
-
def windows?
|
26
|
-
/mswin|mingw/ =~ RUBY_PLATFORM
|
27
|
-
end
|
28
|
-
|
29
|
-
def dev_null
|
30
|
-
windows? ? 'NUL' : '/dev/null'
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
module IoHack
|
35
|
-
|
36
|
-
#
|
37
|
-
# this is a ridiculous hack to capture what was written to $stdout/$stderr for testing
|
38
|
-
# an alternative is to use Open3.popen3 on external calls which has overhead
|
39
|
-
# and OS dependencies.
|
40
|
-
#
|
41
|
-
# This hack would apparently not be as bad on 1.9, which would allow you to simply
|
42
|
-
# set $stdout and $stderr to instances of StringIO
|
43
|
-
#
|
44
|
-
# I don't know what is the 'right way' to test this kind of thing
|
45
|
-
#
|
46
|
-
|
47
|
-
class IoHackStream < File
|
48
|
-
#
|
49
|
-
# pre 1.9 you can't assign $stdout and $stderr to anything other than
|
50
|
-
# an IO::File instance. what we *want* is to have them be StringIOs that
|
51
|
-
# we can read from like strings for testing. So this is a crazy proxy
|
52
|
-
# around StringIO. Note it makes *all* methods except a few protected,
|
53
|
-
# which for me was failing silently when i forgot to make the appropriate
|
54
|
-
# ones public. hack!
|
55
|
-
#
|
56
|
-
|
57
|
-
except = %w(inspect kind_of?)
|
58
|
-
except += except.map{|x| x.to_sym } # for Ruby 1.9
|
59
|
-
these = ancestors[0].instance_methods
|
60
|
-
# these = [1,2,3].map{|x| ancestors[x].instance_methods(false)}.flatten
|
61
|
-
eraseme = (these - except)
|
62
|
-
eraseme.each{ |name| protected name }
|
63
|
-
attr_reader :io
|
64
|
-
def initialize()
|
65
|
-
@io = StringIO.new
|
66
|
-
super(TestSupport.dev_null, 'r+') # probably doesn't matter the mode
|
67
|
-
end
|
68
|
-
these = %w(write << puts)
|
69
|
-
these.each do |name|
|
70
|
-
define_method(name) do |*a|
|
71
|
-
@io.send(name, *a)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def fake_popen2 path
|
77
|
-
push_io
|
78
|
-
require path # caller assumes responsibility for exceptions vis-a-vis stack
|
79
|
-
pop_io
|
80
|
-
end
|
81
|
-
|
82
|
-
def io_stack
|
83
|
-
@io_stack ||= []
|
84
|
-
end
|
85
|
-
|
86
|
-
def push_io
|
87
|
-
io_stack.push [$stdout, $stderr]
|
88
|
-
$stdout = IoHackStream.new
|
89
|
-
$stderr = IoHackStream.new
|
90
|
-
nil
|
91
|
-
end
|
92
|
-
|
93
|
-
def pop_io
|
94
|
-
fail('stack empty') unless io_stack.any?
|
95
|
-
result = [$stdout, $stderr]
|
96
|
-
$stdout, $stderr = io_stack.pop
|
97
|
-
result.each_with_index do |io,idx|
|
98
|
-
if io.kind_of? IoHackStream
|
99
|
-
io.io.seek(0)
|
100
|
-
result[idx] = io.io.read
|
101
|
-
end
|
102
|
-
end
|
103
|
-
result
|
104
|
-
end
|
105
|
-
end
|