typingtutor 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/exercises/biglebowski.txt +30 -0
- data/lib/typingtutor/line.rb +4 -2
- data/lib/typingtutor/runner.rb +13 -5
- data/lib/typingtutor/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 076b2445ce5e631d240564095aaf06e7b44f4bde
|
4
|
+
data.tar.gz: 91356f29bb94e37ba90c467a921ad07b16d78626
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4dff1bc62eb3683d27ed59822e38301e47a0fcf63e0e38e3d7e512c8879c5ab2b27c839a04bf945f7066d45e2bd5779a731633d3776ba6b30cb41f23ac615dd
|
7
|
+
data.tar.gz: aa8e90442ddf0f05d00a6d720b4f3770a17038aa79d65f2593af0e94d810f0bceb7c76de8eced9d42d6f69e85ee603cfc0780331e30bca5ca8ac81a8d33f434e
|
data/.DS_Store
ADDED
Binary file
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Way out west there was this fella. Fella I wanna tell you about.
|
2
|
+
Fella by the name of Jeff Lebowski.
|
3
|
+
At least that was the handle that his loving parents gave him.
|
4
|
+
But he never had much use for it himself.
|
5
|
+
This Lebowski, he called himself the Dude.
|
6
|
+
Now Dude, that's a name no one would self-apply where I come from.
|
7
|
+
But then there was a lot about the Dude that didn't make a whole lot of sense to me,
|
8
|
+
and a lot about where he lived likewise.
|
9
|
+
But then again, maybe that's why I found the place so darned interesting.
|
10
|
+
They call Los Angeles the City of Angels.
|
11
|
+
I didn't find it to be that, exactly.
|
12
|
+
But I'll allow there are some nice folks there.
|
13
|
+
Course, I can't say I seen London, and I never been to France,
|
14
|
+
and I ain't never seen no queen in her damned undies, as the fella says.
|
15
|
+
But I'll tell you what, after seeing Los Angeles and this here story I'm about to unfold, well,
|
16
|
+
I guess I've seen something every bit as stupefying as you can see in any of those other places, and in English, too.
|
17
|
+
So I can die with a smile on my face without feeling like the good Lord gypped me.
|
18
|
+
Now, this here story I'm about to unfold took place back in the early 90s,
|
19
|
+
just about the time of our conflict with Saddam and the Iraqis.
|
20
|
+
I only mention it 'cause sometimes there's a man... I won't say a hero.
|
21
|
+
'Cause what's a hero? But sometimes there's a man...
|
22
|
+
And I'm talking about the Dude here.
|
23
|
+
Sometimes there's a man... Well, he's the man for his time and place.
|
24
|
+
He fits right in there. And that's the Dude in Los Angeles.
|
25
|
+
And even if he is a lazy man, and the Dude was most certainly that,
|
26
|
+
quite possibly the laziest in Los Angeles county,
|
27
|
+
which would place him high in the running for laziest worldwide.
|
28
|
+
But sometimes there's a man...
|
29
|
+
Sometimes there's a man...
|
30
|
+
Well, I lost my train of thought here.
|
data/lib/typingtutor/line.rb
CHANGED
@@ -13,7 +13,9 @@ module Typingtutor
|
|
13
13
|
while(true) do
|
14
14
|
char = STDIN.getch
|
15
15
|
case char.ord
|
16
|
-
when 3
|
16
|
+
when 3 # CTRL-C
|
17
|
+
puts
|
18
|
+
exit(1)
|
17
19
|
when 13 then break # enter
|
18
20
|
when 127 # backspace
|
19
21
|
@actual.chop!
|
@@ -49,7 +51,7 @@ module Typingtutor
|
|
49
51
|
{ total_chars: @original.length,
|
50
52
|
correct_chars: @original.length.times.select {|i| @original[i] == @actual[i] }.size,
|
51
53
|
keystrokes: @keystrokes,
|
52
|
-
total_words: @
|
54
|
+
total_words: @actual.split(' ').size
|
53
55
|
}
|
54
56
|
end
|
55
57
|
|
data/lib/typingtutor/runner.rb
CHANGED
@@ -3,7 +3,7 @@ module Typingtutor
|
|
3
3
|
include HighLine::SystemExtensions
|
4
4
|
|
5
5
|
def run(exercise_name)
|
6
|
-
exercise = load_exercise(exercise_name)
|
6
|
+
exercise = load_exercise(exercise_name) unless exercise_name.nil?
|
7
7
|
if exercise
|
8
8
|
setup_color_scheme
|
9
9
|
play_intro
|
@@ -12,9 +12,14 @@ module Typingtutor
|
|
12
12
|
print_stats(stats)
|
13
13
|
else
|
14
14
|
puts "Typingtutor v#{Typingtutor::VERSION}"
|
15
|
-
puts
|
16
|
-
puts "
|
15
|
+
puts
|
16
|
+
puts "$ typingtutor <exercise>"
|
17
|
+
puts "$ typingtutor path/to/localfile.txt"
|
18
|
+
puts
|
19
|
+
puts "built in exercises:"
|
17
20
|
exercises.each {|e| puts "- #{e}"}
|
21
|
+
puts
|
22
|
+
puts "eg: typingtutor biglebowski"
|
18
23
|
end
|
19
24
|
end
|
20
25
|
|
@@ -36,10 +41,13 @@ module Typingtutor
|
|
36
41
|
end
|
37
42
|
|
38
43
|
def load_exercise(name)
|
39
|
-
|
44
|
+
gem_file_name = File.join(File.dirname(__FILE__), '..', '..', "exercises", "#{name}.txt")
|
40
45
|
|
41
46
|
# load from exercise folder in the gem
|
42
|
-
lines
|
47
|
+
lines ||= IO.read(name).lines if File.exists?(name)
|
48
|
+
lines ||= IO.read("#{name}.txt").lines if File.exists?("#{name}.txt")
|
49
|
+
lines ||= IO.read(gem_file_name).lines if File.exists?(gem_file_name)
|
50
|
+
|
43
51
|
return if lines.nil?
|
44
52
|
|
45
53
|
lines.each {|line| line.strip!} # remove extra spaces
|
data/lib/typingtutor/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: typingtutor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paolo Dona
|
@@ -46,6 +46,7 @@ executables:
|
|
46
46
|
extensions: []
|
47
47
|
extra_rdoc_files: []
|
48
48
|
files:
|
49
|
+
- ".DS_Store"
|
49
50
|
- ".gitignore"
|
50
51
|
- Gemfile
|
51
52
|
- Gemfile.lock
|
@@ -53,6 +54,7 @@ files:
|
|
53
54
|
- README.md
|
54
55
|
- Rakefile
|
55
56
|
- bin/typingtutor
|
57
|
+
- exercises/biglebowski.txt
|
56
58
|
- exercises/fox.txt
|
57
59
|
- exercises/haikurb.txt
|
58
60
|
- exercises/lorem.txt
|