vispan 0.7.0 → 0.8.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: 0223f7cfd208708a1fab670b3ec424f1520bf969
4
- data.tar.gz: c298807c684cea9249d3341adcf5ad57cdca3155
3
+ metadata.gz: 9ab4cac77a347cba8000a50b246d075ec8df347d
4
+ data.tar.gz: 85ba9617355b813c1ab62b5e9d2bc35251d87ac1
5
5
  SHA512:
6
- metadata.gz: c39a467ef8ec4130b12d7cce31cafd95576227f4a4ca7f5ca90aba3c676bb92fa206d9e38a705c1832273f9540b7733929d21cae187a09895618fd6ec465ac0f
7
- data.tar.gz: a301dd388f4cddca1bbc8023ad168a645f2a8c0cc746918a862f1716b6ee1074fec50f1af381d535ec5dc22e1f15fb76bad12829be35b7d76cc76df475f32463
6
+ metadata.gz: a2566a5fa96f66fd86988373d9e68233c067a4af5ab0ccf36e1f9a95552dadc06ee7f2ebf2a22203e6c4178d5808bdc9e0fab0dcfe7c9a5a6c35026022240297
7
+ data.tar.gz: a959b1bd4b3b418dd4ef811583417b3b91ddf23c92f8ed608cdec50869c0a5ba09ce41f6f6a768551e504adb382d408d0401caf2dae83a772a27f638f098b41a
data/bin/generate CHANGED
@@ -5,7 +5,7 @@ require "./lib/vispan.rb"
5
5
  if ARGV.length == 2
6
6
  input_file = ARGV[0]
7
7
  output_file = ARGV[1]
8
- process = Vispan::WebPreview.new(input_file)
8
+ process = Vispan::WebPreview.new(input: input_file)
9
9
  process.display_text
10
10
  process.visualize(output_file)
11
11
  else
data/lib/vispan.rb CHANGED
@@ -3,19 +3,22 @@ require "vispan/relation.rb"
3
3
  require "vispan/node.rb"
4
4
  require "vispan/output_console.rb"
5
5
  require "vispan/output_graphic.rb"
6
+ require 'fileutils'
6
7
 
7
8
  module Vispan
8
- attr_reader :processed_string, :nodes, :text, :szenarios
9
+ attr_reader :szenarios
9
10
 
10
11
  class WebPreview
11
12
  def call(env)
12
- self.visualize('process.png')
13
- [200, {"Content-Type" => "image/png"}, [IO.read('process.png')]]
13
+ self.visualize(@output)
14
+ file_ending = File.extname(output_file).delete(".")
15
+ [200, {"Content-Type" => "image/#{file_ending}"}, [IO.read(@output)]]
14
16
  end
15
17
 
16
- def initialize(input_file)
18
+ def initialize(files)
19
+ @output = files[:output]
17
20
  @szenarios = []
18
- separate_szenarios(input_file)
21
+ separate_szenarios(files[:input])
19
22
  end
20
23
 
21
24
  def separate_szenarios(input_file)
@@ -31,7 +34,6 @@ module Vispan
31
34
  elsif line != "\n"
32
35
  @relation_lines << line
33
36
  end
34
-
35
37
  end
36
38
 
37
39
  @szenarios << @single_szenario
@@ -59,10 +61,8 @@ module Vispan
59
61
  end
60
62
 
61
63
  def visualize(output_file)
62
- png = OutputGraphic.new(@szenarios, output_file)
63
- png.generate
64
+ graphic = OutputGraphic.new(@szenarios, output_file)
65
+ graphic.generate
64
66
  end
65
-
66
67
  end
67
-
68
68
  end
data/lib/vispan/config.rb CHANGED
@@ -1,13 +1,17 @@
1
1
  NODE_WIDTH = 3.3
2
2
  NODE_MARGIN = 0.2
3
3
 
4
+ GENERAL_SETTINGS = {graph:{rankdir:"LR", labeljust:"l", splines:"ortho" },
5
+ node:{color:"none", shape:"rect", style:"rounded, filled", width:"#{NODE_WIDTH}", margin:"#{NODE_MARGIN}"},
6
+ edge:{}}
7
+
4
8
  SZENARIO = {szenario:{bgcolor:"mintcream:lightcyan", margin:60, fontsize:18}}
5
9
 
