trecs 0.0.9 → 0.1.0
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/bin/trecs +4 -2
- data/bin/trecs_record +66 -0
- data/lib/trecs/recording_strategies/raw_file_strategy.rb +1 -1
- data/lib/trecs/recording_strategies/ttyrec_strategy.rb +76 -0
- data/lib/trecs/version.rb +1 -1
- data/lib/trecs/writers/yaml_store_writer.rb +1 -0
- data/pkg/trecs-0.0.9.gem +0 -0
- metadata +6 -3
- data/lib/trecs/recording_strategies/ttyrec_recording_strategy.rb +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 757f42c4df411d64d4dc4d17376c0f745bd944da
|
4
|
+
data.tar.gz: e36e0606e3856f86687f4a541c9c359878ada950
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc09b46d6ea86b06692337e2d449576ff3881505c9084592855d6a2c89f94dc42cf80c1119d6aebae34a98a80239c903378f7d052acf668be2b7144494066862
|
7
|
+
data.tar.gz: e558d76ab3bf1277184acc067db519a9b99c3b8e6687b9607bf5ddda5c5ee7fe775d9b249da9924506db463e7ba244af44981f2b9884cf53efcacc2a2d8aa328
|
data/Gemfile.lock
CHANGED
data/bin/trecs
CHANGED
data/bin/trecs_record
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift(File.expand_path("../../lib", __FILE__))
|
4
|
+
require "trecs"
|
5
|
+
require "recorder"
|
6
|
+
require "trollop"
|
7
|
+
|
8
|
+
|
9
|
+
opts = Trollop::options do
|
10
|
+
opt :step, "Time in ms between frames", short: 's', default: 100
|
11
|
+
opt :format, "File format", type: String, default: "yaml_store"
|
12
|
+
opt :strategy, "Strategy", type: String, default: "incremental"
|
13
|
+
|
14
|
+
opt :message, "Message to record", type: String, default: "TRecs!"
|
15
|
+
opt :input_file, "File to record", type: String, default: ""
|
16
|
+
opt :terminal, "Launch terminal", default: true
|
17
|
+
|
18
|
+
end
|
19
|
+
opts[:trecs_file] = ARGV[0]
|
20
|
+
|
21
|
+
writer_file = "writers/#{opts[:format]}_writer"
|
22
|
+
require writer_file
|
23
|
+
writer_class = Kernel.const_get([
|
24
|
+
"TRecs::",
|
25
|
+
opts[:format].split(/[-_\s]/).map(&:capitalize),
|
26
|
+
"Writer"
|
27
|
+
].join
|
28
|
+
)
|
29
|
+
|
30
|
+
|
31
|
+
strategy_file = "recording_strategies/#{opts[:strategy]}_strategy"
|
32
|
+
require strategy_file
|
33
|
+
strategy_class = Kernel.const_get([
|
34
|
+
"TRecs::",
|
35
|
+
opts[:strategy].split(/[-_\s]/).map(&:capitalize),
|
36
|
+
"Strategy"
|
37
|
+
].join
|
38
|
+
)
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
puts "Recording ..."
|
43
|
+
|
44
|
+
if strategy_class == TRecs::TtyrecStrategy
|
45
|
+
opts[:height], opts[:width] = `stty size`.split(" ").map(&:to_i)
|
46
|
+
system "ttyrec #{opts[:input_file]}" if opts[:terminal]
|
47
|
+
end
|
48
|
+
|
49
|
+
recorder_options = {
|
50
|
+
writer: writer_class.new(opts),
|
51
|
+
strategy: strategy_class.new(opts),
|
52
|
+
step: opts[:step],
|
53
|
+
}
|
54
|
+
|
55
|
+
|
56
|
+
RECORDER = TRecs::Recorder.new(recorder_options)
|
57
|
+
|
58
|
+
trap "SIGINT" do
|
59
|
+
RECORDER.stop
|
60
|
+
end
|
61
|
+
|
62
|
+
RECORDER.record
|
63
|
+
|
64
|
+
puts "Recording finished"
|
65
|
+
puts "Play with:"
|
66
|
+
puts " bin/trecs #{opts[:trecs_file]}"
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module TRecs
|
2
|
+
class TtyrecStrategy
|
3
|
+
attr_accessor :recorder
|
4
|
+
|
5
|
+
def initialize(options={})
|
6
|
+
file = options.fetch(:input_file)
|
7
|
+
@file = File.new(file)
|
8
|
+
@frames = []
|
9
|
+
@full_output = ""
|
10
|
+
@height = options.fetch(:height) { 24 }
|
11
|
+
@width = options.fetch(:width) { 80 }
|
12
|
+
end
|
13
|
+
|
14
|
+
def perform
|
15
|
+
@prev_timestamp = 0
|
16
|
+
@prev_frame = ""
|
17
|
+
while !@file.eof?
|
18
|
+
sec, usec, len = @file.read(12).unpack('VVV')
|
19
|
+
curr_data = @file.read(len)
|
20
|
+
@full_output << curr_data
|
21
|
+
|
22
|
+
#data_array = @full_output.each_line.to_a
|
23
|
+
#height = data_array.size > @height ? @height : 0
|
24
|
+
#frame = data_array[-height..-1].join
|
25
|
+
|
26
|
+
frame = @prev_frame + curr_data
|
27
|
+
|
28
|
+
@first_timestamp ||= [ sec, usec ].join('.').to_f
|
29
|
+
curr_timestamp = [ sec, usec ].join('.').to_f
|
30
|
+
offset = ((curr_timestamp - @first_timestamp)*1000).to_i
|
31
|
+
|
32
|
+
if curr_timestamp > @prev_timestamp
|
33
|
+
recorder.current_frame(time: offset, content: frame)
|
34
|
+
@prev_timestamp = curr_timestamp
|
35
|
+
@prev_frame = frame
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# module TRecs
|
43
|
+
# class TtyrecStrategy
|
44
|
+
# attr_accessor :recorder
|
45
|
+
|
46
|
+
# def initialize(options={})
|
47
|
+
# file = options.fetch(:input_file)
|
48
|
+
# @file = File.new(file)
|
49
|
+
# @frames = []
|
50
|
+
# @full_output = ""
|
51
|
+
# @height = options.fetch(:height) { 24 }
|
52
|
+
# @width = options.fetch(:width) { 80 }
|
53
|
+
# end
|
54
|
+
|
55
|
+
# def perform
|
56
|
+
# @prev_timestamp = 0
|
57
|
+
# while !@file.eof?
|
58
|
+
# sec, usec, len = @file.read(12).unpack('VVV')
|
59
|
+
# @full_output << @file.read(len)
|
60
|
+
|
61
|
+
# data_array = @full_output.each_line.to_a
|
62
|
+
# height = data_array.size > @height ? @height : 0
|
63
|
+
# frame = data_array[-height..-1].join
|
64
|
+
|
65
|
+
# @first_timestamp ||= [ sec, usec ].join('.').to_f
|
66
|
+
# curr_timestamp = [ sec, usec ].join('.').to_f
|
67
|
+
# offset = ((curr_timestamp - @first_timestamp)*1000).to_i
|
68
|
+
|
69
|
+
# if curr_timestamp > @prev_timestamp
|
70
|
+
# recorder.current_frame(time: offset, content: frame)
|
71
|
+
# @prev_timestamp = curr_timestamp
|
72
|
+
# end
|
73
|
+
# end
|
74
|
+
# end
|
75
|
+
# end
|
76
|
+
# end
|
data/lib/trecs/version.rb
CHANGED
data/pkg/trecs-0.0.9.gem
ADDED
Binary file
|
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.0
|
4
|
+
version: 0.1.0
|
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-06-
|
11
|
+
date: 2014-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|
@@ -129,6 +129,7 @@ executables:
|
|
129
129
|
- trecs
|
130
130
|
- trecs_message
|
131
131
|
- trecs_raw_file
|
132
|
+
- trecs_record
|
132
133
|
- trecs_terminal
|
133
134
|
extensions: []
|
134
135
|
extra_rdoc_files: []
|
@@ -146,6 +147,7 @@ files:
|
|
146
147
|
- bin/trecs
|
147
148
|
- bin/trecs_message
|
148
149
|
- bin/trecs_raw_file
|
150
|
+
- bin/trecs_record
|
149
151
|
- bin/trecs_terminal
|
150
152
|
- doc/steps.org
|
151
153
|
- lib/players/zip_file_player.rb
|
@@ -162,7 +164,7 @@ files:
|
|
162
164
|
- lib/trecs/recording_strategies/hash_strategy.rb
|
163
165
|
- lib/trecs/recording_strategies/incremental_strategy.rb
|
164
166
|
- lib/trecs/recording_strategies/raw_file_strategy.rb
|
165
|
-
- lib/trecs/recording_strategies/
|
167
|
+
- lib/trecs/recording_strategies/ttyrec_strategy.rb
|
166
168
|
- lib/trecs/screens/terminal_screen.rb
|
167
169
|
- lib/trecs/tickers/terminal_input_ticker.rb
|
168
170
|
- lib/trecs/tickers/ticker.rb
|
@@ -186,6 +188,7 @@ files:
|
|
186
188
|
- pkg/trecs-0.0.6.gem
|
187
189
|
- pkg/trecs-0.0.7.gem
|
188
190
|
- pkg/trecs-0.0.8.gem
|
191
|
+
- pkg/trecs-0.0.9.gem
|
189
192
|
- sandbox/create_recording.rb
|
190
193
|
- sandbox/lipsum_end
|
191
194
|
- sandbox/lipsum_start
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require "recording_strategy"
|
2
|
-
module TRecs
|
3
|
-
class TtyrecRecordingStrategy < RecordingStrategy
|
4
|
-
def initialize(file:, height: 24, width: 80, **options)
|
5
|
-
@file = File.new(file)
|
6
|
-
@frames = []
|
7
|
-
@full_output = ""
|
8
|
-
@height = height
|
9
|
-
@width = width
|
10
|
-
super
|
11
|
-
end
|
12
|
-
|
13
|
-
def perform
|
14
|
-
while !@file.eof?
|
15
|
-
sec, usec, len = @file.read(12).unpack('VVV')
|
16
|
-
@full_output << @file.read(len)
|
17
|
-
|
18
|
-
data_array = @full_output.each_line.to_a
|
19
|
-
height = data_array.size > @height ? @height : 0
|
20
|
-
frame = data_array[-height..-1].join
|
21
|
-
|
22
|
-
prev_timestamp ||= [ sec, usec ].join('.').to_f
|
23
|
-
curr_timestamp = [ sec, usec ].join('.').to_f
|
24
|
-
offset = ((curr_timestamp - prev_timestamp)*1000).to_i
|
25
|
-
|
26
|
-
recorder.current_frame(time: offset, content: frame)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|