vispan 0.12.0 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vispan.rb +3 -1
- data/lib/vispan/config.rb +5 -4
- data/lib/vispan/graphwriter.rb +23 -3
- data/lib/vispan/node.rb +3 -2
- data/lib/vispan/relation.rb +7 -1
- data/lib/vispan/szenario.rb +31 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c00d545c86c8f83e10f5dbf39fadcc384271dca6
|
4
|
+
data.tar.gz: 934f4a88849dfa633e3357c58757e7266edbd6e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 488bca000babaa2f9382f5e051a785c9bf0c4f7e0f639c711ce66b981c46e70d70da3e879001203ac836d05b687ec9febb1c5553425502fce11c39b01313b2de
|
7
|
+
data.tar.gz: 625a53519aa63cb77692d307dbbb5860fa958420c878f6976c1e327210bafea13f4397aeab2dc2482c0eea244fd07f9ac6ed33c625875d0010a9369bc1ac7c8a
|
data/lib/vispan.rb
CHANGED
@@ -18,6 +18,9 @@ module Vispan
|
|
18
18
|
@output = files[:output]
|
19
19
|
@szenarios = []
|
20
20
|
separate_szenarios(files[:input])
|
21
|
+
@szenarios.each do |szenario|
|
22
|
+
szenario.assign_ranks
|
23
|
+
end
|
21
24
|
end
|
22
25
|
|
23
26
|
def separate_szenarios(input_file)
|
@@ -34,7 +37,6 @@ module Vispan
|
|
34
37
|
@relation_lines << line
|
35
38
|
end
|
36
39
|
end
|
37
|
-
|
38
40
|
@szenarios << @single_szenario
|
39
41
|
end
|
40
42
|
|
data/lib/vispan/config.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
NODE_WIDTH = 3.3
|
2
2
|
NODE_MARGIN = 0.2
|
3
3
|
|
4
|
-
GENERAL_SETTINGS = {graph:{rankdir:"LR", labeljust:"l", splines:"true" },
|
5
|
-
node:{
|
4
|
+
GENERAL_SETTINGS = {graph:{rankdir:"LR", labeljust:"l", splines:"true", concentrate: "true", ranksep:"2"},
|
5
|
+
node:{shape:"rect", color:"none", style:"rounded, filled", margin:"#{NODE_MARGIN}", width:"#{NODE_WIDTH}"},
|
6
6
|
edge:{}}
|
7
7
|
|
8
8
|
SZENARIO = {szenario:{bgcolor:"mintcream:lightcyan", margin:60, fontsize:18}}
|
@@ -10,8 +10,9 @@ SZENARIO = {szenario:{bgcolor:"mintcream:lightcyan", margin:60, fontsize:18}}
|
|
10
10
|
NODE = {screen:{fillcolor:"yellowgreen:lemonchiffon"},
|
11
11
|
email:{fillcolor:"grey:ghostwhite"},
|
12
12
|
pdf:{fillcolor:"gold:orange"},
|
13
|
-
command:{fillcolor:"lightblue:steelblue"}
|
13
|
+
command:{fillcolor:"lightblue:steelblue"},
|
14
|
+
helper:{shape:"plaintext", fillcolor:"none", width:"0.01", height:"0.01", margin:"0.15"}
|
14
15
|
}
|
15
16
|
RELATION = {event:{color:"red"},
|
16
|
-
link:{
|
17
|
+
link:{arrowsize:"0.7", style:"dashed"}
|
17
18
|
}
|
data/lib/vispan/graphwriter.rb
CHANGED
@@ -3,23 +3,43 @@ require "vispan/config.rb"
|
|
3
3
|
class GraphWriter
|
4
4
|
|
5
5
|
def build_string(szenarios)
|
6
|
+
# puts "Digraph G{ #{get_general_settings}#{szenarios.map.with_index {|szenario, index| build_szenario(szenario, index)}.join("")}}"
|
6
7
|
"Digraph G{ #{get_general_settings}#{szenarios.map.with_index {|szenario, index| build_szenario(szenario, index)}.join("")}}"
|
7
8
|
end
|
8
9
|
|
9
10
|
def build_szenario(szenario, index)
|
10
11
|
node_definitions = szenario.nodes.map{|node| write_node(node)}.join("")
|
11
|
-
relation_definitions = szenario.relations.map{|relation| write_relations(relation)}.join("")
|
12
|
+
relation_definitions = szenario.relations.map{|relation| write_relations(relation, szenario)}.join("")
|
12
13
|
effect_definitions = szenario.relations.map {|relation| write_effects(relation)}.join("")
|
13
14
|
|
14
15
|
"\n\nsubgraph cluster#{index.to_s} {label=\"#{szenario.title}\"#{find_attributes(szenario)};\n#{node_definitions}\n#{relation_definitions}#{effect_definitions}}"
|
15
16
|
end
|
16
17
|
|
17
18
|
def write_node(node)
|
19
|
+
# puts node.inspect
|
18
20
|
"#{node.name} [label=\"#{node.label}\" #{find_attributes(node)}]\n"
|
21
|
+
# [label=<<TABLE BORDER=\"0\" CELLBORDER=\"0\" CELLSPACING=\"0\" ><TR><TD PORT=\"#{node.name}\">#{node.label}</TD></TR></TABLE>> #{find_attributes(node)}]\n"
|
22
|
+
|
19
23
|
end
|
20
24
|
|
21
|
-
def write_relations(relation)
|
22
|
-
|
25
|
+
def write_relations(relation, szenario)
|
26
|
+
|
27
|
+
if relation.get_direction < 0
|
28
|
+
previous_node_name = szenario.get_previous_helper_node(relation)
|
29
|
+
"#{relation.start.name}:w-> #{relation.helper.name}:e [dir=\"none\" #{find_attributes(relation)}];
|
30
|
+
#{relation.helper.name}:w -> #{relation.stop.name}:e [dir=\"forward\" #{find_attributes(relation)}];
|
31
|
+
{rank = same; #{previous_node_name}; #{relation.helper.name};}"
|
32
|
+
else
|
33
|
+
#
|
34
|
+
#
|
35
|
+
# return "#{relation.helper.name} -> #{relation.stop.name} [dir=\"forward\" #{find_attributes(relation)}];
|
36
|
+
# #{relation.start.name}-> #{relation.helper.name} [dir=\"none\" #{find_attributes(relation)}];
|
37
|
+
# {rank = same; helper_0Angebotspostenerteilen0; #{relation.helper.name};}"
|
38
|
+
# end
|
39
|
+
# puts "#{relation.start.name} #{relation.start.rank} führt zurück zu #{relation.stop.name} #{relation.stop.rank}" if relation.start.rank > relation.stop.rank
|
40
|
+
"#{relation.start.name}:e-> #{relation.helper.name}:w [dir=\"none\" #{find_attributes(relation)}];
|
41
|
+
#{relation.helper.name}:e -> #{relation.stop.name}:w [dir=\"forward\" #{find_attributes(relation)}]\n"
|
42
|
+
end
|
23
43
|
end
|
24
44
|
|
25
45
|
def write_effects(relation)
|
data/lib/vispan/node.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
class Node
|
2
2
|
|
3
|
-
attr_accessor :name, :type, :label
|
4
|
-
NODE_TYPES = ["screen", "email", "pdf", "command"]
|
3
|
+
attr_accessor :name, :type, :label, :rank
|
4
|
+
NODE_TYPES = ["screen", "email", "pdf", "command", "helper"]
|
5
5
|
|
6
6
|
def initialize(type, label, index)
|
7
7
|
@name = transform_to_name(label, index)
|
8
8
|
@type = NODE_TYPES.include?(type)? type : ""
|
9
9
|
@label = label
|
10
|
+
@rank = 0
|
10
11
|
end
|
11
12
|
|
12
13
|
def transform_to_name(label, index)
|
data/lib/vispan/relation.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
class Relation
|
2
|
-
attr_accessor :start, :stop, :type, :effects, :label
|
2
|
+
attr_accessor :start, :stop, :type, :effects, :label, :helper
|
3
3
|
|
4
4
|
def initialize(relation_array, index)
|
5
5
|
@effects = []
|
6
6
|
@label = ""
|
7
7
|
|
8
8
|
extract(relation_array, index)
|
9
|
+
@helper = Node.new("helper", @label, index)
|
10
|
+
@helper.name = "helper_"+ @helper.name + @stop.name
|
9
11
|
end
|
10
12
|
|
11
13
|
def extract(relation_array, index)
|
@@ -42,4 +44,8 @@ class Relation
|
|
42
44
|
}
|
43
45
|
end
|
44
46
|
end
|
47
|
+
|
48
|
+
def get_direction
|
49
|
+
@stop.rank - @start.rank
|
50
|
+
end
|
45
51
|
end
|
data/lib/vispan/szenario.rb
CHANGED
@@ -24,8 +24,9 @@ class Szenario
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def add_relation(relation)
|
27
|
+
add_nodes([relation.start, relation.stop, relation.helper, relation.effects])
|
28
|
+
replace_with_existing_nodes(relation, @nodes)
|
27
29
|
@relations << relation
|
28
|
-
add_nodes([relation.start, relation.stop, relation.effects])
|
29
30
|
end
|
30
31
|
|
31
32
|
def add_nodes(nodes_array)
|
@@ -38,4 +39,33 @@ class Szenario
|
|
38
39
|
return false if szenario_node.name == node.name
|
39
40
|
end
|
40
41
|
end
|
42
|
+
|
43
|
+
def replace_with_existing_nodes(relation, nodes)
|
44
|
+
nodes.each do |node|
|
45
|
+
relation.start = node if relation.start.name == node.name
|
46
|
+
relation.stop = node if relation.stop.name == node.name
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def assign_ranks
|
51
|
+
rank = @relations.map{|relation|
|
52
|
+
|
53
|
+
if relation.start.rank == 0
|
54
|
+
relation.start.rank = 1
|
55
|
+
relation.stop.rank = 2 unless relation.stop.rank > 0
|
56
|
+
elsif relation.stop.rank == 0
|
57
|
+
relation.stop.rank = relation.start.rank + 1
|
58
|
+
end
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
62
|
+
def get_previous_helper_node(relation2)
|
63
|
+
@relations.each do |relation|
|
64
|
+
|
65
|
+
if relation2.start.name == relation.stop.name
|
66
|
+
return relation.helper.name
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
41
71
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vispan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Witek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|