readspeed 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +35 -0
- data/LICENSE.txt +21 -0
- data/README.md +26 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/readspeed +16 -0
- data/bin/setup +8 -0
- data/docs/readspeed-usage.gif +0 -0
- data/lib/readspeed.rb +5 -0
- data/lib/readspeed/tracker.rb +124 -0
- data/lib/readspeed/version.rb +3 -0
- data/readspeed.gemspec +27 -0
- metadata +103 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0f95daf752da04495606d7d4c02ea4369e676141a81f3e0a7f98354d7038bae0
|
4
|
+
data.tar.gz: 0c4850987a58001fb0bde547c8f71e4d99d0292101cb070b10e3154d9bd1a8be
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9d07400d78a798376686afa1a7a1b0307d0b4d810df7eac68b3b59916841fc17437570772e8810c39877003da782c50b2dbf20e8ecf344d64585ad19f77158cf
|
7
|
+
data.tar.gz: c7d9c66bcee8298366efa45ef2112ea0ce83a5b3f85b5908429021115f7d95fcca9424104b836d5e3e1e4c263caff6f515e660d7a44eae97f77a74aaebda1ecd
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
readspeed (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.3)
|
10
|
+
rake (10.5.0)
|
11
|
+
rspec (3.7.0)
|
12
|
+
rspec-core (~> 3.7.0)
|
13
|
+
rspec-expectations (~> 3.7.0)
|
14
|
+
rspec-mocks (~> 3.7.0)
|
15
|
+
rspec-core (3.7.1)
|
16
|
+
rspec-support (~> 3.7.0)
|
17
|
+
rspec-expectations (3.7.0)
|
18
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
+
rspec-support (~> 3.7.0)
|
20
|
+
rspec-mocks (3.7.0)
|
21
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
+
rspec-support (~> 3.7.0)
|
23
|
+
rspec-support (3.7.1)
|
24
|
+
|
25
|
+
PLATFORMS
|
26
|
+
ruby
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
bundler (~> 1.16)
|
30
|
+
rake (~> 10.0)
|
31
|
+
readspeed!
|
32
|
+
rspec (~> 3.0)
|
33
|
+
|
34
|
+
BUNDLED WITH
|
35
|
+
1.16.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Madis Nõmme
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Readspeed
|
2
|
+
|
3
|
+
Cli tool that records your reading speed and provides summary.
|
4
|
+
|
5
|
+
![Example usage](docs/readspeed-usage.gif)
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
1. Install with: `gem install readspeed`
|
10
|
+
2. Then run `readspeed`
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
After starting readspeed will start recording your page reading speed.
|
15
|
+
When you finish reading page, press [ENTER] and timing of next page begins.
|
16
|
+
Couple other commands are available as well. They can be seen during the app run by entering `help` or `h`.
|
17
|
+
|
18
|
+
When you exit the application with `quit` or `q`, it will record your reading session into `yaml` file in the directory that you ran the `readspeed` command from.
|
19
|
+
|
20
|
+
## Contributing
|
21
|
+
|
22
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/readspeed.
|
23
|
+
|
24
|
+
## License
|
25
|
+
|
26
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "readspeed"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/readspeed
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$LOAD_PATH << './lib'
|
4
|
+
require 'readspeed'
|
5
|
+
|
6
|
+
if ARGV.length == 1
|
7
|
+
file_name = title = ARGV.first
|
8
|
+
else
|
9
|
+
print "What are you reading?"
|
10
|
+
title = gets.chomp
|
11
|
+
file_name = nil
|
12
|
+
end
|
13
|
+
|
14
|
+
tracker = Readspeed::Tracker.new(title)
|
15
|
+
tracker.file_name = file_name
|
16
|
+
tracker.start
|
data/bin/setup
ADDED
Binary file
|
data/lib/readspeed.rb
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Readspeed
|
4
|
+
class Tracker
|
5
|
+
attr_accessor :file_name
|
6
|
+
|
7
|
+
def initialize(title)
|
8
|
+
@pages = 0
|
9
|
+
@times = []
|
10
|
+
@title = title
|
11
|
+
@input = nil
|
12
|
+
end
|
13
|
+
|
14
|
+
def start
|
15
|
+
puts "#{help_info}\n Starting recording. Press [ENTER] when you finish reading page."
|
16
|
+
while true do
|
17
|
+
start_time = Time.now
|
18
|
+
case read_command
|
19
|
+
when :quit
|
20
|
+
write_summary_to_file
|
21
|
+
break
|
22
|
+
when :pause
|
23
|
+
@paused = true
|
24
|
+
when :resume
|
25
|
+
@paused = false
|
26
|
+
when :help
|
27
|
+
print_help
|
28
|
+
else
|
29
|
+
record_next_page(start_time, Time.now)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
COMMANDS = {
|
37
|
+
quit: %w(q quit),
|
38
|
+
pause: %w(p pause),
|
39
|
+
resume: %w(r resume),
|
40
|
+
help: %w(h help)
|
41
|
+
}
|
42
|
+
|
43
|
+
def expanded_commands
|
44
|
+
COMMANDS.reduce({}) do |sum, (command, inputs)|
|
45
|
+
inputs.each { |i| sum[i] = command }
|
46
|
+
sum
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def read_command
|
51
|
+
status = @paused ? "(paused)" : "#{@pages}"
|
52
|
+
print "#{status}> "
|
53
|
+
input = STDIN.gets.chomp
|
54
|
+
if @paused && input == ''
|
55
|
+
@paused = false
|
56
|
+
selected_command = :resume
|
57
|
+
else
|
58
|
+
selected_command = expanded_commands[input]
|
59
|
+
end
|
60
|
+
selected_command
|
61
|
+
end
|
62
|
+
|
63
|
+
def record_next_page(start_time, end_time)
|
64
|
+
@pages += 1
|
65
|
+
@times << end_time - start_time
|
66
|
+
puts summary
|
67
|
+
end
|
68
|
+
|
69
|
+
def help_info
|
70
|
+
<<~EOS
|
71
|
+
Press [ENTER] without typing anything to start next page or one of the
|
72
|
+
following commands:
|
73
|
+
|
74
|
+
q, quit - quit the application, write summary to file
|
75
|
+
p, pause - record current page, pause
|
76
|
+
r, resume - resume from pause
|
77
|
+
h, help - show help (this)
|
78
|
+
EOS
|
79
|
+
end
|
80
|
+
|
81
|
+
def write_summary_to_file
|
82
|
+
puts "Writing summary to #{file_name}"
|
83
|
+
if File.exist?(file_name)
|
84
|
+
reading_summary = YAML.load(File.read(file_name))
|
85
|
+
else
|
86
|
+
reading_summary = {
|
87
|
+
title: @title,
|
88
|
+
started_at: Time.now,
|
89
|
+
readings: []
|
90
|
+
}
|
91
|
+
end
|
92
|
+
|
93
|
+
reading = {
|
94
|
+
session_finished_at: Time.now,
|
95
|
+
pages: @pages,
|
96
|
+
times: @times,
|
97
|
+
summary: summary
|
98
|
+
}
|
99
|
+
|
100
|
+
reading_summary[:readings] << reading
|
101
|
+
File.open(file_name, 'w') { |f| f.write(reading_summary.to_yaml) }
|
102
|
+
end
|
103
|
+
|
104
|
+
def summary
|
105
|
+
"Finished page #{@pages}. Last: #{last} Average: #{average} Total: #{total}"
|
106
|
+
end
|
107
|
+
|
108
|
+
def last
|
109
|
+
@times.last.round(1)
|
110
|
+
end
|
111
|
+
|
112
|
+
def average
|
113
|
+
(total / @pages).round(1)
|
114
|
+
end
|
115
|
+
|
116
|
+
def total
|
117
|
+
@times.reduce(&:+).round(1)
|
118
|
+
end
|
119
|
+
|
120
|
+
def file_name
|
121
|
+
@file_name || @title.gsub(/( )/, '_').downcase + ".yaml"
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
data/readspeed.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "readspeed/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "readspeed"
|
8
|
+
spec.version = Readspeed::VERSION
|
9
|
+
spec.authors = ["Madis Nõmme"]
|
10
|
+
spec.email = ["me@mad.is"]
|
11
|
+
|
12
|
+
spec.summary = %q{Records your reading speed and provides summary}
|
13
|
+
spec.description = %q{Small cli to track your reading speed to push yourself read more and faster}
|
14
|
+
spec.homepage = "https://github.com/madis/readspeed"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: readspeed
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Madis Nõmme
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-04-26 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.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Small cli to track your reading speed to push yourself read more and
|
56
|
+
faster
|
57
|
+
email:
|
58
|
+
- me@mad.is
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".rspec"
|
65
|
+
- ".travis.yml"
|
66
|
+
- Gemfile
|
67
|
+
- Gemfile.lock
|
68
|
+
- LICENSE.txt
|
69
|
+
- README.md
|
70
|
+
- Rakefile
|
71
|
+
- bin/console
|
72
|
+
- bin/readspeed
|
73
|
+
- bin/setup
|
74
|
+
- docs/readspeed-usage.gif
|
75
|
+
- lib/readspeed.rb
|
76
|
+
- lib/readspeed/tracker.rb
|
77
|
+
- lib/readspeed/version.rb
|
78
|
+
- readspeed.gemspec
|
79
|
+
homepage: https://github.com/madis/readspeed
|
80
|
+
licenses:
|
81
|
+
- MIT
|
82
|
+
metadata: {}
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
requirements: []
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 2.7.3
|
100
|
+
signing_key:
|
101
|
+
specification_version: 4
|
102
|
+
summary: Records your reading speed and provides summary
|
103
|
+
test_files: []
|