dogviz 0.0.13 → 0.0.14
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/lib/dogviz/version.rb +1 -1
- data/lib/dogviz.rb +15 -1
- data/tests/graph_checking.rb +33 -0
- data/tests/test_dogviz_flows.rb +91 -0
- data/tests/test_dogviz_functionally.rb +0 -72
- data/tests/test_dogviz_graphviz_rendering.rb +2 -34
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad63138af5aec7bfff4533f7407f03f9c0c293c5
|
4
|
+
data.tar.gz: ad75faa51b2a4bdd297fbe28ab5a41314879a869
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f05df9e542952cd2208834f9531820ca0515085eedd9a3f4eba54c15c4674cd6c1b2c115c34519efc1343707ae005888feb034cf341279990411821e9dcc737f
|
7
|
+
data.tar.gz: 09e6f76ddd0032713df169c031d5585b03c5f0eca9037451652f9213eeec9660ff594d209e3543328ae0d1d6d562daee53fa86a59964c5b88dbc6416290b2bef
|
data/lib/dogviz/version.rb
CHANGED
data/lib/dogviz.rb
CHANGED
@@ -12,6 +12,7 @@ module Dogviz
|
|
12
12
|
def description
|
13
13
|
@description
|
14
14
|
end
|
15
|
+
attr_reader :processor
|
15
16
|
end
|
16
17
|
module Flowable
|
17
18
|
def does(action)
|
@@ -402,6 +403,12 @@ module Dogviz
|
|
402
403
|
@calls = []
|
403
404
|
end
|
404
405
|
|
406
|
+
def make_connections
|
407
|
+
calls.each {|from, to, label|
|
408
|
+
thing_of(from).points_to thing_of(to), label: label
|
409
|
+
}
|
410
|
+
end
|
411
|
+
|
405
412
|
def flows(*steps)
|
406
413
|
from = nil
|
407
414
|
to = nil
|
@@ -440,8 +447,15 @@ module Dogviz
|
|
440
447
|
end
|
441
448
|
renderer.rendered
|
442
449
|
end
|
450
|
+
|
443
451
|
private
|
444
|
-
|
452
|
+
|
453
|
+
attr_reader :calls, :sys
|
454
|
+
|
455
|
+
def thing_of(it)
|
456
|
+
return it.processor if it.is_a?(Process)
|
457
|
+
it
|
458
|
+
end
|
445
459
|
end
|
446
460
|
|
447
461
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module GraphChecking
|
2
|
+
def subgraph_ids
|
3
|
+
subgraphs.map(&:id)
|
4
|
+
end
|
5
|
+
|
6
|
+
def subgraph(id)
|
7
|
+
subgraphs.find {|sub| sub.id == id }
|
8
|
+
end
|
9
|
+
|
10
|
+
def subgraphs(from=graph)
|
11
|
+
subs = []
|
12
|
+
from.each_graph {|sub_name, sub|
|
13
|
+
subs << sub
|
14
|
+
subs += subgraphs(sub)
|
15
|
+
}
|
16
|
+
subs
|
17
|
+
end
|
18
|
+
|
19
|
+
def connections(sep=' ')
|
20
|
+
edges.map {|e|
|
21
|
+
"#{e.tail_node}->#{e.head_node}"
|
22
|
+
}.join sep
|
23
|
+
end
|
24
|
+
|
25
|
+
def edges
|
26
|
+
graph.each_edge
|
27
|
+
end
|
28
|
+
|
29
|
+
def find(name)
|
30
|
+
graph.find_node name
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require_relative 'setup_tests'
|
2
|
+
require_relative 'graph_checking'
|
3
|
+
|
4
|
+
module Tests
|
5
|
+
class TestDogvizFlows < Test::Unit::TestCase
|
6
|
+
include GraphChecking
|
7
|
+
|
8
|
+
def outfile(ext)
|
9
|
+
"/tmp/dogviz_flow_test.#{ext}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def read_outfile(ext)
|
13
|
+
File.read outfile(ext)
|
14
|
+
end
|
15
|
+
|
16
|
+
include Dogviz
|
17
|
+
|
18
|
+
def test_flow_generates_precise_sequence
|
19
|
+
sys = System.new 'takeaway'
|
20
|
+
eater = sys.thing 'eater'
|
21
|
+
server = sys.thing 'server'
|
22
|
+
cook = sys.thing 'chef'
|
23
|
+
|
24
|
+
order = sys.flow 'order'
|
25
|
+
order.flows eater, 'gimme burger',
|
26
|
+
server, 'passes order',
|
27
|
+
cook, server, eater
|
28
|
+
|
29
|
+
order.output sequence: outfile('seq.txt')
|
30
|
+
|
31
|
+
definition = read_outfile('seq.txt')
|
32
|
+
|
33
|
+
assert_equal [
|
34
|
+
'eater -> server: gimme burger',
|
35
|
+
'server -> chef: passes order',
|
36
|
+
'chef -> server:',
|
37
|
+
'server -> eater:',
|
38
|
+
].join("\n"), definition
|
39
|
+
end
|
40
|
+
|
41
|
+
def create_food_flow
|
42
|
+
@sys = System.new 'takeaway'
|
43
|
+
eater = sys.thing 'eater'
|
44
|
+
server = sys.thing 'server'
|
45
|
+
cook = sys.thing 'cook'
|
46
|
+
|
47
|
+
order = sys.flow 'order'
|
48
|
+
order.flows eater, 'orders',
|
49
|
+
server, 'creates order',
|
50
|
+
cook.does('cooks burger'),
|
51
|
+
'burger', server,
|
52
|
+
'burger', eater
|
53
|
+
order
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_flow_generates_precise_sequence_with_action
|
57
|
+
order = create_food_flow
|
58
|
+
|
59
|
+
order.output sequence: outfile('seq.txt')
|
60
|
+
definition = read_outfile('seq.txt')
|
61
|
+
|
62
|
+
assert_equal([
|
63
|
+
'eater -> server: orders',
|
64
|
+
'server -> +cook: creates order',
|
65
|
+
'note right of cook',
|
66
|
+
' cooks burger',
|
67
|
+
'end note',
|
68
|
+
'cook -> -server: burger',
|
69
|
+
'server -> eater: burger',
|
70
|
+
].join("\n"), definition)
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_flow_can_be_used_to_make_connections_in_dog
|
74
|
+
order = create_food_flow
|
75
|
+
|
76
|
+
order.make_connections
|
77
|
+
|
78
|
+
assert_equal('eater->server server->cook server->eater cook->server', connections)
|
79
|
+
end
|
80
|
+
|
81
|
+
private
|
82
|
+
|
83
|
+
attr_accessor :sys
|
84
|
+
|
85
|
+
def graph
|
86
|
+
g = sys.render
|
87
|
+
sys.output svg: outfile('svg')
|
88
|
+
g
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -52,77 +52,5 @@ module Tests
|
|
52
52
|
assert_equal ['chases', 'follows', 'parents', 'ignores'], graph.names_of.edges
|
53
53
|
end
|
54
54
|
|
55
|
-
def test_flow_generates_precise_sequence
|
56
|
-
sys = System.new 'takeaway'
|
57
|
-
eater = sys.thing 'eater'
|
58
|
-
server = sys.thing 'server'
|
59
|
-
cook = sys.thing 'chef'
|
60
|
-
|
61
|
-
order = sys.flow 'order'
|
62
|
-
order.flows eater, 'gimme burger',
|
63
|
-
server, 'passes order',
|
64
|
-
cook, server, eater
|
65
|
-
|
66
|
-
order.output sequence: outfile('seq.txt')
|
67
|
-
|
68
|
-
definition = read_outfile('seq.txt')
|
69
|
-
|
70
|
-
assert_equal [
|
71
|
-
'eater -> server: gimme burger',
|
72
|
-
'server -> chef: passes order',
|
73
|
-
'chef -> server:',
|
74
|
-
'server -> eater:',
|
75
|
-
].join("\n"), definition
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_flow_generates_precise_sequence_with_action
|
79
|
-
sys = System.new 'takeaway'
|
80
|
-
eater = sys.thing 'eater'
|
81
|
-
server = sys.thing 'server'
|
82
|
-
cook = sys.thing 'cook'
|
83
|
-
|
84
|
-
order = sys.flow 'order'
|
85
|
-
order.flows eater, 'orders',
|
86
|
-
server, 'creates order',
|
87
|
-
cook.does('cooks burger'),
|
88
|
-
'burger', server,
|
89
|
-
'burger', eater
|
90
|
-
|
91
|
-
order.output sequence: outfile('seq.txt')
|
92
|
-
definition = read_outfile('seq.txt')
|
93
|
-
|
94
|
-
assert_equal([
|
95
|
-
'eater -> server: orders',
|
96
|
-
'server -> +cook: creates order',
|
97
|
-
'note right of cook',
|
98
|
-
' cooks burger',
|
99
|
-
'end note',
|
100
|
-
'cook -> -server: burger',
|
101
|
-
'server -> eater: burger',
|
102
|
-
].join("\n"), definition)
|
103
|
-
end
|
104
|
-
|
105
|
-
def xtest_flows_render_sequence_diagrams_and_form_edges
|
106
|
-
|
107
|
-
sys = System.new 'service'
|
108
|
-
|
109
|
-
organisation = sys.container 'organisation'
|
110
|
-
|
111
|
-
customer = sys.thing 'customer'
|
112
|
-
|
113
|
-
support = organisation.thing 'support phone line'
|
114
|
-
ivr = organisation.thing 'ivr'
|
115
|
-
first = organisation.thing 'first level support'
|
116
|
-
second = organisation.thing 'second level support'
|
117
|
-
|
118
|
-
complaint = sys.flow 'complaint'
|
119
|
-
|
120
|
-
complain.flows customer, 'calls',
|
121
|
-
support, 'connects to',
|
122
|
-
ivr, ''
|
123
|
-
|
124
|
-
|
125
|
-
end
|
126
|
-
|
127
55
|
end
|
128
56
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
require_relative 'setup_tests'
|
2
|
+
require_relative 'graph_checking'
|
2
3
|
|
3
4
|
class TestDogvizGraphvizRendering < Test::Unit::TestCase
|
4
5
|
include Dogviz
|
6
|
+
include GraphChecking
|
5
7
|
|
6
8
|
attr_reader :sys
|
7
9
|
|
@@ -346,38 +348,4 @@ class TestDogvizGraphvizRendering < Test::Unit::TestCase
|
|
346
348
|
assert_equal('thread->haystack_nested_hidden_away_needle', connections)
|
347
349
|
end
|
348
350
|
|
349
|
-
|
350
|
-
private
|
351
|
-
|
352
|
-
def subgraph_ids
|
353
|
-
subgraphs.map(&:id)
|
354
|
-
end
|
355
|
-
|
356
|
-
def subgraph(id)
|
357
|
-
subgraphs.find {|sub| sub.id == id }
|
358
|
-
end
|
359
|
-
|
360
|
-
def subgraphs(from=graph)
|
361
|
-
subs = []
|
362
|
-
from.each_graph {|sub_name, sub|
|
363
|
-
subs << sub
|
364
|
-
subs += subgraphs(sub)
|
365
|
-
}
|
366
|
-
subs
|
367
|
-
end
|
368
|
-
|
369
|
-
def connections(sep=' ')
|
370
|
-
edges.map {|e|
|
371
|
-
"#{e.tail_node}->#{e.head_node}"
|
372
|
-
}.join sep
|
373
|
-
end
|
374
|
-
|
375
|
-
def edges
|
376
|
-
graph.each_edge
|
377
|
-
end
|
378
|
-
|
379
|
-
def find(name)
|
380
|
-
graph.find_node name
|
381
|
-
end
|
382
|
-
|
383
351
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dogviz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- damned
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -113,8 +113,10 @@ files:
|
|
113
113
|
- examples/website_domain.rb
|
114
114
|
- lib/dogviz.rb
|
115
115
|
- lib/dogviz/version.rb
|
116
|
+
- tests/graph_checking.rb
|
116
117
|
- tests/setup_tests.rb
|
117
118
|
- tests/svg_graph.rb
|
119
|
+
- tests/test_dogviz_flows.rb
|
118
120
|
- tests/test_dogviz_functionally.rb
|
119
121
|
- tests/test_dogviz_graph.rb
|
120
122
|
- tests/test_dogviz_graphviz_rendering.rb
|