speed_read 0.0.2 → 0.0.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: 8c18cbb3384e6b9f1321329ff81099620e60c44f
4
- data.tar.gz: bdfe2be84edc5d9abf3fb7d6995f111679fd055b
3
+ metadata.gz: cb7b5ef3479063b640ffef7d3caf382c9e064e70
4
+ data.tar.gz: be41ccf89568cda208ab5e9c29578ee73fb017eb
5
5
  SHA512:
6
- metadata.gz: 2a6ae8ba6f2966bf98c6a35f6be80ea0d7e74465d8142c76ee9ff85e6913538530a0c1ffdbc90b7fee6c8cdc8d482743a3da5fdac68a3ab733a7fcc6a62de2ce
7
- data.tar.gz: 127a83b8d82d062d4a9faf9c48b1bd82011b4218d5dd82dd747b9cab2e9a570d6d6ff4e03f937a7299b646fb5dc89a44e0a48a37fba71cf72555cd860b083277
6
+ metadata.gz: d7793636003ab2307a51aacffc088fc7f719013e6b3b45818831940d902ef4076bbaa79de1fed6563d42337f30c812dce5eb423b372de4f75e45135b89b373e3
7
+ data.tar.gz: 3550e3a102fe655cc2b187916ab0ce18e842ab816c3048e398122d6272ed29599178862137e0a1cc860e0c47170e4ec9c39566b425540c9b5edad2bfd9862130
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.0.3 / 2014-03-04
2
+ * Improve test coverage.
3
+ * Improve helper script to build and test.
4
+ * Add helper script to push the gem.
5
+
1
6
  == 0.0.2 / 2014-03-03
2
7
  * Update homepage url.
3
8
 
@@ -1,3 +1,3 @@
1
1
  module SpeedRead
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
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.chomp.split(/(?:-|\s)+/).compact.reject{|e| e.empty?}
15
- words.each do |w|
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
- i = find_ORP(word);
19
- output = " " * (ORP_VISUAL_POS-i) + colorize_word(word,i)
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 ./speed_read-0.0.2.gem && head -n 21 tea.txt | speed_read
2
+ gem build speed_read.gemspec && gem install `ls -1 speed_read-0.0.* | tail -n1` && head -n 21 tea.txt | speed_read
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env bash
2
+ gem build speed_read.gemspec && gem push `ls -1 speed_read-0.0.* | tail -n1`
@@ -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.2
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