cpee-transformation 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.
Files changed (39) hide show
  1. checksums.yaml +7 -0
  2. data/AUTHORS +2 -0
  3. data/LICENSE +165 -0
  4. data/README.md +1 -0
  5. data/Rakefile +21 -0
  6. data/cpee-transformation.gemspec +29 -0
  7. data/lib/cpee/transformation/beautiful.rb +182 -0
  8. data/lib/cpee/transformation/bpmn2.rb +144 -0
  9. data/lib/cpee/transformation/cpee.rb +309 -0
  10. data/lib/cpee/transformation/dataflow.rb +127 -0
  11. data/lib/cpee/transformation/graphviz.rb +100 -0
  12. data/lib/cpee/transformation/implementation.rb +144 -0
  13. data/lib/cpee/transformation/implementation.xml +47 -0
  14. data/lib/cpee/transformation/mermaid.rb +242 -0
  15. data/lib/cpee/transformation/ptml.rb +316 -0
  16. data/lib/cpee/transformation/structures.rb +570 -0
  17. data/lib/cpee/transformation/target.rb +58 -0
  18. data/lib/cpee/transformation/text-bf.rb +201 -0
  19. data/lib/cpee/transformation/text-df-PO-extended.rb +221 -0
  20. data/lib/cpee/transformation/text-df-PO-reduced.rb +211 -0
  21. data/lib/cpee/transformation/transformation_text_cpee.xml +49 -0
  22. data/lib/cpee/transformation/transformation_xml_cpee.xml +49 -0
  23. data/lib/cpee/transformation/transformation_xml_text.xml +49 -0
  24. data/lib/cpee/transformation/transformer.rb +300 -0
  25. data/server/trans +38 -0
  26. data/tools/bpmn2_to_cpee.rb +84 -0
  27. data/tools/bpmn2_to_mermaid.rb +85 -0
  28. data/tools/bpmn2_to_ptml.rb +87 -0
  29. data/tools/cpee-trans +74 -0
  30. data/tools/cpee_to_cpee.rb +83 -0
  31. data/tools/cpee_to_dataflow.rb +83 -0
  32. data/tools/cpee_to_mermaid.rb +85 -0
  33. data/tools/cpee_to_ptml.rb +87 -0
  34. data/tools/cpee_to_text_bf.rb +85 -0
  35. data/tools/cpee_to_text_df-poe.rb +85 -0
  36. data/tools/cpee_to_text_df-por.rb +85 -0
  37. data/tools/mermaid_to_cpee.rb +85 -0
  38. data/tools/ptml_to_cpee.rb +87 -0
  39. metadata +160 -0
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/ruby
2
+ # encoding: UTF-8
3
+ #
4
+ # This file is part of CPEE-TRANSFORMATION.
5
+ #
6
+ # CPEE-TRANSFORMATION is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU Lesser General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or (at your
9
+ # option) any later version.
10
+ #
11
+ # CPEE-TRANSFORMATION is distributed in the hope that it will be useful, but
12
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
14
+ # for more details.
15
+ #
16
+ # You should have received a copy of the GNU Lesser General Public License
17
+ # along with CPEE-TRANSFORMATION (file COPYING in the main directory). If not,
18
+ # see <http://www.gnu.org/licenses/>.
19
+
20
+ def wrap(s1, s2, width=78, indent=ARGV.options.summary_width + 3)
21
+ lines = []
22
+ s = ARGV.options.summary_indent + s1 + ' ' * (indent - s1.length - ARGV.options.summary_indent.length) + s2
23
+ line, s = s[0..indent-2], s[indent..-1]
24
+ s.split(/\n/).each do |ss|
25
+ ss.split(/[ \t]+/).each do |word|
26
+ if line.size + word.size >= width
27
+ lines << line
28
+ line = (" " * (indent)) + word
29
+ else
30
+ line << " " << word
31
+ end
32
+ end
33
+ lines << line if line
34
+ line = (" " * (indent-1))
35
+ end
36
+ return lines.join("\n")
37
+ end
38
+
39
+ require 'optparse'
40
+
41
+ require_relative '../lib/cpee/transformation/transformer' rescue nil
42
+ require_relative '../lib/cpee/transformation/bpmn2' rescue nil
43
+ require_relative '../lib/cpee/transformation/ptml' rescue nil
44
+
45
+ interactive = false
46
+ printtree = false
47
+
48
+ ARGV.options { |opt|
49
+ opt.summary_indent = ' ' * 2
50
+ opt.summary_width = 18
51
+ opt.banner = "Usage:\n#{opt.summary_indent}#{File.basename($0)} FNAME\n"
52
+ opt.on("Options:")
53
+ opt.on("--help", "-h", "This text") { puts opt; exit }
54
+ opt.on("--interactive", "-i", "Interactive mode") { interactive = true }
55
+ opt.on("--tree", "-t", "Print tree") { printtree = true }
56
+ opt.on("")
57
+ opt.on(wrap("[FNAME]","convert cpee tree in file FNAME to cpee and output to console."))
58
+ opt.parse!
59
+ }
60
+
61
+ if ARGV.length != 1
62
+ puts ARGV.options
63
+ exit
64
+ else
65
+ f = ARGV[0]
66
+ end
67
+
68
+ model = CPEE::Transformation::Source::BPMN2.new(File.read(f))
69
+
70
+ trans = CPEE::Transformation::Transformer.new(model)
71
+ traces = trans.build_traces
72
+
73
+ if interactive
74
+ puts traces.legend
75
+ puts
76
+ tree = trans.build_tree(true)
77
+ else
78
+ tree = trans.build_tree(false)
79
+ end
80
+
81
+ pp tree
82
+
83
+ if printtree
84
+ puts tree.to_s
85
+ else
86
+ puts trans.generate_model(CPEE::Transformation::Target::PTML)
87
+ end
data/tools/cpee-trans ADDED
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/ruby
2
+ #
3
+ # This file is part of CPEE-TRANSFORMATION.
4
+ #
5
+ # CPEE-TRANSFORMATION is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or (at your
8
+ # option) any later version.
9
+ #
10
+ # CPEE-TRANSFORMATION is distributed in the hope that it will be useful, but
11
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13
+ # for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with CPEE-TRANSFORMATION (file LICENSE in the main directory). If not,
17
+ # see <http://www.gnu.org/licenses/>.
18
+
19
+ curpath = __dir__
20
+ require 'rubygems'
21
+ require 'optparse'
22
+ require 'fileutils'
23
+ require 'xml/smart'
24
+ require 'yaml'
25
+ require 'typhoeus'
26
+ require 'stringio'
27
+
28
+ def wrap(s, width=78, indent=18, extra_indent=4) #{{{
29
+ lines = []
30
+ line, s = s[0..indent-2], s[indent..-1]
31
+ s.split(/\n/).each do |ss|
32
+ ss.split(/[ \t]+/).each do |word|
33
+ if line.size + word.size >= width
34
+ lines << line
35
+ line = (" " * (indent + extra_indent)) + word
36
+ else
37
+ line << " " << word
38
+ end
39
+ end
40
+ lines << line if line
41
+ line = (" " * (indent-1))
42
+ end
43
+ return lines.join "\n"
44
+ end #}}}
45
+
46
+ exname = File.basename($0)
47
+
48
+ ARGV.options { |opt|
49
+ opt.summary_indent = ' ' * 2
50
+ opt.summary_width = 11
51
+ opt.banner = "Usage:\n#{opt.summary_indent}#{exname} new [DIR] | cpui [DIR]\n"
52
+ opt.on("Options:")
53
+ opt.on("--help", "-h", "This text") { puts opt; exit }
54
+ opt.on("")
55
+ opt.on(wrap("new [DIR] scaffolds a sample transformation service.",78,14,0))
56
+ opt.parse!
57
+ }
58
+ if (ARGV.length != 2)
59
+ puts ARGV.options
60
+ exit
61
+ else
62
+ command = ARGV[0]
63
+ dir = ARGV[1]
64
+ end
65
+
66
+ if command == 'new'
67
+ if !File.exist?(dir)
68
+ FileUtils.cp_r(File.join(curpath,'..','server'),dir)
69
+ else
70
+ puts 'Directory already exists.'
71
+ end
72
+ else
73
+ puts ARGV.options
74
+ end
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/ruby
2
+ # encoding: UTF-8
3
+ #
4
+ # This file is part of CPEE-TRANSFORMATION.
5
+ #
6
+ # CPEE-TRANSFORMATION is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU Lesser General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or (at your
9
+ # option) any later version.
10
+ #
11
+ # CPEE-TRANSFORMATION is distributed in the hope that it will be useful, but
12
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
14
+ # for more details.
15
+ #
16
+ # You should have received a copy of the GNU Lesser General Public License
17
+ # along with CPEE-TRANSFORMATION (file COPYING in the main directory). If not,
18
+ # see <http://www.gnu.org/licenses/>.
19
+
20
+ def wrap(s1, s2, width=78, indent=ARGV.options.summary_width + 3)
21
+ lines = []
22
+ s = ARGV.options.summary_indent + s1 + ' ' * (indent - s1.length - ARGV.options.summary_indent.length) + s2
23
+ line, s = s[0..indent-2], s[indent..-1]
24
+ s.split(/\n/).each do |ss|
25
+ ss.split(/[ \t]+/).each do |word|
26
+ if line.size + word.size >= width
27
+ lines << line
28
+ line = (" " * (indent)) + word
29
+ else
30
+ line << " " << word
31
+ end
32
+ end
33
+ lines << line if line
34
+ line = (" " * (indent-1))
35
+ end
36
+ return lines.join("\n")
37
+ end
38
+
39
+ require 'optparse'
40
+
41
+ require_relative '../lib/cpee/transformation/transformer' rescue nil
42
+ require_relative '../lib/cpee/transformation/cpee' rescue nil
43
+
44
+ interactive = false
45
+ printtree = false
46
+
47
+ ARGV.options { |opt|
48
+ opt.summary_indent = ' ' * 2
49
+ opt.summary_width = 18
50
+ opt.banner = "Usage:\n#{opt.summary_indent}#{File.basename($0)} FNAME\n"
51
+ opt.on("Options:")
52
+ opt.on("--help", "-h", "This text") { puts opt; exit }
53
+ opt.on("--interactive", "-i", "Interactive mode") { interactive = true }
54
+ opt.on("--tree", "-t", "Print tree") { printtree = true }
55
+ opt.on("")
56
+ opt.on(wrap("[FNAME]","convert cpee tree in file FNAME to cpee and output to console."))
57
+ opt.parse!
58
+ }
59
+
60
+ if ARGV.length != 1
61
+ puts ARGV.options
62
+ exit
63
+ else
64
+ f = ARGV[0]
65
+ end
66
+
67
+ model = CPEE::Transformation::Source::CPEE.new(File.read(f))
68
+
69
+ trans = CPEE::Transformation::Transformer.new(model)
70
+ traces = trans.build_traces
71
+
72
+ if interactive
73
+ puts traces.legend
74
+ tree = trans.build_tree(true)
75
+ else
76
+ tree = trans.build_tree(false)
77
+ end
78
+
79
+ if printtree
80
+ puts tree.to_s
81
+ else
82
+ puts trans.generate_model(CPEE::Transformation::Target::CPEE)
83
+ end
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/ruby
2
+ # encoding: UTF-8
3
+ #
4
+ # This file is part of cpee-transformation.
5
+ #
6
+ # cpee-transformation is free software: you can redistribute it and/or modify it under the terms
7
+ # of the GNU Lesser General Public License as published by the Free Software Foundation,
8
+ # either version 3 of the License, or (at your option) any later version.
9
+ #
10
+ # cpee-transformation is distributed in the hope that it will be useful, but WITHOUT ANY
11
+ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12
+ # PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU Lesser General Public License along with
15
+ # cpee-transformation (file COPYING in the main directory). If not, see
16
+ # <http://www.gnu.org/licenses/>.
17
+
18
+ def wrap(s1, s2, width=78, indent=ARGV.options.summary_width + 3)
19
+ lines = []
20
+ s = ARGV.options.summary_indent + s1 + ' ' * (indent - s1.length - ARGV.options.summary_indent.length) + s2
21
+ line, s = s[0..indent-2], s[indent..-1]
22
+ s.split(/\n/).each do |ss|
23
+ ss.split(/[ \t]+/).each do |word|
24
+ if line.size + word.size >= width
25
+ lines << line
26
+ line = (" " * (indent)) + word
27
+ else
28
+ line << " " << word
29
+ end
30
+ end
31
+ lines << line if line
32
+ line = (" " * (indent-1))
33
+ end
34
+ return lines.join("\n")
35
+ end
36
+
37
+ require 'optparse'
38
+
39
+ require_relative '../lib/cpee/transformation/transformer' rescue nil
40
+ require_relative '../lib/cpee/transformation/cpee' rescue nil
41
+ require_relative '../lib/cpee/transformation/dataflow' rescue nil
42
+
43
+ interactive = false
44
+ printtree = false
45
+
46
+ ARGV.options { |opt|
47
+ opt.summary_indent = ' ' * 2
48
+ opt.summary_width = 18
49
+ opt.banner = "Usage:\n#{opt.summary_indent}#{File.basename($0)} FNAME\n"
50
+ opt.on("Options:")
51
+ opt.on("--help", "-h", "This text") { puts opt; exit }
52
+ opt.on("--interactive", "-i", "Interactive mode") { interactive = true }
53
+ opt.on("--tree", "-t", "Print tree") { printtree = true }
54
+ opt.on("")
55
+ opt.on(wrap("[FNAME]","convert cpee tree in file FNAME to mermaid and output to console."))
56
+ opt.parse!
57
+ }
58
+
59
+ if ARGV.length != 1
60
+ puts ARGV.options
61
+ exit
62
+ else
63
+ f = ARGV[0]
64
+ end
65
+
66
+ model = CPEE::Transformation::Source::CPEE.new(File.read(f))
67
+
68
+ trans = CPEE::Transformation::Transformer.new(model)
69
+ traces = trans.build_traces
70
+
71
+ if interactive
72
+ puts traces.legend
73
+ puts
74
+ tree = trans.build_tree(true)
75
+ else
76
+ tree = trans.build_tree(false)
77
+ end
78
+
79
+ if printtree
80
+ puts tree.to_s
81
+ else
82
+ puts trans.generate_model(CPEE::Transformation::Target::DataFlow)
83
+ end
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/ruby
2
+ # encoding: UTF-8
3
+ #
4
+ # This file is part of CPEE-TRANSFORMATION.
5
+ #
6
+ # CPEE-TRANSFORMATION is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU Lesser General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or (at your
9
+ # option) any later version.
10
+ #
11
+ # CPEE-TRANSFORMATION is distributed in the hope that it will be useful, but
12
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
14
+ # for more details.
15
+ #
16
+ # You should have received a copy of the GNU Lesser General Public License
17
+ # along with CPEE-TRANSFORMATION (file COPYING in the main directory). If not,
18
+ # see <http://www.gnu.org/licenses/>.
19
+
20
+ def wrap(s1, s2, width=78, indent=ARGV.options.summary_width + 3)
21
+ lines = []
22
+ s = ARGV.options.summary_indent + s1 + ' ' * (indent - s1.length - ARGV.options.summary_indent.length) + s2
23
+ line, s = s[0..indent-2], s[indent..-1]
24
+ s.split(/\n/).each do |ss|
25
+ ss.split(/[ \t]+/).each do |word|
26
+ if line.size + word.size >= width
27
+ lines << line
28
+ line = (" " * (indent)) + word
29
+ else
30
+ line << " " << word
31
+ end
32
+ end
33
+ lines << line if line
34
+ line = (" " * (indent-1))
35
+ end
36
+ return lines.join("\n")
37
+ end
38
+
39
+ require 'optparse'
40
+
41
+ require_relative '../lib/cpee/transformation/transformer' rescue nil
42
+ require_relative '../lib/cpee/transformation/cpee' rescue nil
43
+ require_relative '../lib/cpee/transformation/mermaid' rescue nil
44
+
45
+ interactive = false
46
+ printtree = false
47
+
48
+ ARGV.options { |opt|
49
+ opt.summary_indent = ' ' * 2
50
+ opt.summary_width = 18
51
+ opt.banner = "Usage:\n#{opt.summary_indent}#{File.basename($0)} FNAME\n"
52
+ opt.on("Options:")
53
+ opt.on("--help", "-h", "This text") { puts opt; exit }
54
+ opt.on("--interactive", "-i", "Interactive mode") { interactive = true }
55
+ opt.on("--tree", "-t", "Print tree") { printtree = true }
56
+ opt.on("")
57
+ opt.on(wrap("[FNAME]","convert cpee tree in file FNAME to mermaid and output to console."))
58
+ opt.parse!
59
+ }
60
+
61
+ if ARGV.length != 1
62
+ puts ARGV.options
63
+ exit
64
+ else
65
+ f = ARGV[0]
66
+ end
67
+
68
+ model = CPEE::Transformation::Source::CPEE.new(File.read(f))
69
+
70
+ trans = CPEE::Transformation::Transformer.new(model)
71
+ traces = trans.build_traces
72
+
73
+ if interactive
74
+ puts traces.legend
75
+ puts
76
+ tree = trans.build_tree(true)
77
+ else
78
+ tree = trans.build_tree(false)
79
+ end
80
+
81
+ if printtree
82
+ puts tree.to_s
83
+ else
84
+ puts trans.generate_model(CPEE::Transformation::Target::Mermaid)
85
+ end
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/ruby
2
+ # encoding: UTF-8
3
+ #
4
+ # This file is part of CPEE-TRANSFORMATION.
5
+ #
6
+ # CPEE-TRANSFORMATION is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU Lesser General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or (at your
9
+ # option) any later version.
10
+ #
11
+ # CPEE-TRANSFORMATION is distributed in the hope that it will be useful, but
12
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
14
+ # for more details.
15
+ #
16
+ # You should have received a copy of the GNU Lesser General Public License
17
+ # along with CPEE-TRANSFORMATION (file COPYING in the main directory). If not,
18
+ # see <http://www.gnu.org/licenses/>.
19
+
20
+ def wrap(s1, s2, width=78, indent=ARGV.options.summary_width + 3)
21
+ lines = []
22
+ s = ARGV.options.summary_indent + s1 + ' ' * (indent - s1.length - ARGV.options.summary_indent.length) + s2
23
+ line, s = s[0..indent-2], s[indent..-1]
24
+ s.split(/\n/).each do |ss|
25
+ ss.split(/[ \t]+/).each do |word|
26
+ if line.size + word.size >= width
27
+ lines << line
28
+ line = (" " * (indent)) + word
29
+ else
30
+ line << " " << word
31
+ end
32
+ end
33
+ lines << line if line
34
+ line = (" " * (indent-1))
35
+ end
36
+ return lines.join("\n")
37
+ end
38
+
39
+ require 'optparse'
40
+
41
+ require_relative '../lib/cpee/transformation/transformer' rescue nil
42
+ require_relative '../lib/cpee/transformation/cpee' rescue nil
43
+ require_relative '../lib/cpee/transformation/ptml' rescue nil
44
+
45
+ interactive = false
46
+ printtree = false
47
+
48
+ ARGV.options { |opt|
49
+ opt.summary_indent = ' ' * 2
50
+ opt.summary_width = 18
51
+ opt.banner = "Usage:\n#{opt.summary_indent}#{File.basename($0)} FNAME\n"
52
+ opt.on("Options:")
53
+ opt.on("--help", "-h", "This text") { puts opt; exit }
54
+ opt.on("--interactive", "-i", "Interactive mode") { interactive = true }
55
+ opt.on("--tree", "-t", "Print tree") { printtree = true }
56
+ opt.on("")
57
+ opt.on(wrap("[FNAME]","convert cpee tree in file FNAME to cpee and output to console."))
58
+ opt.parse!
59
+ }
60
+
61
+ if ARGV.length != 1
62
+ puts ARGV.options
63
+ exit
64
+ else
65
+ f = ARGV[0]
66
+ end
67
+
68
+ model = CPEE::Transformation::Source::CPEE.new(File.read(f))
69
+
70
+ trans = CPEE::Transformation::Transformer.new(model)
71
+ traces = trans.build_traces
72
+
73
+ if interactive
74
+ puts traces.legend
75
+ puts
76
+ tree = trans.build_tree(true)
77
+ else
78
+ tree = trans.build_tree(false)
79
+ end
80
+
81
+ pp tree
82
+
83
+ if printtree
84
+ puts tree.to_s
85
+ else
86
+ puts trans.generate_model(CPEE::Transformation::Target::PTML)
87
+ end
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/ruby
2
+ # encoding: UTF-8
3
+ #
4
+ # This file is part of CPEE-TRANSFORMATION.
5
+ #
6
+ # CPEE-TRANSFORMATION is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU Lesser General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or (at your
9
+ # option) any later version.
10
+ #
11
+ # CPEE-TRANSFORMATION is distributed in the hope that it will be useful, but
12
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
14
+ # for more details.
15
+ #
16
+ # You should have received a copy of the GNU Lesser General Public License
17
+ # along with CPEE-TRANSFORMATION (file COPYING in the main directory). If not,
18
+ # see <http://www.gnu.org/licenses/>.
19
+
20
+ def wrap(s1, s2, width=78, indent=ARGV.options.summary_width + 3)
21
+ lines = []
22
+ s = ARGV.options.summary_indent + s1 + ' ' * (indent - s1.length - ARGV.options.summary_indent.length) + s2
23
+ line, s = s[0..indent-2], s[indent..-1]
24
+ s.split(/\n/).each do |ss|
25
+ ss.split(/[ \t]+/).each do |word|
26
+ if line.size + word.size >= width
27
+ lines << line
28
+ line = (" " * (indent)) + word
29
+ else
30
+ line << " " << word
31
+ end
32
+ end
33
+ lines << line if line
34
+ line = (" " * (indent-1))
35
+ end
36
+ return lines.join("\n")
37
+ end
38
+
39
+ require 'optparse'
40
+
41
+ require_relative '../lib/cpee/transformation/transformer' rescue nil
42
+ require_relative '../lib/cpee/transformation/cpee' rescue nil
43
+ require_relative '../lib/cpee/transformation/text-bf' rescue nil
44
+
45
+ interactive = false
46
+ printtree = false
47
+
48
+ ARGV.options { |opt|
49
+ opt.summary_indent = ' ' * 2
50
+ opt.summary_width = 18
51
+ opt.banner = "Usage:\n#{opt.summary_indent}#{File.basename($0)} FNAME\n"
52
+ opt.on("Options:")
53
+ opt.on("--help", "-h", "This text") { puts opt; exit }
54
+ opt.on("--interactive", "-i", "Interactive mode") { interactive = true }
55
+ opt.on("--tree", "-t", "Print tree") { printtree = true }
56
+ opt.on("")
57
+ opt.on(wrap("[FNAME]","convert cpee tree in file FNAME to cpee and output to console."))
58
+ opt.parse!
59
+ }
60
+
61
+ if ARGV.length != 1
62
+ puts ARGV.options
63
+ exit
64
+ else
65
+ f = ARGV[0]
66
+ end
67
+
68
+ model = CPEE::Transformation::Source::CPEE.new(File.read(f))
69
+
70
+ trans = CPEE::Transformation::Transformer.new(model)
71
+ traces = trans.build_traces
72
+
73
+ if interactive
74
+ puts traces.legend
75
+ puts
76
+ tree = trans.build_tree(true)
77
+ else
78
+ tree = trans.build_tree(false)
79
+ end
80
+
81
+ if printtree
82
+ puts tree.to_s
83
+ else
84
+ puts trans.generate_model(CPEE::Transformation::Target::Text_bf)
85
+ end
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/ruby
2
+ # encoding: UTF-8
3
+ #
4
+ # This file is part of CPEE-TRANSFORMATION.
5
+ #
6
+ # CPEE-TRANSFORMATION is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU Lesser General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or (at your
9
+ # option) any later version.
10
+ #
11
+ # CPEE-TRANSFORMATION is distributed in the hope that it will be useful, but
12
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
14
+ # for more details.
15
+ #
16
+ # You should have received a copy of the GNU Lesser General Public License
17
+ # along with CPEE-TRANSFORMATION (file COPYING in the main directory). If not,
18
+ # see <http://www.gnu.org/licenses/>.
19
+
20
+ def wrap(s1, s2, width=78, indent=ARGV.options.summary_width + 3)
21
+ lines = []
22
+ s = ARGV.options.summary_indent + s1 + ' ' * (indent - s1.length - ARGV.options.summary_indent.length) + s2
23
+ line, s = s[0..indent-2], s[indent..-1]
24
+ s.split(/\n/).each do |ss|
25
+ ss.split(/[ \t]+/).each do |word|
26
+ if line.size + word.size >= width
27
+ lines << line
28
+ line = (" " * (indent)) + word
29
+ else
30
+ line << " " << word
31
+ end
32
+ end
33
+ lines << line if line
34
+ line = (" " * (indent-1))
35
+ end
36
+ return lines.join("\n")
37
+ end
38
+
39
+ require 'optparse'
40
+
41
+ require_relative '../lib/cpee/transformation/transformer' rescue nil
42
+ require_relative '../lib/cpee/transformation/cpee' rescue nil
43
+ require_relative '../lib/cpee/transformation/text-df-PO-extended' rescue nil
44
+
45
+ interactive = false
46
+ printtree = false
47
+
48
+ ARGV.options { |opt|
49
+ opt.summary_indent = ' ' * 2
50
+ opt.summary_width = 18
51
+ opt.banner = "Usage:\n#{opt.summary_indent}#{File.basename($0)} FNAME\n"
52
+ opt.on("Options:")
53
+ opt.on("--help", "-h", "This text") { puts opt; exit }
54
+ opt.on("--interactive", "-i", "Interactive mode") { interactive = true }
55
+ opt.on("--tree", "-t", "Print tree") { printtree = true }
56
+ opt.on("")
57
+ opt.on(wrap("[FNAME]","convert cpee tree in file FNAME to cpee and output to console."))
58
+ opt.parse!
59
+ }
60
+
61
+ if ARGV.length != 1
62
+ puts ARGV.options
63
+ exit
64
+ else
65
+ f = ARGV[0]
66
+ end
67
+
68
+ model = CPEE::Transformation::Source::CPEE.new(File.read(f))
69
+
70
+ trans = CPEE::Transformation::Transformer.new(model)
71
+ traces = trans.build_traces
72
+
73
+ if interactive
74
+ puts traces.legend
75
+ puts
76
+ tree = trans.build_tree(true)
77
+ else
78
+ tree = trans.build_tree(false)
79
+ end
80
+
81
+ if printtree
82
+ puts tree.to_s
83
+ else
84
+ puts trans.generate_model(CPEE::Transformation::Target::Text_df_PO_extended)
85
+ end