sra2019 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/sra2019.rb +128 -22
- metadata +22 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ddc547d97ba77fd821c80247707774db29fa20b38d8a9f4183e793e04516ca8
|
4
|
+
data.tar.gz: 93fde335b26f1cda3befbab1c5db96e346e877a16d42907dd55c9f64e3671355
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '017894f86f375912322529f8d9c66b61c4b35c9a9960684bd93abd3f2ca415862daf0cf3265353581679bea0623f695dfd08560ced77197fbc0e20d1e5fdc0fb'
|
7
|
+
data.tar.gz: af6db46c959d7b5beedff8b15be615a0d8c7733886d5abb78e830bf9e991d5b49bc0fec5d012f1b0d50c9d07d9e7fb9b8d43db814b11d07a3acd0b225ae54637
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/sra2019.rb
CHANGED
@@ -8,7 +8,10 @@
|
|
8
8
|
require 'hlt'
|
9
9
|
require 'rexle'
|
10
10
|
require 'base64'
|
11
|
+
require 'ostruct'
|
12
|
+
require 'subunit'
|
11
13
|
require 'zip/zip'
|
14
|
+
require 'dynarex'
|
12
15
|
require 'rxfhelper'
|
13
16
|
require 'wicked_pdf'
|
14
17
|
require 'mini_magick'
|
@@ -16,11 +19,21 @@ require 'archive/zip'
|
|
16
19
|
require 'rexle-builder'
|
17
20
|
|
18
21
|
|
22
|
+
module TimeHelper
|
23
|
+
|
24
|
+
refine String do
|
25
|
+
def to_time()
|
26
|
+
Time.strptime(self, "%H:%M:%S")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
19
31
|
|
20
32
|
class StepsRecorderAnalyser
|
21
33
|
using ColouredText
|
34
|
+
using TimeHelper
|
22
35
|
|
23
|
-
attr_reader :steps
|
36
|
+
attr_reader :steps, :start_time, :stop_time
|
24
37
|
|
25
38
|
|
26
39
|
def initialize(s, debug: false, savepath: '/tmp', title: 'Untitled')
|
@@ -37,12 +50,39 @@ class StepsRecorderAnalyser
|
|
37
50
|
|
38
51
|
puts ('content: ' + content.inspect).debug if @debug
|
39
52
|
|
40
|
-
|
41
|
-
@
|
42
|
-
@
|
53
|
+
@actions = parse_report content
|
54
|
+
@all_steps = parse_steps content
|
55
|
+
@doc = build @all_steps
|
56
|
+
steps = @all_steps.select {|x| x[:user_comment]}
|
57
|
+
@steps = steps.any? ? steps : @all_steps
|
43
58
|
|
44
59
|
end
|
45
60
|
|
61
|
+
def import(s)
|
62
|
+
|
63
|
+
@dx = Dynarex.new
|
64
|
+
@dx.import s
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
# Returns a Dynarex object
|
69
|
+
#
|
70
|
+
def to_dx()
|
71
|
+
|
72
|
+
@dx = Dynarex.new 'instructions/instruction(step, imgsrc, description)'
|
73
|
+
@dx.summary[:rawdoc_type] = 'rowx'
|
74
|
+
|
75
|
+
@steps.each.with_index do |h, i|
|
76
|
+
|
77
|
+
@dx.create step: i+1, imgsrc: "screenshot#{i+1}.jpg",
|
78
|
+
description: h[:user_comment] || h[:desc]
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
@dx
|
83
|
+
|
84
|
+
end
|
85
|
+
|
46
86
|
def to_kbml(options={})
|
47
87
|
|
48
88
|
|
@@ -50,6 +90,9 @@ class StepsRecorderAnalyser
|
|
50
90
|
|
51
91
|
end
|
52
92
|
|
93
|
+
|
94
|
+
# Writes the steps to an HTML file
|
95
|
+
#
|
53
96
|
def to_html(filepath=File.join(@savepath, 'sra' + Time.now.to_i.to_s))
|
54
97
|
|
55
98
|
# save the image files to a file directory.
|
@@ -95,7 +138,9 @@ html
|
|
95
138
|
EOF
|
96
139
|
|
97
140
|
html = Rexle.new(Hlt.new(@sliml).to_html)\
|
98
|
-
.root.element('html').xml
|
141
|
+
.root.element('html').xml pretrequire 'requestor'
|
142
|
+
eval Requestor.read('http://a0.jamesrobertson.eu/rorb/r/ruby'){|x| x.require 'sra2019' }
|
143
|
+
ty: true
|
99
144
|
File.write File.join(filepath, 'index.html'), html
|
100
145
|
|
101
146
|
%w(layout style print).each \
|
@@ -109,6 +154,43 @@ EOF
|
|
109
154
|
@sliml
|
110
155
|
end
|
111
156
|
|
157
|
+
def to_srt()
|
158
|
+
|
159
|
+
lines = to_subtitles.strip.lines.map.with_index do |x, i|
|
160
|
+
|
161
|
+
raw_times, subtitle = x.split(/ /,2)
|
162
|
+
|
163
|
+
start_time, end_time = raw_times.split('-',2)
|
164
|
+
times = [("%02d:%02d:%02d" % ([0, 0 ] + start_time.split(/\D/)\
|
165
|
+
.map(&:to_i)).reverse.take(3).reverse), \
|
166
|
+
'-->', \
|
167
|
+
("%02d:%02d:%02d" % ([0, 0 ] + end_time.split(/\D/).map(&:to_i))\
|
168
|
+
.reverse.take(3).reverse)].join(' ')
|
169
|
+
|
170
|
+
[i+1, times, subtitle].join("\n")
|
171
|
+
|
172
|
+
end
|
173
|
+
|
174
|
+
lines.join("\n")
|
175
|
+
|
176
|
+
end
|
177
|
+
|
178
|
+
def to_subtitles()
|
179
|
+
|
180
|
+
times = @all_steps.map(&:time).each_cons(2).map do |x|
|
181
|
+
|
182
|
+
x.map do |sec|
|
183
|
+
a = Subunit.new(units={minutes:60, hours:60}, seconds: sec).to_h.to_a
|
184
|
+
a.map {|x|"%d%s" % [x[1], x[0][0]] }.join('')
|
185
|
+
end.join('-')
|
186
|
+
|
187
|
+
end
|
188
|
+
times.zip(@all_steps.map(&:desc)).map {|x| x.join(' ')}.join("\n")
|
189
|
+
|
190
|
+
end
|
191
|
+
|
192
|
+
# Writes the steps to a PDF file
|
193
|
+
#
|
112
194
|
def to_pdf(pdf_file=File.join(@savepath, 'sra' + Time.now.to_i.to_s,
|
113
195
|
@title.gsub(/ /,'-') + '.pdf'))
|
114
196
|
|
@@ -121,18 +203,20 @@ EOF
|
|
121
203
|
|
122
204
|
end
|
123
205
|
|
124
|
-
|
206
|
+
# Compresses the HTML file directory to a ZIP file
|
207
|
+
#
|
125
208
|
def to_zip()
|
126
209
|
|
127
210
|
project = 'sra' + Time.now.to_i.to_s
|
128
211
|
newdir = File.join(@savepath, project)
|
129
212
|
zipfile = newdir + '.zip'
|
130
213
|
|
131
|
-
|
214
|
+
to_html(File.join(newdir))
|
215
|
+
#to_pdf(File.join(newdir, @title.gsub(/ /,'-') + '.pdf'))
|
132
216
|
|
133
217
|
Archive::Zip.archive(zipfile, newdir)
|
134
218
|
|
135
|
-
|
219
|
+
zipfile
|
136
220
|
|
137
221
|
end
|
138
222
|
|
@@ -184,15 +268,16 @@ EOF
|
|
184
268
|
|
185
269
|
|
186
270
|
def extract_image(s, n)
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
e =
|
191
|
-
|
192
|
-
|
271
|
+
|
272
|
+
action = @actions[n-1]
|
273
|
+
puts 'action: ' + action.inspect if @debug
|
274
|
+
e = action.element('HighlightXYWH')
|
275
|
+
return unless e
|
193
276
|
y, x, w, h = e.text.split(',').map(&:to_i)
|
194
277
|
|
195
|
-
jpg_file =
|
278
|
+
jpg_file = action.element('ScreenshotFileName/text()')
|
279
|
+
return unless jpg_file
|
280
|
+
|
196
281
|
img_data = s[/(?<=Content-Location: #{jpg_file}\r\n\r\n)[^--]+/m]
|
197
282
|
puts ('img_data: ' + img_data.inspect).debug if @debug
|
198
283
|
|
@@ -203,6 +288,23 @@ EOF
|
|
203
288
|
image.to_blob
|
204
289
|
|
205
290
|
end
|
291
|
+
|
292
|
+
def parse_report(s)
|
293
|
+
|
294
|
+
report = Rexle.new s[/<Report>.*<\/Report>/m]
|
295
|
+
session = report.root.element('UserActionData/RecordSession')
|
296
|
+
puts 'session: ' + session.inspect if @debug
|
297
|
+
puts 'attributes: ' + session.attributes.inspect if @debug
|
298
|
+
|
299
|
+
@start_time, @stop_time = %w(Start Stop).map do |x|
|
300
|
+
v = session.attributes[(x + 'Time').to_sym]
|
301
|
+
puts 'v: ' + v.inspect if @debug
|
302
|
+
v.to_time
|
303
|
+
end
|
304
|
+
|
305
|
+
session.xpath('EachAction')
|
306
|
+
|
307
|
+
end
|
206
308
|
|
207
309
|
def parse_steps(s)
|
208
310
|
|
@@ -220,27 +322,31 @@ EOF
|
|
220
322
|
|
221
323
|
raw_comment = a[0][/User Comment: (.*)/,1]
|
222
324
|
|
223
|
-
n = a[0][/(?<=Step )\d+/]
|
325
|
+
n = a[0][/(?<=Step )\d+/].to_i
|
224
326
|
puts ('n: ' + n.inspect).debug if @debug
|
327
|
+
|
328
|
+
time = (@actions[n-1].attributes[:Time].to_time - @start_time).to_i
|
225
329
|
|
226
|
-
|
330
|
+
|
331
|
+
h = if raw_comment then
|
227
332
|
|
228
333
|
{
|
229
|
-
|
230
|
-
user_comment: raw_comment.gsub(""",''),
|
231
|
-
screenshot: extract_image(s, n)
|
334
|
+
user_comment: raw_comment.gsub(""",'')
|
232
335
|
}
|
233
336
|
|
234
337
|
else
|
235
338
|
|
236
339
|
{
|
237
|
-
|
238
|
-
|
340
|
+
desc: a[0][/(?:Step \d+: )(.*)/,1].gsub('&','&')\
|
341
|
+
.gsub(""",'"').sub(/\s+\[[^\[]+\]$/,''),
|
239
342
|
keys: keys ,
|
240
343
|
program: a[1][/(?<=Program: ).*/],
|
241
344
|
ui_elements: a[2][/(?<=UI Elements: ).*/].split(/,\s+/)
|
242
345
|
}
|
243
346
|
end
|
347
|
+
|
348
|
+
steps = {step: n, time: time, screenshot: extract_image(s, n)}.merge(h)
|
349
|
+
OpenStruct.new(steps)
|
244
350
|
|
245
351
|
end
|
246
352
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sra2019
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
YgXo0DU1HUhuKAAuA0aZdb6DV5BqgZx9e27CLIKqRk5P7TikW49mFaelQfSRi675
|
36
36
|
ugi0V/wkIOHFlKLS87IPnc09
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2019-04-
|
38
|
+
date: 2019-04-28 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: hlt
|
@@ -57,6 +57,26 @@ dependencies:
|
|
57
57
|
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
59
|
version: 0.6.3
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: subunit
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 0.3.0
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0.3'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 0.3.0
|
77
|
+
- - "~>"
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0.3'
|
60
80
|
- !ruby/object:Gem::Dependency
|
61
81
|
name: archive-zip
|
62
82
|
requirement: !ruby/object:Gem::Requirement
|
metadata.gz.sig
CHANGED
Binary file
|