6
- NODE = {screen:{color:"none", shape:"rect", style:"rounded, filled", fillcolor:"yellowgreen:lemonchiffon", width:"#{NODE_WIDTH}", margin:"#{NODE_MARGIN}"},
7
- email:{color:"none", shape:"rect",style:"rounded, filled", fillcolor:"grey:ghostwhite", width:"#{NODE_WIDTH}", margin:"#{NODE_MARGIN}"},
8
- pdf:{color:"none", shape:"rect", style:"rounded, filled", fillcolor:"gold:orange", width:"#{NODE_WIDTH}", margin:"#{NODE_MARGIN}"},
9
- command:{color:"none", shape:"rect",style:"rounded, filled", fillcolor:"lightblue:steelblue", width:"#{NODE_WIDTH}", margin:"#{NODE_MARGIN}"}
10
- }
10
+ NODE = {screen:{fillcolor:"yellowgreen:lemonchiffon"},
11
+ email:{fillcolor:"grey:ghostwhite"},
12
+ pdf:{fillcolor:"gold:orange"},
13
+ command:{fillcolor:"lightblue:steelblue"}
14
+ }
11
15
  RELATION = {event:{color:"red"},
12
- link:{arrowhead:"none", arrowsize:"30"}
13
- }
16
+ link:{arrowhead:"none", arrowsize:"30"}
17
+ }
@@ -3,7 +3,7 @@ require "vispan/config.rb"
3
3
  class GraphWriter
4
4
 
5
5
  def build_string(szenarios)
6
- "Digraph G{ rankdir=LR; splines=ortho;labeljust=l#{szenarios.map.with_index {|szenario, index| build_szenario(szenario, index)}.join("")}}"
6
+ "Digraph G{ #{get_general_settings}#{szenarios.map.with_index {|szenario, index| build_szenario(szenario, index)}.join("")}}"
7
7
  end
8
8
 
9
9
  def build_szenario(szenario, index)
@@ -31,4 +31,7 @@ class GraphWriter
31
31
  GraphWriter.const_get(type)[element.type.to_sym].map{|attribute| "; #{attribute[0]}=\"#{attribute[1]}\""}.join("")
32
32
  end
33
33
 
34
+ def get_general_settings
35
+ GraphWriter.const_get("GENERAL_SETTINGS").map{|attribute| "#{attribute[0]} [#{attribute[1].map{|attri| "#{attri[0]}=\"#{attri[1]}\""}.join(";")}]"}.join(";")
36
+ end
34
37
  end
data/lib/vispan/node.rb CHANGED
@@ -12,5 +12,4 @@ class Node
12
12
  def transform_to_name(label, index)
13
13
  label.gsub(/[-\s.]/, "") + index.to_s
14
14
  end
15
-
16
15
  end
@@ -20,7 +20,6 @@ class OutputConsole
20
20
  @text += "\n"
21
21
  @text += "'#{rel.start.label}' führt zu '#{rel.stop.label}'"
22
22
  done << rel.start
23
-
24
23
  else
25
24
  @text += " und zu '#{rel.stop.label}'"
26
25
  end
@@ -29,5 +28,4 @@ class OutputConsole
29
28
  @text += "\n"
30
29
  end
31
30
  end
32
-
33
31
  end
@@ -17,7 +17,7 @@ class OutputGraphic
17
17
 
18
18
  def build_graph
19
19
  graph = GraphWriter.new()
20
- @processed_string = graph.build_string(@szenarios)
20
+ @processed_string = graph.build_string(@szenarios.reverse)
21
21
  end
22
22
 
23
23
  def generate_processed_file(processed_string)
@@ -26,15 +26,10 @@ class OutputGraphic
26
26
  end
27
27
 
28
28
  def generate_graph(output_file)
29
- file_ending = check_output(output_file)
29
+ FileUtils.mkdir_p File.dirname(output_file)
30
+ file_ending = File.extname(output_file).delete(".")
30
31
  cmd = "dot -T#{file_ending} #{@file.path} -o #{output_file}"
31
32
  system(cmd)
32
33
  @file.unlink
33
34
  end
34
-
35
- def check_output(output_file)
36
- output_file = output_file.to_s
37
- output_file.split(".")[1]
38
- end
39
-
40
35
  end
@@ -26,7 +26,6 @@ class Relation
26
26
  node_array = node_string.split(":")
27
27
  type = node_array[0].strip.downcase
28
28
  label = node_array[1].strip
29
- # puts label
30
29
  adjust_length(label)
31
30
  Node.new(type, label, index)
32
31
  end
@@ -40,10 +39,7 @@ class Relation
40
39
  empty = string[limit, string.length-limit].index(" ")
41
40
  string[limit+empty] = "\n"
42
41
  end
43
-
44
42
  }
45
43
  end
46
-
47
44
  end
48
-
49
45
  end
@@ -38,5 +38,4 @@ class Szenario
38
38
  return false if szenario_node.name == node.name
39
39
  end
40
40
  end
41
-
42
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vispan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Witek
@@ -10,26 +10,6 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2018-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rack
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '2.0'
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 2.0.1
23
- type: :runtime
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- requirements:
27
- - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: '2.0'
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: 2.0.1
33
13
  - !ruby/object:Gem::Dependency
34
14
  name: bundler
35
15
  requirement: !ruby/object:Gem::Requirement
@@ -113,4 +93,3 @@ signing_key:
113
93
  specification_version: 4
114
94
  summary: Visualize processes with simple syntax and multiple output formats
115
95
  test_files: []
116
- has_rdoc: