speed_read 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +5 -0
- data/lib/speed_read/version.rb +1 -1
- data/lib/speed_read.rb +8 -5
- data/scripts/build_install_test.sh +1 -1
- data/scripts/publish.sh +2 -0
- data/test/speed_read_test.rb +25 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb7b5ef3479063b640ffef7d3caf382c9e064e70
|
4
|
+
data.tar.gz: be41ccf89568cda208ab5e9c29578ee73fb017eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7793636003ab2307a51aacffc088fc7f719013e6b3b45818831940d902ef4076bbaa79de1fed6563d42337f30c812dce5eb423b372de4f75e45135b89b373e3
|
7
|
+
data.tar.gz: 3550e3a102fe655cc2b187916ab0ce18e842ab816c3048e398122d6272ed29599178862137e0a1cc860e0c47170e4ec9c39566b425540c9b5edad2bfd9862130
|
data/History.txt
CHANGED
data/lib/speed_read/version.rb
CHANGED
data/lib/speed_read.rb
CHANGED
@@ -11,12 +11,11 @@ module SpeedRead
|
|
11
11
|
def start(words_per_minute)
|
12
12
|
puts " " * ORP_VISUAL_POS + "v".colorize(:red)
|
13
13
|
ARGF.each do |line|
|
14
|
-
words = line
|
15
|
-
words.each do |
|
16
|
-
word = w.chomp.strip
|
14
|
+
words = tokenize(line)
|
15
|
+
words.each do |word|
|
17
16
|
# pad the end of your lines with spaces if they might be shorter than the previous line.
|
18
|
-
|
19
|
-
output = " " * (ORP_VISUAL_POS-
|
17
|
+
orp = find_ORP(word);
|
18
|
+
output = " " * (ORP_VISUAL_POS-orp) + colorize_word(word,orp)
|
20
19
|
print output.ljust(80, " ") + "#{words_per_minute} wpm\r"
|
21
20
|
$stdout.flush
|
22
21
|
sleep (60.0 / words_per_minute.to_i)
|
@@ -25,6 +24,10 @@ module SpeedRead
|
|
25
24
|
puts
|
26
25
|
end
|
27
26
|
|
27
|
+
def tokenize(input)
|
28
|
+
input.chomp.split(/(?:-|\s)+/).compact.reject{|e| e.empty?}
|
29
|
+
end
|
30
|
+
|
28
31
|
# ORP: Optical Recognition Point (the red-colored alignment pilot),
|
29
32
|
# # the way Spritz probably does it.
|
30
33
|
def find_ORP(word)
|
@@ -1,2 +1,2 @@
|
|
1
1
|
#!/usr/bin/env bash
|
2
|
-
gem build speed_read.gemspec && gem install
|
2
|
+
gem build speed_read.gemspec && gem install `ls -1 speed_read-0.0.* | tail -n1` && head -n 21 tea.txt | speed_read
|
data/scripts/publish.sh
ADDED
data/test/speed_read_test.rb
CHANGED
@@ -4,6 +4,31 @@ require 'minitest/autorun'
|
|
4
4
|
|
5
5
|
class SpeedReadTest < Minitest::Unit::TestCase
|
6
6
|
|
7
|
+
def test_word_tokenization
|
8
|
+
assert_equal ["a", "b", "c"], SpeedRead.tokenize("a b c")
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_word_tokenization_with_punctuation
|
12
|
+
assert_equal ["a", "b", "c."], SpeedRead.tokenize("a b c.")
|
13
|
+
assert_equal ["a", "b", "c?"], SpeedRead.tokenize("a b c?")
|
14
|
+
assert_equal ["a", "b:", "c"], SpeedRead.tokenize("a b: c")
|
15
|
+
assert_equal ["a,", "b", "c"], SpeedRead.tokenize("a, b c")
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_word_tokenization_with_new_line
|
19
|
+
assert_equal ["a", "b", "c"], SpeedRead.tokenize("a b c\n")
|
20
|
+
assert_equal ["a", "b", "c"], SpeedRead.tokenize("\na b c")
|
21
|
+
assert_equal ["a", "b", "c"], SpeedRead.tokenize("\na \nb \nc\n")
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_word_tokenization_with_leading_whitespaces
|
25
|
+
assert_equal ["a", "b", "c"], SpeedRead.tokenize(" a b c")
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_word_tokenization_with_trailing_whitespaces
|
29
|
+
assert_equal ["a", "b", "c"], SpeedRead.tokenize("a b c ")
|
30
|
+
end
|
31
|
+
|
7
32
|
def test_find_correct_orp
|
8
33
|
assert_equal 0, SpeedRead.find_ORP("")
|
9
34
|
assert_equal 0, SpeedRead.find_ORP("1")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: speed_read
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Arni
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- lib/speed_read.rb
|
72
72
|
- lib/speed_read/version.rb
|
73
73
|
- scripts/build_install_test.sh
|
74
|
+
- scripts/publish.sh
|
74
75
|
- speed_read.gemspec
|
75
76
|
- tea.txt
|
76
77
|
- test/speed_read_test.rb
|