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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c053bd688656f93ca597389353a860b3ded0f497
4
- data.tar.gz: 0dcbd07ec1349b348c30144910edcb2d38b05f13
3
+ metadata.gz: 83bf7947322b7ce65b1f28184043e091e3b2f2a6
4
+ data.tar.gz: 159c0d1e8d5050b72f665937a8c97f7a1f81f5a9
5
5
  SHA512:
6
- metadata.gz: 7e6a2ed26d1dfb9599c029898720fc8859cd22a713d7ee999118927c2bdb3317ad8061d58fb9784e04f9281ac7b63c6d7a3f0744ef72a3733499a6414d754de4
7
- data.tar.gz: fc09c1a4621a981987cd05fd994cc69ecbe07b492fceb52d97406e0c5ac501de30798db7b03ae6e3586c9ca5c6fe069d8ff1a4486e8c4c05c21b62096ebd3c8d
6
+ metadata.gz: ed8e0acfc531b32d21f8789e0b50abba641e5d7ad3f247d45e74a3f542b95c5f2ec2445000ac4eaa1b54fa026b2c844b061b74d568d63326a8780a9e0c6e44fc
7
+ data.tar.gz: f3f1f847161bd1a9a6ab065fb97e08870c31ba25814f7d0ca7e2241b47ec3cfbf301b9e15264a0a7573a0c2652791098bca545993917712c0c8f6d24786f8bba
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- trecs (0.3.4)
4
+ trecs (0.3.5)
5
5
  minitar (~> 0.5.4)
6
6
  trollop (~> 2.0)
7
7
 
data/bin/trecs CHANGED
@@ -58,8 +58,6 @@ def stop_sound_player
58
58
  end
59
59
  ######## END AUDIO ########
60
60
 
61
-
62
-
63
61
  source = TRecs::TgzSource.new(trecs_backend: opts.fetch(:trecs_backend))
64
62
  reader = source.build_reader(opts)
65
63
 
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
- "TRecs::",
33
- opts[:strategy].split(/[-_\s]/).map(&:capitalize),
34
- "Strategy"
35
- ].join
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
@@ -1,3 +1,3 @@
1
1
  module TRecs
2
- VERSION = "0.3.4"
2
+ VERSION = "0.3.5"
3
3
  end
@@ -3,8 +3,6 @@ require "strategies/file_frames_strategy"
3
3
 
4
4
  module TRecs
5
5
  describe FileFramesStrategy do
6
- context "initialization" do
7
- skip("FileFramesStrategy")
8
- end
6
+ skip("FileFramesStrategy")
9
7
  end
10
8
  end
@@ -0,0 +1,8 @@
1
+ require "spec_helper"
2
+ require "strategies/trecs_file_strategy"
3
+
4
+ module TRecs
5
+ describe TrecsFileStrategy do
6
+ skip("TrecsFileStrategy")
7
+ end
8
+ end
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
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