cpee-logging-xes-yaml 1.3.2 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/cpee-logging-xes-yaml.gemspec +1 -1
- data/lib/cpee-logging-xes-yaml/tools.rb +3 -3
- data/tools/cpee-logging-xes-yaml +108 -11
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d0f1a3d5cdf89d14a2c7ff96d36f0d331496ca095d4c395c49c770e827ed279
|
4
|
+
data.tar.gz: 67c87266391555e7dd326420e341549314d3b111b036637c965e42300972489d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97bdab2b3cfaafb419e5dd20a87eab3ec096a08a15c22fac43f1a7209e3a440bb31246007c85f38dc51ed60ed28115d651191c4de24aae6d8480341e7d286cc1
|
7
|
+
data.tar.gz: 434309fe76ed0653a8af989e4fd074c21d2164f37518d4808c54fe8bb77bd8c86b2bf1f6aa39fa556070a68d32a13b4262052a7caa2089237e84b14d7394f88b
|
@@ -18,10 +18,9 @@ require 'weel'
|
|
18
18
|
require 'digest/sha1'
|
19
19
|
|
20
20
|
class StreamPoint
|
21
|
-
attr_accessor :value, :timestamp, :source, :meta
|
22
|
-
attr_reader :id
|
21
|
+
attr_accessor :value, :timestamp, :source, :meta, :id
|
23
22
|
|
24
|
-
def initialize(id)
|
23
|
+
def initialize(id=nil)
|
25
24
|
@id = id
|
26
25
|
@value = nil
|
27
26
|
@timestamp = Time.now
|
@@ -101,6 +100,7 @@ module CPEE
|
|
101
100
|
tp = nil
|
102
101
|
if val.is_a? StreamPoint
|
103
102
|
tp = val
|
103
|
+
tp.id = tid if tp.id.nil?
|
104
104
|
tp.source = tso if tp.source.nil?
|
105
105
|
else
|
106
106
|
tp = StreamPoint.new(tid)
|
data/tools/cpee-logging-xes-yaml
CHANGED
@@ -24,8 +24,10 @@ require 'xml/smart'
|
|
24
24
|
require 'yaml'
|
25
25
|
require 'typhoeus'
|
26
26
|
require 'stringio'
|
27
|
+
require 'typhoeus'
|
28
|
+
require 'date'
|
27
29
|
|
28
|
-
def wrap(s, width=78, indent=
|
30
|
+
def wrap(s, width=78, indent=19, extra_indent=4)
|
29
31
|
lines = []
|
30
32
|
line, s = s[0..indent-2], s[indent..-1]
|
31
33
|
s.split(/\n/).each do |ss|
|
@@ -91,20 +93,69 @@ def react(name,copy=false,deep=0)
|
|
91
93
|
end
|
92
94
|
end
|
93
95
|
|
96
|
+
def extract(path)
|
97
|
+
if path =~ /^http.*/
|
98
|
+
response = Typhoeus.get(path)
|
99
|
+
if response.success?
|
100
|
+
text = response.response_body
|
101
|
+
end
|
102
|
+
else
|
103
|
+
text = File.read(File.join(__dir__,path))
|
104
|
+
end
|
105
|
+
yaml = Psych.load_stream(text)
|
106
|
+
changes = []
|
107
|
+
|
108
|
+
info = yaml.shift()
|
109
|
+
uuid = info.dig('log','trace','cpee:instance')
|
110
|
+
yaml.each() do |el|
|
111
|
+
if(el['event']['id:id'] == 'external' && (el.dig('event','cpee:lifecycle:transition') == 'endpoints/change' || el.dig('event','cpee:lifecycle:transition') == 'dataelements/change'|| el.dig('event','cpee:lifecycle:transition') == 'description/change'))
|
112
|
+
changes.push(el)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
#puts "found #{changes.size()} changes"
|
116
|
+
|
117
|
+
changes.sort!() {|a,b| DateTime.strptime(a.dig('event','time:timestamp'),'%Y-%m-%dT%H:%M:%S.%L%:z') <=> DateTime.strptime(b.dig('event','time:timestamp'),'%Y-%m-%dT%H:%M:%S.%L%:z')}
|
118
|
+
#p changes.map() {|el| el.dig('event','time:timestamp')}
|
119
|
+
|
120
|
+
de = ep = desc = nil
|
121
|
+
counter = 0
|
122
|
+
changes.each() do |change|
|
123
|
+
if(change.dig('event','cpee:lifecycle:transition') == 'dataelements/change') then
|
124
|
+
de = change.dig('event','data')
|
125
|
+
end
|
126
|
+
if(change.dig('event','cpee:lifecycle:transition') == 'endpoints/change') then
|
127
|
+
ep = change.dig('event','data')
|
128
|
+
end
|
129
|
+
if(change.dig('event','cpee:lifecycle:transition') == 'description/change') then
|
130
|
+
desc = change.dig('event','cpee:description')
|
131
|
+
end
|
132
|
+
if(change.dig('event','cpee:lifecycle:transition') == 'description/change' || change.dig('event','cpee:lifecycle:transition') == 'endpoints/change') then
|
133
|
+
yield uuid, de, ep, desc, counter if block_given?
|
134
|
+
counter += 1
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
[de, ep, desc]
|
139
|
+
end
|
140
|
+
|
94
141
|
exname = File.basename($0)
|
95
142
|
|
96
143
|
ARGV.options { |opt|
|
97
144
|
opt.summary_indent = ' ' * 2
|
98
|
-
opt.summary_width =
|
145
|
+
opt.summary_width = 16
|
99
146
|
opt.banner = "Usage:\n#{opt.summary_indent}#{exname} new [DIR] | view [URI] | copy [URI]\n"
|
100
147
|
opt.on("Options:")
|
101
148
|
opt.on("--help", "-h", "This text") { puts opt; exit }
|
102
149
|
opt.on("")
|
103
|
-
opt.on(wrap("new [DIR]
|
150
|
+
opt.on(wrap("new [DIR] scaffolds a sample logging service. Add a handler to a cpee instance to experience the pleasure."))
|
151
|
+
opt.on("")
|
152
|
+
opt.on(wrap("view [DIR] view the dependencies between processes and subprocesses. Works 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"))
|
104
153
|
opt.on("")
|
105
|
-
opt.on(wrap("
|
154
|
+
opt.on(wrap("copy [DIR] copy dependent processes and subprocesses to the current directory. 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"))
|
106
155
|
opt.on("")
|
107
|
-
opt.on(wrap("
|
156
|
+
opt.on(wrap("extract-all [LOG] extract cpee testset from cpee xes-yaml log. Works for local and remote logs. Write logs to files in folder named like the instance uuid contained in the log. Examples:\n#{exname} extract https://cpee.org/log/123.xes.yaml\n#{exname} extract ~/log/logs/456.xes.yaml"))
|
157
|
+
opt.on("")
|
158
|
+
opt.on(wrap("extract-last [LOG] extract cpee testset from cpee xes-yaml log. Works for local and remote logs. Write last revision of the model to stdout. Examples:\n#{exname} extract https://cpee.org/log/123.xes.yaml\n#{exname} extract ~/log/logs/456.xes.yaml"))
|
108
159
|
opt.parse!
|
109
160
|
}
|
110
161
|
if (ARGV.length != 2)
|
@@ -112,20 +163,66 @@ if (ARGV.length != 2)
|
|
112
163
|
exit
|
113
164
|
else
|
114
165
|
command = ARGV[0]
|
115
|
-
|
166
|
+
path = ARGV[1]
|
116
167
|
end
|
117
168
|
|
118
169
|
if command == 'new'
|
119
|
-
if !File.exist?(
|
120
|
-
FileUtils.cp_r(File.join(curpath,'..','server'),
|
121
|
-
FileUtils.mkdir(File.join(
|
170
|
+
if !File.exist?(path)
|
171
|
+
FileUtils.cp_r(File.join(curpath,'..','server'),path)
|
172
|
+
FileUtils.mkdir(File.join(path,'logs')) rescue nil
|
122
173
|
else
|
123
174
|
puts 'Directory already exists.'
|
124
175
|
end
|
125
176
|
elsif command == 'view'
|
126
|
-
react
|
177
|
+
react path, false
|
127
178
|
elsif command == 'copy'
|
128
|
-
react
|
179
|
+
react path, true
|
180
|
+
elsif command == 'extract-all'
|
181
|
+
extract(path) do |uuid, de, ep, desc, version|
|
182
|
+
xml = XML::Smart.string('<testset xmlns="http://cpee.org/ns/properties/2.0"><executionhandler>ruby</executionhandler></testset>')
|
183
|
+
dataelements = xml.root().add('dataelements')
|
184
|
+
endpoints = xml.root().add('endpoints')
|
185
|
+
description = xml.root().add('description').add(XML::Smart.string('<description xmlns="http://cpee.org/ns/description/1.0"/>').root())
|
186
|
+
unless de.nil?
|
187
|
+
de.each do |d|
|
188
|
+
dataelements.add(d['name'],d['value'])
|
189
|
+
end
|
190
|
+
end
|
191
|
+
unless ep.nil?
|
192
|
+
ep.each do |e|
|
193
|
+
endpoints.add(e['name'],e['value'])
|
194
|
+
end
|
195
|
+
end
|
196
|
+
unless desc.nil?
|
197
|
+
description.replace_by(XML::Smart.string(desc).root())
|
198
|
+
end
|
199
|
+
dirname = File.join(__dir__,uuid)
|
200
|
+
filename = File.join(dirname,"#{uuid}_#{version}.xml")
|
201
|
+
Dir.mkdir(dirname) unless Dir.exist?(dirname)
|
202
|
+
File.write(filename, xml.to_s())
|
203
|
+
end
|
204
|
+
elsif command == 'extract-last'
|
205
|
+
de, ep, desc = extract(path)
|
206
|
+
|
207
|
+
xml = XML::Smart.string('<testset xmlns="http://cpee.org/ns/properties/2.0"><executionhandler>ruby</executionhandler></testset>')
|
208
|
+
dataelements = xml.root().add('dataelements')
|
209
|
+
endpoints = xml.root().add('endpoints')
|
210
|
+
description = xml.root().add('description').add(XML::Smart.string('<description xmlns="http://cpee.org/ns/description/1.0"/>').root())
|
211
|
+
unless de.nil?
|
212
|
+
de.each do |d|
|
213
|
+
dataelements.add(d['name'],d['value'])
|
214
|
+
end
|
215
|
+
end
|
216
|
+
unless ep.nil?
|
217
|
+
ep.each do |e|
|
218
|
+
endpoints.add(e['name'],e['value'])
|
219
|
+
end
|
220
|
+
end
|
221
|
+
unless desc.nil?
|
222
|
+
description.replace_by(XML::Smart.string(desc).root())
|
223
|
+
end
|
224
|
+
|
225
|
+
puts xml.to_s
|
129
226
|
else
|
130
227
|
puts ARGV.options
|
131
228
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cpee-logging-xes-yaml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juergen eTM Mangler
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: tools
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2024-01-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: riddl
|
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
98
|
- !ruby/object:Gem::Version
|
99
99
|
version: '0'
|
100
100
|
requirements: []
|
101
|
-
rubygems_version: 3.
|
101
|
+
rubygems_version: 3.4.10
|
102
102
|
signing_key:
|
103
103
|
specification_version: 4
|
104
104
|
summary: Logging for the cloud process execution engine (cpee.org)
|