trecs 0.3.16 → 0.3.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/trecs/frame.rb +14 -4
- data/lib/trecs/sources/tgz_source.rb +3 -1
- data/lib/trecs/strategies/emacs_plugin_strategy.rb +41 -4
- data/lib/trecs/strategies/strategy.rb +1 -1
- data/lib/trecs/strategies/trecs_file_strategy.rb +2 -1
- data/lib/trecs/version.rb +1 -1
- data/lib/trecs/writers/json_writer.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36f09f6bf3ee384819705353885cd422b4fc3ee1
|
4
|
+
data.tar.gz: 78e0570a6a8b71479c391204a10a904e387215ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28b35d6a1732c79b7788dd598e9e21214330935d0877d8ae2bd7e365a6fc05155d4626e87eb99132a957651b13da7f4d5fdb8f5f1db737056ce8f3e16ff8dcf8
|
7
|
+
data.tar.gz: ad73ab1c1b025c40f03c691c69459bbb4327e106670ecd7f34f60304136de2ab2023a5598f453c535571d4f902689adf22bba286ff7944fbfb1cdb3ab7f46e24
|
data/Gemfile.lock
CHANGED
data/lib/trecs/frame.rb
CHANGED
@@ -6,17 +6,17 @@ module TRecs
|
|
6
6
|
def initialize(opts={})
|
7
7
|
opts = opts.is_a?(Hash) ? opts : {content: opts}
|
8
8
|
@content = opts.fetch(:content) { "" }
|
9
|
-
@format = opts
|
9
|
+
@format = opts[:format] || "raw"
|
10
10
|
end
|
11
11
|
|
12
12
|
def width
|
13
|
-
|
13
|
+
raw_text.each_line.map { |line|
|
14
14
|
line.chomp.size
|
15
15
|
}.max
|
16
16
|
end
|
17
17
|
|
18
18
|
def height
|
19
|
-
|
19
|
+
raw_text.lines.count
|
20
20
|
end
|
21
21
|
|
22
22
|
def each
|
@@ -34,11 +34,21 @@ module TRecs
|
|
34
34
|
format: format
|
35
35
|
}
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
def ==(other)
|
39
39
|
other = Frame(other)
|
40
40
|
to_s == other.to_s && format == other.format
|
41
41
|
end
|
42
|
+
|
43
|
+
|
44
|
+
def raw_text
|
45
|
+
@raw_text = if format == "html"
|
46
|
+
content.split("\n").join("\\n").gsub(/<style>.+<\/style>/, "").gsub("\\n", "\n").gsub(%r{</?[^>]+?>}, '')
|
47
|
+
else
|
48
|
+
content
|
49
|
+
end
|
50
|
+
end
|
51
|
+
private
|
42
52
|
end
|
43
53
|
|
44
54
|
end
|
@@ -12,7 +12,9 @@ module TRecs
|
|
12
12
|
attr_reader :trecs_backend
|
13
13
|
|
14
14
|
def initialize(options={})
|
15
|
-
|
15
|
+
backend = options.fetch(:trecs_backend)
|
16
|
+
file = Pathname(backend).expand_path.to_s
|
17
|
+
@trecs_backend = file
|
16
18
|
end
|
17
19
|
|
18
20
|
def create_recording
|
@@ -1,21 +1,58 @@
|
|
1
1
|
require "strategies/raw_file_strategy"
|
2
|
+
require "frame"
|
2
3
|
|
3
4
|
module TRecs
|
4
5
|
class EmacsPluginStrategy < RawFileStrategy
|
5
|
-
def initialize(options={})
|
6
|
+
def initialize(options={})
|
6
7
|
file = "/tmp/emacs-session-recording.html"
|
7
8
|
@file = File.open(file)
|
8
9
|
|
9
10
|
@clock = options.fetch(:clock) { Time }
|
10
11
|
@testing = options.fetch(:testing) { false }
|
11
12
|
|
12
|
-
|
13
|
+
@width = 0
|
14
|
+
@height = 0
|
13
15
|
end
|
14
16
|
|
17
|
+
def perform
|
18
|
+
@recording = true
|
19
|
+
start_time = clock.now
|
20
|
+
|
21
|
+
frames = {}
|
22
|
+
|
23
|
+
while @recording
|
24
|
+
frames[timestamp(clock.now - start_time)] = File.read(@file)
|
25
|
+
custom_sleep(recorder.step)
|
26
|
+
end
|
27
|
+
|
28
|
+
frames.each do |_, content|
|
29
|
+
frame = Frame.new(content: content, format: "html")
|
30
|
+
@width = frame.width if frame.width > @width
|
31
|
+
@height = frame.height if frame.height > @height
|
32
|
+
end
|
33
|
+
|
34
|
+
frames.each do |time, content|
|
35
|
+
current_time(time)
|
36
|
+
current_content(content)
|
37
|
+
current_format("html")
|
38
|
+
save_frame
|
39
|
+
end
|
40
|
+
end
|
15
41
|
|
16
42
|
def current_content(content=nil)
|
17
|
-
content.
|
18
|
-
|
43
|
+
style = content.split("\n")
|
44
|
+
.join("\\n")[/<style type="text\/css">\\n <!--\\n (.+)\\n -->\\n <\/style>/, 1]
|
45
|
+
.split("\\n ").join("\n")
|
46
|
+
.gsub("body {", "pre.emacs-code {")
|
47
|
+
code = content
|
48
|
+
.split("\n").join("<do not compute>")[/\s+<pre>(.+)<\/pre>/, 1]
|
49
|
+
.split("<do not compute>").join("\n")
|
50
|
+
.gsub(/\/\*.+\*\//, "")
|
51
|
+
#.gsub!(/^\s/, "").gsub!(/^(<[^\/]\w+ (\w+=['"][^>]+['"])*>)+ /) {|m| m[-1]=""; m } # clean extra space at the begining of each line
|
52
|
+
|
53
|
+
new_content = "<style>#{style}</style><pre style='border: 2px solid #898989;width: #{@width}ex;height: #{@height}ex' class='emacs-code'>#{code}</pre>"
|
54
|
+
|
55
|
+
super(new_content)
|
19
56
|
end
|
20
57
|
end
|
21
58
|
end
|
data/lib/trecs/version.rb
CHANGED
@@ -25,13 +25,13 @@ module TRecs
|
|
25
25
|
def create_frame(options={})
|
26
26
|
time = options.fetch(:time)
|
27
27
|
content = options.fetch(:content)
|
28
|
-
format = options
|
28
|
+
format = options[:format]
|
29
29
|
|
30
30
|
frame = {
|
31
31
|
format: format,
|
32
32
|
content: content,
|
33
33
|
}
|
34
|
-
|
34
|
+
|
35
35
|
frames[time] = frame
|
36
36
|
end
|
37
37
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trecs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Federico Iachetti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: trollop
|