speed_read 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 68eab501d2fbfe6779d2d9114b0c2cbe0a34b671
4
+ data.tar.gz: df2088a97800293b28070ec6ba04f2b119540866
5
+ SHA512:
6
+ metadata.gz: d8bb2ec82f771c73da8e28c788624cddfed66b0a22cb18013da366d4d3da85c2e67687f3191b1c28e6e95605a1a494ac041e53a8de05e5db8577259210538767
7
+ data.tar.gz: 4fcd316b424c64e4f06f0558fa34f772b3745bb47279f2b8fff95d66c6258b68d5fe4a3e305f421da838032198a9723ed967dc43444f2d51cb031be2a5e79983
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in speed_read.gemspec
4
+ gemspec
data/History.txt ADDED
@@ -0,0 +1,2 @@
1
+ == 0.0.1 / 2014-03-03
2
+ * Birthday!
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Thomas Arni
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # SpeedRead
2
+
3
+ This is a yet simplistic implementation in ruby of [Pasky's Perl version](https://github.com/pasky/speedread).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'speed_read'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install speed_read
18
+
19
+ ## Usage
20
+ speed_read reads from standard input. Thus,
21
+ you can use the usual unix suspects.
22
+
23
+ $ echo "one two tree" | speed_read
24
+ $ speed_read < your_text_file.txt
25
+ $ cat your_text_file.txt | speed_read
26
+
27
+ To set the words per minute use
28
+
29
+ $ echo "one two tree" | speed_read -w 500
30
+
31
+ ## Test
32
+ In order to test the gem locally, use:
33
+
34
+ bundle exec rake test
35
+
36
+ ## Contributing
37
+
38
+ 1. Fork it ( http://github.com/sunsations/speed_read/fork )
39
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
40
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
41
+ 4. Push to the branch (`git push origin my-new-feature`)
42
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.pattern = 'test/**/*_test.rb'
6
+ end
7
+
8
+ desc "Run tests"
9
+ task default: :test
data/bin/speed_read ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'colorize'
4
+ require 'optparse'
5
+ require 'speed_read'
6
+
7
+ options = {}
8
+ optparse = OptionParser.new do|opts|
9
+ opts.banner = "Usage: speed_read [options] file1 file2 ..."
10
+ options[:wpm] = 250
11
+ opts.on('-w', '--wpm WPM', 'Sets words per minute to WPM') do |wpm|
12
+ options[:wpm] = wpm.to_i
13
+ end
14
+ end
15
+ optparse.parse!
16
+
17
+ SpeedRead.start(options[:wpm])
@@ -0,0 +1,3 @@
1
+ module SpeedRead
2
+ VERSION = "0.0.1"
3
+ end
data/lib/speed_read.rb ADDED
@@ -0,0 +1,45 @@
1
+ require "speed_read/version"
2
+ require "colorize"
3
+
4
+ module SpeedRead
5
+
6
+ ORP_VISUAL_POS = 20;
7
+
8
+ class << self
9
+ trap("INT") { puts "\nGoodbye!"; exit;}
10
+
11
+ def start(words_per_minute)
12
+ puts " " * ORP_VISUAL_POS + "v".colorize(:red)
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
17
+ # 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)
20
+ print output.ljust(80, " ") + "#{words_per_minute} wpm\r"
21
+ $stdout.flush
22
+ sleep (60.0 / words_per_minute.to_i)
23
+ end
24
+ end
25
+ puts
26
+ end
27
+
28
+ # ORP: Optical Recognition Point (the red-colored alignment pilot),
29
+ # # the way Spritz probably does it.
30
+ def find_ORP(word)
31
+ return 0 if word.nil?
32
+ return 4 if word.length > 13
33
+ return [0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3][word.size];
34
+ end
35
+
36
+ def colorize_word(word, i)
37
+ return "" unless word
38
+ pre = word[0...i]
39
+ pivot = word[i] ? word[i].colorize(:red) : ""
40
+ suffix = word[i+1..-1]
41
+ "#{pre}#{pivot}#{suffix}"
42
+ end
43
+
44
+ end
45
+ end
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env bash
2
+ gem build speed_read.gemspec && gem install ./speed_read-0.0.1.gem && head -n 21 tea.txt | speed_read
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'speed_read/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "speed_read"
8
+ spec.version = SpeedRead::VERSION
9
+ spec.authors = ["Thomas Arni"]
10
+ spec.email = ["thomas.arni@gmail.com"]
11
+ spec.summary = %q{A simple terminal-based open source spritz-alike.}
12
+ spec.description = %q{A simple terminal-based open source spritz-alike. Allows you to read at a much more rapid pace.}
13
+ #TODO set correct homepage
14
+ spec.homepage = "https://github.com/sunsations"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files`.split($/)
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.4"
23
+ spec.add_development_dependency "rake", '~> 0'
24
+ spec.add_dependency 'colorize', '~> 0.6'
25
+ end
data/tea.txt ADDED
@@ -0,0 +1,113 @@
1
+ A Nice Cup of Tea
2
+
3
+ By George Orwell
4
+
5
+ Evening Standard, 12 January 1946.
6
+
7
+ If you look up 'tea' in the first cookery book that comes to hand you will
8
+ probably find that it is unmentioned; or at most you will find a few lines
9
+ of sketchy instructions which give no ruling on several of the most
10
+ important points.
11
+
12
+ This is curious, not only because tea is one of the main stays of
13
+ civilization in this country, as well as in Eire, Australia and New
14
+ Zealand, but because the best manner of making it is the subject of
15
+ violent disputes.
16
+
17
+ When I look through my own recipe for the perfect cup of tea, I find no
18
+ fewer than eleven outstanding points. On perhaps two of them there would
19
+ be pretty general agreement, but at least four others are acutely
20
+ controversial. Here are my own eleven rules, every one of which I regard
21
+ as golden:
22
+
23
+ * First of all, one should use Indian or Ceylonese tea. China tea has
24
+ virtues which are not to be despised nowadays — it is economical, and
25
+ one can drink it without milk — but there is not much stimulation in
26
+ it. One does not feel wiser, braver or more optimistic after drinking
27
+ it. Anyone who has used that comforting phrase 'a nice cup of tea'
28
+ invariably means Indian tea.
29
+
30
+ * Secondly, tea should be made in small quantities — that is, in a
31
+ teapot. Tea out of an urn is always tasteless, while army tea, made in
32
+ a cauldron, tastes of grease and whitewash. The teapot should be made
33
+ of china or earthenware. Silver or Britanniaware teapots produce
34
+ inferior tea and enamel pots are worse; though curiously enough a
35
+ pewter teapot (a rarity nowadays) is not so bad.
36
+
37
+ * Thirdly, the pot should be warmed beforehand. This is better done by
38
+ placing it on the hob than by the usual method of swilling it out with
39
+ hot water.
40
+
41
+ * Fourthly, the tea should be strong. For a pot holding a quart, if you
42
+ are going to fill it nearly to the brim, six heaped teaspoons would be
43
+ about right. In a time of rationing, this is not an idea that can be
44
+ realized on every day of the week, but I maintain that one strong cup
45
+ of tea is better than twenty weak ones. All true tea lovers not only
46
+ like their tea strong, but like it a little stronger with each year
47
+ that passes — a fact which is recognized in the extra ration issued to
48
+ old-age pensioners.
49
+
50
+ * Fifthly, the tea should be put straight into the pot. No strainers,
51
+ muslin bags or other devices to imprison the tea. In some countries
52
+ teapots are fitted with little dangling baskets under the spout to
53
+ catch the stray leaves, which are supposed to be harmful. Actually one
54
+ can swallow tea-leaves in considerable quantities without ill effect,
55
+ and if the tea is not loose in the pot it never infuses properly.
56
+
57
+ * Sixthly, one should take the teapot to the kettle and not the other
58
+ way about. The water should be actually boiling at the moment of
59
+ impact, which means that one should keep it on the flame while one
60
+ pours. Some people add that one should only use water that has been
61
+ freshly brought to the boil, but I have never noticed that it makes
62
+ any difference.
63
+
64
+ * Seventhly, after making the tea, one should stir it, or better, give
65
+ the pot a good shake, afterwards allowing the leaves to settle.
66
+
67
+ * Eighthly, one should drink out of a good breakfast cup — that is, the
68
+ cylindrical type of cup, not the flat, shallow type. The breakfast cup
69
+ holds more, and with the other kind one's tea is always half cold
70
+ before one has well started on it.
71
+
72
+ * Ninthly, one should pour the cream off the milk before using it for
73
+ tea. Milk that is too creamy always gives tea a sickly taste.
74
+
75
+ * Tenthly, one should pour tea into the cup first. This is one of the
76
+ most controversial points of all; indeed in every family in Britain
77
+ there are probably two schools of thought on the subject. The
78
+ milk-first school can bring forward some fairly strong arguments, but
79
+ I maintain that my own argument is unanswerable. This is that, by
80
+ putting the tea in first and stirring as one pours, one can exactly
81
+ regulate the amount of milk whereas one is liable to put in too much
82
+ milk if one does it the other way round.
83
+
84
+ * Lastly, tea — unless one is drinking it in the Russian style — should
85
+ be drunk without sugar. I know very well that I am in a minority here.
86
+ But still, how can you call yourself a true tealover if you destroy
87
+ the flavour of your tea by putting sugar in it? It would be equally
88
+ reasonable to put in pepper or salt. Tea is meant to be bitter, just
89
+ as beer is meant to be bitter. If you sweeten it, you are no longer
90
+ tasting the tea, you are merely tasting the sugar; you could make a
91
+ very similar drink by dissolving sugar in plain hot water.
92
+
93
+ Some people would answer that they don't like tea in itself, that they
94
+ only drink it in order to be warmed and stimulated, and they need
95
+ sugar to take the taste away. To those misguided people I would say:
96
+ Try drinking tea without sugar for, say, a fortnight and it is very
97
+ unlikely that you will ever want to ruin your tea by sweetening it
98
+ again.
99
+
100
+ These are not the only controversial points to arise in connexion with tea
101
+ drinking, but they are sufficient to show how subtilized the whole
102
+ business has become. There is also the mysterious social etiquette
103
+ surrounding the teapot (why is it considered vulgar to drink out of your
104
+ saucer, for instance?) and much might be written about the subsidiary uses
105
+ of tealeaves, such as telling fortunes, predicting the arrival of
106
+ visitors, feeding rabbits, healing burns and sweeping the carpet. It is
107
+ worth paying attention to such details as warming the pot and using water
108
+ that is really boiling, so as to make quite sure of wringing out of one's
109
+ ration the twenty good, strong cups of that two ounces, properly handled,
110
+ ought to represent.
111
+
112
+ (taken from The Collected Essays, Journalism and Letters of George Orwell,
113
+ Volume 3, 1943-45, Penguin ISBN, 0-14-00-3153-7)
@@ -0,0 +1,27 @@
1
+ require_relative 'test_helper'
2
+
3
+ require 'minitest/autorun'
4
+
5
+ class SpeedReadTest < Minitest::Unit::TestCase
6
+
7
+ def test_find_correct_orp
8
+ assert_equal 0, SpeedRead.find_ORP("")
9
+ assert_equal 0, SpeedRead.find_ORP("1")
10
+ assert_equal 1, SpeedRead.find_ORP("12")
11
+ assert_equal 1, SpeedRead.find_ORP("12345")
12
+ assert_equal 2, SpeedRead.find_ORP("123456")
13
+ assert_equal 2, SpeedRead.find_ORP("123456789")
14
+ assert_equal 3, SpeedRead.find_ORP("1234567890")
15
+ assert_equal 4, SpeedRead.find_ORP("123456789012345678")
16
+ end
17
+
18
+ def test_word_colorize
19
+ assert_equal "a\e[0;31;49mb\e[0mc", SpeedRead.colorize_word("abc", 1)
20
+ assert_equal "12\e[0;31;49m3\e[0m456789", SpeedRead.colorize_word("123456789", 2)
21
+ end
22
+
23
+ def test_word_colorize_with_invalid_input
24
+ assert_equal "", SpeedRead.colorize_word(nil, 0)
25
+ end
26
+
27
+ end
@@ -0,0 +1,7 @@
1
+ require 'bundler/setup'
2
+ require 'minitest/autorun'
3
+ require 'minitest/unit'
4
+
5
+ Dir[File.dirname(__FILE__) + '/../lib/**/*.rb'].each do |rb_file|
6
+ require rb_file
7
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: speed_read
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Thomas Arni
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.4'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: colorize
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.6'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.6'
55
+ description: A simple terminal-based open source spritz-alike. Allows you to read
56
+ at a much more rapid pace.
57
+ email:
58
+ - thomas.arni@gmail.com
59
+ executables:
60
+ - speed_read
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - ".gitignore"
65
+ - Gemfile
66
+ - History.txt
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - bin/speed_read
71
+ - lib/speed_read.rb
72
+ - lib/speed_read/version.rb
73
+ - scripts/build_install_test.sh
74
+ - speed_read.gemspec
75
+ - tea.txt
76
+ - test/speed_read_test.rb
77
+ - test/test_helper.rb
78
+ homepage: https://github.com/sunsations
79
+ licenses:
80
+ - MIT
81
+ metadata: {}
82
+ post_install_message:
83
+ rdoc_options: []
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ requirements: []
97
+ rubyforge_project:
98
+ rubygems_version: 2.2.2
99
+ signing_key:
100
+ specification_version: 4
101
+ summary: A simple terminal-based open source spritz-alike.
102
+ test_files:
103
+ - test/speed_read_test.rb
104
+ - test/test_helper.rb
105
+ has_rdoc: