spritz_reader 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/bin/spritz +53 -0
  3. metadata +47 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: efd98842714479aa6b7d581b7eb617f982463578
4
+ data.tar.gz: 5d72644afe85080986dad52a90d5a0c6f9dffddd
5
+ SHA512:
6
+ metadata.gz: 52a6771fd1584fab32c8d84512478f28ab95f1a3bee16e073008f7dc45af193e69b854146602c3a9b7d9f29f50a74044b4b31165af0f80bf0a6c6a35f76e9c47
7
+ data.tar.gz: 521b2d3d21ac7eb52d9f0ae3eb3deacb47d2ee01921f9eb7676deec96849cb33aa1bfd227680db05104bbfc6ef3ee84e5b6f8ecf192bb19d9dae5d179ec7ef75
data/bin/spritz ADDED
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ if ARGV.index('-h')
4
+ puts "Usage: #{__FILE__} [-n word_per_minute] file..."
5
+ exit(0)
6
+ end
7
+
8
+ if idx = ARGV.index('-n')
9
+ WORD_PER_MINUTE = ARGV[idx+1].to_i
10
+ 2.times{ ARGV.delete_at(idx) }
11
+ else
12
+ WORD_PER_MINUTE = 250
13
+ end
14
+
15
+ SLEEP_SECONDS = 60.0 / WORD_PER_MINUTE
16
+ COLUMNS = 50
17
+
18
+ class String
19
+ def bold; "\033[1m#{self}\033[22m" end
20
+ def green; "\033[32m#{self}\033[0m" end
21
+ def gray; "\033[37m#{self}\033[0m" end
22
+ def optimal_index
23
+ idx = (0.35 * self.length).ceil
24
+ idx = 5 if idx > 5
25
+ idx -= 1
26
+ end
27
+
28
+ def print_word
29
+ idx = optimal_index
30
+ left_padding = COLUMNS/2 - idx
31
+ right_padding = COLUMNS/2 - (length - idx)
32
+
33
+ ret = "\r#{' '*left_padding}"
34
+ ret << "#{self[0, idx]}"
35
+ ret << "#{self[idx].green.bold}"
36
+ ret << "#{self[idx+1, length].gray}"
37
+ ret << "#{' '*right_padding}"
38
+ print ret
39
+ end
40
+ end
41
+
42
+ tail = ''
43
+ while read = ARGF.read(1024)
44
+ tail << read
45
+ tail.match /\S+\s*\z/
46
+ tail, words = $&, $`.scan(/\S+/)
47
+ while word = words.shift
48
+ word.print_word
49
+ sleep SLEEP_SECONDS
50
+ end
51
+ end
52
+ tail.print_word
53
+ puts
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spritz_reader
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jian Weihang
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-03 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |2-
14
+
15
+ Spritzing is reading text with Spritz Inc.'s patented technology. When you're spritzing, you're reading text one word at a time in our "redicle," a special visual frame we designed for reading.
16
+ email: tonytonyjan@gmail.com
17
+ executables:
18
+ - spritz
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - bin/spritz
23
+ homepage: https://github.com/tonytonyjan/spritz
24
+ licenses:
25
+ - MIT
26
+ metadata: {}
27
+ post_install_message:
28
+ rdoc_options: []
29
+ require_paths:
30
+ - lib
31
+ required_ruby_version: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements: []
42
+ rubyforge_project:
43
+ rubygems_version: 2.4.6
44
+ signing_key:
45
+ specification_version: 4
46
+ summary: Command line tool for spritz reading.
47
+ test_files: []