cpee-logging-xes-yaml 1.0 → 1.0.1

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
  SHA256:
3
- metadata.gz: da7a05239a1da8c1c5385237edd86c5e416d5890547fd887fa58afcec6964e0f
4
- data.tar.gz: 4af562158950e42d15f8ae2cc109849785601f1f8a13b75714f8f4769f8de584
3
+ metadata.gz: 5233866b6ce08af2156e106e2813f40d684833933726adfea60a1297f0fef556
4
+ data.tar.gz: 93cbef9a422a9388bed75adb86a04eec7faa06036540e6190cc41ec07658a664
5
5
  SHA512:
6
- metadata.gz: a05b38fe0f0e2626130393e87d210c9fbe2312583dd1aa9c56953696cbed4d31a59a6989c2e8bab050dac150ef2fefbf87c6dfef6662a245333da5cb9222bcb7
7
- data.tar.gz: c79d798d6a1aa42e4731a8feb637a49027811d7a7509bb47c0ae1af5b2dc1c6b2cf67f8af100e78715fe4506ba9ab92cb6939f54691991dca40ba6e8f1e8d2c0
6
+ metadata.gz: 55569ea8f23429cb63bf6d8d6df57064a9a3982ba66876fe36d8b400937c7d57a8dcc2c7ed9f833324541739338dfa1ff24198a4dae35888745c53a3fcf54132
7
+ data.tar.gz: c28f5c119e48cc76a3edef1b4649ed9d5f0ba6f75b848b0a1b734018de5afa45e0d6be918fd40d940667742b44c5b576f2297b7b210935519ba4ce778ebb1d62
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cpee-logging-xes-yaml"
3
- s.version = "1.0"
3
+ s.version = "1.0.1"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.license = "LGPL-3.0"
6
6
  s.summary = "Logging for the cloud process execution engine (cpee.org)"
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
 
16
16
  s.required_ruby_version = '>=2.4.0'
17
17
 
18
- s.authors = ['Juergen eTM Mangler']
18
+ s.authors = ['Juergen eTM Mangler','Florian Stertz']
19
19
 
20
20
  s.email = 'juergen.mangler@gmail.com'
21
21
  s.homepage = 'http://cpee.org/'
@@ -4,15 +4,18 @@ require 'rubygems'
4
4
  require 'optparse'
5
5
  require 'fileutils'
6
6
  require 'xml/smart'
7
+ require 'yaml'
8
+ require 'typhoeus'
9
+ require 'stringio'
7
10
 
8
- def wrap(s, width=78, indent=18)
11
+ def wrap(s, width=78, indent=18, extra_indent=4)
9
12
  lines = []
10
13
  line, s = s[0..indent-2], s[indent..-1]
11
14
  s.split(/\n/).each do |ss|
12
15
  ss.split(/[ \t]+/).each do |word|
13
16
  if line.size + word.size >= width
14
17
  lines << line
15
- line = (" " * (indent)) + word
18
+ line = (" " * (indent + extra_indent)) + word
16
19
  else
17
20
  line << " " << word
18
21
  end
@@ -23,27 +26,88 @@ def wrap(s, width=78, indent=18)
23
26
  return lines.join "\n"
24
27
  end
25
28
 
29
+ def follow(fname,io,copy,deep=0)
30
+ if copy
31
+ File.write(File.basename(fname,'.xes.yaml') + '.xes.yaml',io.read)
32
+ io.rewind
33
+ end
34
+ YAML.load_stream(io) do |e|
35
+ if name = e.dig('log','trace','cpee:name')
36
+ puts " " * deep + name + " (#{File.basename(fname,'.xes.yaml')}) - #{e.dig('log','trace','concept:name')}"
37
+ end
38
+ if e.dig('event','concept:endpoint') == 'https://centurio.work/flow/start/url/' && e.dig('event','cpee:lifecycle:transition') == 'task/instantiation'
39
+ base = e.dig('event','data','data_receiver')
40
+ val = base.dig('CPEE-INSTANCE') rescue nil
41
+ if val.nil?
42
+ val = File.basename(base)
43
+ end
44
+ uuid = base.dig('CPEE-INSTANCE-UUID') rescue nil
45
+ unless uuid
46
+ res = Typhoeus.get(File.join('https://centurio.work/flow/engine/',val,'/properties/values/attributes/uuid/'))
47
+ if res.success?
48
+ uuid = XML::Smart.string(res.body).find('string(/*)')
49
+ end
50
+ end
51
+ react File.dirname(fname) + "/#{uuid}.xes.yaml",copy,deep + 2
52
+ end
53
+ end
54
+ end
55
+
56
+ def react(name,copy=false,deep=0)
57
+ if name.nil?
58
+ help
59
+ elsif name =~ /^https?:\/\//
60
+ res = Typhoeus.get(name)
61
+ if res.success?
62
+ file = Tempfile.new('sic')
63
+ file.write(res.body)
64
+ file.rewind
65
+ follow name, file, copy, deep
66
+ file.close
67
+ file.unlink
68
+ end
69
+ elsif File.exists? name
70
+ follow name, File.open(name), copy, deep
71
+ else
72
+ help
73
+ end
74
+ end
75
+
76
+ exname = File.basename($0)
77
+
26
78
  ARGV.options { |opt|
27
79
  opt.summary_indent = ' ' * 2
28
80
  opt.summary_width = 15
29
- opt.banner = "Usage:\n#{opt.summary_indent}#{File.basename($0)} [DIR]\n"
81
+ opt.banner = "Usage:\n#{opt.summary_indent}#{exname} new [DIR] | view [URI] | copy [URI]\n"
30
82
  opt.on("Options:")
31
83
  opt.on("--help", "-h", "This text") { puts opt; exit }
32
84
  opt.on("")
33
- opt.on(wrap("[DIR] scaffolds a sample logging service. Add a handler to a cpee instance to experience the pleasure."))
85
+ opt.on(wrap("new [DIR] scaffolds a sample logging service. Add a handler to a cpee instance to experience the pleasure.",78,18,0))
86
+ opt.on("")
87
+ opt.on(wrap("view [DIR] view the dependencies between processes and subprocesses.\nWorks for local and remote logs. Examples:\n#{exname} view https://cpee.org/log/123.xes.yaml\n#{exname} view https://cpee.org/log/a.xes.yaml > index.txt\n#{exname} view ~/log/logs/456.xes.yaml"))
88
+ opt.on("")
89
+ opt.on(wrap("copy [DIR] copy dependent processes and subprocesses to the current\ndirectory. Works for local and remote logs. Examples:\n#{exname} copy https://cpee.org/log/123.xes.yaml\n#{exname} copy ~/log/logs/456.xes.yaml"))
34
90
  opt.parse!
35
91
  }
