trecs 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1af4ab48e2ddf4708ce082fbf58661d2be18315e
|
4
|
+
data.tar.gz: d5476d4d97cbb09aa01a5bda951f65b7f0e95a9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84bb6266b6901012bfad708845410538b98e322e377ed92cce3be73079e39b4ebcaf2545c4ec8c0a75a1f1cb2a4ea91f3dd3bc77a1b22576b642fa37e1f29148
|
7
|
+
data.tar.gz: 16724b43e5a994b7d7a8cdb1895a60a85911ec9faefd5e96198173c90ae1c4bafabb1f5a7360e52849879fd403fe996f54c01ea0e58885a0aa76e9997ede3bfb
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,63 @@
|
|
1
|
+
require "recording_strategies/strategy"
|
2
|
+
require "recording_strategies/hash_strategy"
|
3
|
+
|
4
|
+
module TRecs
|
5
|
+
class AsteriskSwipeStrategy < HashStrategy
|
6
|
+
include Strategy
|
7
|
+
attr_reader :text
|
8
|
+
attr_reader :step
|
9
|
+
|
10
|
+
def initialize(options={})
|
11
|
+
@text = options.fetch(:text)
|
12
|
+
@step = options.fetch(:step) { 100 }
|
13
|
+
@frames = {}
|
14
|
+
end
|
15
|
+
|
16
|
+
def perform
|
17
|
+
max_line_size = text.each_line.inject(0) { |max, l| l.size > max ? l.size : max }
|
18
|
+
|
19
|
+
text.each_line do |line|
|
20
|
+
curr_text = " %-#{max_line_size}s " % line.chomp
|
21
|
+
(0..(curr_text.length-1)).each do |i|
|
22
|
+
current_time = step * i
|
23
|
+
|
24
|
+
c = curr_text.dup
|
25
|
+
c[i] = "|"
|
26
|
+
(i+1..c.length-3).each do |j|
|
27
|
+
c[j] = "*"
|
28
|
+
end
|
29
|
+
c = c[1..-2]
|
30
|
+
@frames[current_time] = "" unless @frames[current_time]
|
31
|
+
@frames[current_time] = @frames[current_time] << c.strip + "\n"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
@frames.each do |t, c|
|
35
|
+
@frames[t] = @frames[t].chomp
|
36
|
+
end
|
37
|
+
super
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
# ****
|
44
|
+
# ****
|
45
|
+
#
|
46
|
+
# |***
|
47
|
+
# |***
|
48
|
+
#
|
49
|
+
#
|
50
|
+
# h|**
|
51
|
+
# c|**
|
52
|
+
#
|
53
|
+
# ho|*
|
54
|
+
# ch|*
|
55
|
+
#
|
56
|
+
# hol|
|
57
|
+
# cha|
|
58
|
+
#
|
59
|
+
# hola|
|
60
|
+
# chau|
|
61
|
+
#
|
62
|
+
# hola|
|
63
|
+
# chau|
|
@@ -10,12 +10,18 @@ module TRecs
|
|
10
10
|
attr_accessor :__time
|
11
11
|
attr_accessor :__content
|
12
12
|
|
13
|
-
def current_time(time)
|
14
|
-
|
13
|
+
def current_time(time=nil)
|
14
|
+
if time
|
15
|
+
@__time = time
|
16
|
+
end
|
17
|
+
@__time
|
15
18
|
end
|
16
19
|
|
17
|
-
def current_content(content)
|
18
|
-
|
20
|
+
def current_content(content=nil)
|
21
|
+
if content
|
22
|
+
@__content = content
|
23
|
+
end
|
24
|
+
@__content
|
19
25
|
end
|
20
26
|
|
21
27
|
def save_frame
|
data/lib/trecs/version.rb
CHANGED
@@ -0,0 +1,54 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "recording_strategies/asterisk_swipe_strategy"
|
3
|
+
|
4
|
+
require "recorder"
|
5
|
+
require "recording_strategies/hash_strategy"
|
6
|
+
require "writers/in_memory_writer"
|
7
|
+
|
8
|
+
module TRecs
|
9
|
+
describe AsteriskSwipeStrategy do
|
10
|
+
context "initialization" do
|
11
|
+
When(:strategy) { AsteriskSwipeStrategy.new }
|
12
|
+
Then { expect(strategy).to have_raised(/key not found: :text/) }
|
13
|
+
end
|
14
|
+
|
15
|
+
context "performing" do
|
16
|
+
Given(:writer) { InMemoryWriter.new }
|
17
|
+
Given(:recorder) { Recorder.new(strategy: strategy, writer: writer) }
|
18
|
+
|
19
|
+
When { strategy.recorder = recorder }
|
20
|
+
When { recorder.record }
|
21
|
+
|
22
|
+
context "one char" do
|
23
|
+
Given(:strategy) { AsteriskSwipeStrategy.new(text: "a") }
|
24
|
+
Then { writer.frames[0] == "*" }
|
25
|
+
Then { writer.frames[100] == "|" }
|
26
|
+
Then { writer.frames[200] == "a|" }
|
27
|
+
Then { writer.frames[300] == "a" }
|
28
|
+
end
|
29
|
+
|
30
|
+
context "two chars" do
|
31
|
+
Given(:strategy) { AsteriskSwipeStrategy.new(text: "ab", step: 10) }
|
32
|
+
Then { writer.frames[0] == "**" }
|
33
|
+
Then { writer.frames[10] == "|*" }
|
34
|
+
Then { writer.frames[20] == "a|" }
|
35
|
+
Then { writer.frames[30] == "ab|" }
|
36
|
+
Then { writer.frames[40] == "ab" }
|
37
|
+
end
|
38
|
+
|
39
|
+
context "multiple_lines" do
|
40
|
+
Given(:strategy) { AsteriskSwipeStrategy.new(text: "FIRST\nSECOND") }
|
41
|
+
Then { writer.frames[0] == "******\n******" }
|
42
|
+
Then { writer.frames[100] == "|*****\n|*****" }
|
43
|
+
Then { writer.frames[200] == "F|****\nS|****" }
|
44
|
+
Then { writer.frames[300] == "FI|***\nSE|***" }
|
45
|
+
Then { writer.frames[400] == "FIR|**\nSEC|**" }
|
46
|
+
Then { writer.frames[500] == "FIRS|*\nSECO|*" }
|
47
|
+
Then { writer.frames[600] == "FIRST|\nSECON|" }
|
48
|
+
Then { writer.frames[700] == "FIRST |\nSECOND|" }
|
49
|
+
Then { writer.frames[800] == "FIRST\nSECOND" }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
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.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Federico Iachetti
|
@@ -122,6 +122,7 @@ files:
|
|
122
122
|
- lib/trecs/readers/json_reader.rb
|
123
123
|
- lib/trecs/readers/yaml_store_reader.rb
|
124
124
|
- lib/trecs/recorder.rb
|
125
|
+
- lib/trecs/recording_strategies/asterisk_swipe_strategy.rb
|
125
126
|
- lib/trecs/recording_strategies/config_strategy.rb
|
126
127
|
- lib/trecs/recording_strategies/custom_strategy.rb
|
127
128
|
- lib/trecs/recording_strategies/file_frames_strategy.rb
|
@@ -156,6 +157,7 @@ files:
|
|
156
157
|
- spec/trecs/readers/json_reader_spec.rb
|
157
158
|
- spec/trecs/readers/yaml_store_reader_spec.rb
|
158
159
|
- spec/trecs/recorder_spec.rb
|
160
|
+
- spec/trecs/recording_strategies/asterisk_swipe_strategy_spec.rb
|
159
161
|
- spec/trecs/recording_strategies/config_strategy_spec.rb
|
160
162
|
- spec/trecs/recording_strategies/file_frames_strategy_spec.rb
|
161
163
|
- spec/trecs/recording_strategies/fly_from_right_strategy_spec.rb
|
@@ -203,6 +205,7 @@ test_files:
|
|
203
205
|
- spec/trecs/readers/json_reader_spec.rb
|
204
206
|
- spec/trecs/readers/yaml_store_reader_spec.rb
|
205
207
|
- spec/trecs/recorder_spec.rb
|
208
|
+
- spec/trecs/recording_strategies/asterisk_swipe_strategy_spec.rb
|
206
209
|
- spec/trecs/recording_strategies/config_strategy_spec.rb
|
207
210
|
- spec/trecs/recording_strategies/file_frames_strategy_spec.rb
|
208
211
|
- spec/trecs/recording_strategies/fly_from_right_strategy_spec.rb
|