trecs 0.3.4 → 0.3.5
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 +0 -2
- data/bin/trecs_record +8 -4
- data/lib/trecs/strategies/trecs_file_strategy.rb +63 -0
- data/lib/trecs/version.rb +1 -1
- data/spec/trecs/strategies/file_frames_strategy_spec.rb +1 -3
- data/spec/trecs/strategies/trecs_file_strategy_spec.rb +8 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83bf7947322b7ce65b1f28184043e091e3b2f2a6
|
4
|
+
data.tar.gz: 159c0d1e8d5050b72f665937a8c97f7a1f81f5a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed8e0acfc531b32d21f8789e0b50abba641e5d7ad3f247d45e74a3f542b95c5f2ec2445000ac4eaa1b54fa026b2c844b061b74d568d63326a8780a9e0c6e44fc
|
7
|
+
data.tar.gz: f3f1f847161bd1a9a6ab065fb97e08870c31ba25814f7d0ca7e2241b47ec3cfbf301b9e15264a0a7573a0c2652791098bca545993917712c0c8f6d24786f8bba
|
data/Gemfile.lock
CHANGED
data/bin/trecs
CHANGED
data/bin/trecs_record
CHANGED
@@ -20,6 +20,10 @@ opts = Trollop::options do
|
|
20
20
|
opt :color, "Record colors", default: true
|
21
21
|
|
22
22
|
opt :audio, "Record audio"
|
23
|
+
|
24
|
+
opt :from, "Play from", type: Integer, default: 0
|
25
|
+
opt :to, "Play to", type: Integer, default: 0
|
26
|
+
opt :speed, "Playing speed", type: Float, default: 1.0
|
23
27
|
end
|
24
28
|
opts[:trecs_backend] = ARGV[0]
|
25
29
|
|
@@ -29,10 +33,10 @@ writer_class = TRecs::JsonWriter
|
|
29
33
|
strategy_file = "strategies/#{opts[:strategy]}_strategy"
|
30
34
|
require strategy_file
|
31
35
|
strategy_class_name = [
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
+
"TRecs::",
|
37
|
+
opts[:strategy].split(/[-_\s]/).map(&:capitalize),
|
38
|
+
"Strategy"
|
39
|
+
].join
|
36
40
|
strategy_class = strategy_class_name.split("::").reduce(Object) { |a, e| a.const_get e }
|
37
41
|
|
38
42
|
########## AUDIO ##########
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require "strategies/strategy"
|
2
|
+
require "sources/tgz_source"
|
3
|
+
require "player"
|
4
|
+
require "frame"
|
5
|
+
|
6
|
+
module TRecs
|
7
|
+
class TrecsFileStrategy
|
8
|
+
include Strategy
|
9
|
+
attr_reader :input_file
|
10
|
+
attr_reader :frames
|
11
|
+
attr_reader :from
|
12
|
+
attr_reader :to
|
13
|
+
attr_reader :speed
|
14
|
+
attr_reader :timestamps
|
15
|
+
|
16
|
+
def initialize(options={})
|
17
|
+
@input_file = options.fetch(:input_file)
|
18
|
+
|
19
|
+
source = TRecs::TgzSource.new(trecs_backend: input_file)
|
20
|
+
@frames = get_frames(source)
|
21
|
+
|
22
|
+
@from = options.fetch(:from) { nil }
|
23
|
+
@to = options.fetch(:to) { nil }
|
24
|
+
@speed = options.fetch(:speed) { nil }
|
25
|
+
end
|
26
|
+
|
27
|
+
def perform
|
28
|
+
timestamps.each do |time|
|
29
|
+
current_time(((time-from)/speed.to_f).to_i)
|
30
|
+
current_content(frames[time])
|
31
|
+
save_frame
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def timestamps
|
39
|
+
@timestamps ||= frames.keys.map(&:to_i).sort
|
40
|
+
if from
|
41
|
+
@timestamps = @timestamps.select { |t| t > from }
|
42
|
+
@timestamps.unshift(from)
|
43
|
+
end
|
44
|
+
if to && to > 0
|
45
|
+
@timestamps = @timestamps.select { |t| t < to }
|
46
|
+
@timestamps.push(to)
|
47
|
+
end
|
48
|
+
@timestamps
|
49
|
+
end
|
50
|
+
|
51
|
+
def get_frames(source)
|
52
|
+
frames = {}
|
53
|
+
source.read do
|
54
|
+
json_string = source.read_entry("frames.json") || "{}"
|
55
|
+
parsed_json = JSON.parse(json_string, symbolize_names: true)
|
56
|
+
parsed_json.each do |time, value|
|
57
|
+
frames[Integer(time.to_s)] = Frame(value)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
frames
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/lib/trecs/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Federico Iachetti
|
@@ -136,6 +136,7 @@ files:
|
|
136
136
|
- lib/trecs/strategies/shell_command_strategy.rb
|
137
137
|
- lib/trecs/strategies/strategy.rb
|
138
138
|
- lib/trecs/strategies/tmux_session_strategy.rb
|
139
|
+
- lib/trecs/strategies/trecs_file_strategy.rb
|
139
140
|
- lib/trecs/strategies/ttyrec_strategy.rb
|
140
141
|
- lib/trecs/tickers/clock_ticker.rb
|
141
142
|
- lib/trecs/tickers/terminal_input_ticker.rb
|
@@ -167,6 +168,7 @@ files:
|
|
167
168
|
- spec/trecs/strategies/incremental_strategy_spec.rb
|
168
169
|
- spec/trecs/strategies/raw_file_strategy_spec.rb
|
169
170
|
- spec/trecs/strategies/shell_command_strategy_spec.rb
|
171
|
+
- spec/trecs/strategies/trecs_file_strategy_spec.rb
|
170
172
|
- spec/trecs/tickers/clock_ticker_spec.rb
|
171
173
|
- spec/trecs/writers/in_memory_writer_spec.rb
|
172
174
|
- spec/trecs/writers/json_writer_spec.rb
|
@@ -215,6 +217,7 @@ test_files:
|
|
215
217
|
- spec/trecs/strategies/incremental_strategy_spec.rb
|
216
218
|
- spec/trecs/strategies/raw_file_strategy_spec.rb
|
217
219
|
- spec/trecs/strategies/shell_command_strategy_spec.rb
|
220
|
+
- spec/trecs/strategies/trecs_file_strategy_spec.rb
|
218
221
|
- spec/trecs/tickers/clock_ticker_spec.rb
|
219
222
|
- spec/trecs/writers/in_memory_writer_spec.rb
|
220
223
|
- spec/trecs/writers/json_writer_spec.rb
|