trecs 0.2.2 → 0.2.3
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: 4cc795a9ca5013664916c0ba34da4d00a70dd217
|
4
|
+
data.tar.gz: 1d83ad903e4e6541142b0c9beb228cca14b9af8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6156e0bafe7db093e2d7b6155e2befed626f29b77942960e5837f6bc97876ce5f17c483980bcc33e8d4419d661428fe742197106dd5c16dac37a7722bd616e7d
|
7
|
+
data.tar.gz: 100a464b6f6949b36c7da8862e17cc60fd17befe740d02b9024a118ca77d62c32b1863c9db3d25acb7e4e50532bddf3733b08780e488261f38bcbf17a6a445c4
|
data/Gemfile.lock
CHANGED
@@ -4,24 +4,24 @@ require "recording_strategies/hash_strategy"
|
|
4
4
|
module TRecs
|
5
5
|
class AsteriskSwipeStrategy < HashStrategy
|
6
6
|
include Strategy
|
7
|
-
attr_reader :
|
7
|
+
attr_reader :message
|
8
8
|
attr_reader :step
|
9
9
|
|
10
10
|
def initialize(options={})
|
11
|
-
@
|
11
|
+
@message = options.fetch(:message)
|
12
12
|
@step = options.fetch(:step) { 100 }
|
13
13
|
@frames = {}
|
14
14
|
end
|
15
15
|
|
16
16
|
def perform
|
17
|
-
max_line_size =
|
17
|
+
max_line_size = message.each_line.inject(0) { |max, l| l.size > max ? l.size : max }
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
(0..(
|
19
|
+
message.each_line do |line|
|
20
|
+
curr_message = " %-#{max_line_size}s " % line.chomp
|
21
|
+
(0..(curr_message.length-1)).each do |i|
|
22
22
|
current_time = step * i
|
23
23
|
|
24
|
-
c =
|
24
|
+
c = curr_message.dup
|
25
25
|
c[i] = "|"
|
26
26
|
(i+1..c.length-3).each do |j|
|
27
27
|
c[j] = "*"
|
data/lib/trecs/version.rb
CHANGED
@@ -9,7 +9,7 @@ module TRecs
|
|
9
9
|
describe AsteriskSwipeStrategy do
|
10
10
|
context "initialization" do
|
11
11
|
When(:strategy) { AsteriskSwipeStrategy.new }
|
12
|
-
Then { expect(strategy).to have_raised(/key not found: :
|
12
|
+
Then { expect(strategy).to have_raised(/key not found: :message/) }
|
13
13
|
end
|
14
14
|
|
15
15
|
context "performing" do
|
@@ -20,7 +20,7 @@ module TRecs
|
|
20
20
|
When { recorder.record }
|
21
21
|
|
22
22
|
context "one char" do
|
23
|
-
Given(:strategy) { AsteriskSwipeStrategy.new(
|
23
|
+
Given(:strategy) { AsteriskSwipeStrategy.new(message: "a") }
|
24
24
|
Then { writer.frames[0] == "*" }
|
25
25
|
Then { writer.frames[100] == "|" }
|
26
26
|
Then { writer.frames[200] == "a|" }
|
@@ -28,7 +28,7 @@ module TRecs
|
|
28
28
|
end
|
29
29
|
|
30
30
|
context "two chars" do
|
31
|
-
Given(:strategy) { AsteriskSwipeStrategy.new(
|
31
|
+
Given(:strategy) { AsteriskSwipeStrategy.new(message: "ab", step: 10) }
|
32
32
|
Then { writer.frames[0] == "**" }
|
33
33
|
Then { writer.frames[10] == "|*" }
|
34
34
|
Then { writer.frames[20] == "a|" }
|
@@ -37,7 +37,7 @@ module TRecs
|
|
37
37
|
end
|
38
38
|
|
39
39
|
context "multiple_lines" do
|
40
|
-
Given(:strategy) { AsteriskSwipeStrategy.new(
|
40
|
+
Given(:strategy) { AsteriskSwipeStrategy.new(message: "FIRST\nSECOND") }
|
41
41
|
Then { writer.frames[0] == "******\n******" }
|
42
42
|
Then { writer.frames[100] == "|*****\n|*****" }
|
43
43
|
Then { writer.frames[200] == "F|****\nS|****" }
|