36
- if (ARGV.length != 1)
92
+ if (ARGV.length != 2)
37
93
  puts ARGV.options
38
94
  exit
39
95
  else
40
- p1 = ARGV[0]
96
+ command = ARGV[0]
97
+ dir = ARGV[1]
41
98
  end
42
99
 
43
- if !File.exists?(p1)
44
- FileUtils.cp_r(File.join(curpath,'..','server'),p1)
45
- FileUtils.mkdir(File.join(p1,'logs')) rescue nil
46
-
100
+ if command == 'new'
101
+ if !File.exists?(p1)
102
+ FileUtils.cp_r(File.join(curpath,'..','server'),p1)
103
+ FileUtils.mkdir(File.join(p1,'logs')) rescue nil
104
+ else
105
+ puts 'Directory already exists.'
106
+ end
107
+ elsif command == 'view'
108
+ react dir, false
109
+ elsif command == 'copy'
110
+ react dir, true
47
111
  else
48
- puts 'Directory already exists.'
112
+ puts ARGV.options
49
113
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cpee-logging-xes-yaml
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen eTM Mangler
8
+ - Florian Stertz
8
9
  autorequire:
9
10
  bindir: tools
10
11
  cert_chain: []
11
- date: 2020-10-02 00:00:00.000000000 Z
12
+ date: 2020-10-05 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: riddl
@@ -76,7 +77,6 @@ files:
76
77
  - lib/cpee-logging-xes-yaml/template.xes_yaml
77
78
  - server/log
78
79
  - tools/cpee-logging-xes-yaml
79
- - tools/sic.rb
80
80
  homepage: http://cpee.org/
81
81
  licenses:
82
82
  - LGPL-3.0
@@ -1,64 +0,0 @@
1
- #!/usr/bin/ruby
2
- require 'yaml'
3
- require 'typhoeus'
4
- require 'stringio'
5
- require 'xml/smart'
6
-
7
- def follow(fname,io,deep=0)
8
- if ARGV[1] == 'copy'
9
- File.write(File.basename(fname,'.xes.yaml') + '.xes.yaml',io.read)
10
- io.rewind
11
- end
12
- YAML.load_stream(io) do |e|
13
- if name = e.dig('log','trace','cpee:name')
14
- puts " " * deep + name + " (#{File.basename(fname,'.xes.yaml')}) - #{e.dig('log','trace','concept:name')}"
15
- end
16
- if e.dig('event','concept:endpoint') == 'https://centurio.work/flow/start/url/' && e.dig('event','cpee:lifecycle:transition') == 'task/instantiation'
17
- base = e.dig('event','data','data_receiver')
18
- val = base.dig('CPEE-INSTANCE') rescue nil
19
- if val.nil?
20
- val = File.basename(base)
21
- end
22
- uuid = base.dig('CPEE-INSTANCE-UUID') rescue nil
23
- unless uuid
24
- res = Typhoeus.get(File.join('https://centurio.work/flow/engine/',val,'/properties/values/attributes/uuid/'))
25
- if res.success?
26
- uuid = XML::Smart.string(res.body).find('string(/*)')
27
- end
28
- end
29
- react File.dirname(fname) + "/#{uuid}.xes.yaml",deep + 2
30
- end
31
- end
32
- end
33
-
34
- def react(name,deep=0)
35
- if name.nil?
36
- help
37
- elsif name =~ /^https?:\/\//
38
- res = Typhoeus.get(name)
39
- if res.success?
40
- file = Tempfile.new('sic')
41
- file.write(res.body)
42
- file.rewind
43
- follow name, file, deep
44
- file.close
45
- file.unlink
46
- end
47
- elsif File.exists? name
48
- follow name, File.open(name), deep
49
- else
50
- help
51
- end
52
- end
53
-
54
- def help
55
- puts 'Views or copies log file trees to current directory.'
56
- puts
57
- puts ' View: sic.rb https://centurio.work/log/865916c6-2b18-4e9d-81d4-0fab0df248f4.xes.yaml'
58
- puts ' Copy: sic.rb https://centurio.work/log/865916c6-2b18-4e9d-81d4-0fab0df248f4.xes.yaml copy'
59
- puts ' Copy: sic.rb ~/Projects/cpee/log/logs/865916c6-2b18-4e9d-81d4-0fab0df248f4.xes.yaml copy'
60
- puts ' View: sic.rb 865916c6-2b18-4e9d-81d4-0fab0df248f4.xes.yaml'
61
- true
62
- end
63
-
64
- react(ARGV[0]) || help