geek_typist 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/bin/geek_typist CHANGED
@@ -3,6 +3,7 @@ require 'optparse'
3
3
  require "highline/system_extensions"
4
4
  include HighLine::SystemExtensions
5
5
  require 'io/console'
6
+ require 'geek_typist/version'
6
7
 
7
8
  options = {}
8
9
  OptionParser.new do |opts|
@@ -13,11 +14,11 @@ opts.on("-v", "--version", "Version") do |v|
13
14
  end
14
15
 
15
16
  opts.on("-t text", "--text text", "launch the system with the given text ") do |v|
16
- options[:use_text] = v
17
+ options[:use_text] = v
17
18
  end
18
19
 
19
20
  opts.on("-n NUM", "--n-times NUM", "repeat the text NUM times") do |v|
20
- options[:repeat] = v
21
+ options[:repeat] = v
21
22
  end
22
23
 
23
24
  opts.on("-r", "--randomize", "Randomize the content for more fun!") do |v|
@@ -26,10 +27,15 @@ end
26
27
 
27
28
  end.parse!
28
29
 
30
+ if options[:version] == 1
31
+ puts GeekTypist::VERSION
32
+ exit
33
+ end
34
+
29
35
  if options[:use_text]
30
36
  str_test = options[:use_text]
31
37
  else
32
- str_test = "{13-_87}"
38
+ str_test = "{13-_87}" # default text to be used
33
39
  end
34
40
 
35
41
  if options[:repeat]
@@ -44,7 +50,7 @@ if options[:randomize]
44
50
  end
45
51
 
46
52
  def compare_char(c, s)
47
- if Config::CONFIG["ruby_version"] =~ /^1\.9/
53
+ if RbConfig::CONFIG["ruby_version"] =~ /^1\.9/
48
54
  # "version ruby 1.9"
49
55
  return c.chr != s
50
56
  else
@@ -54,15 +60,17 @@ def compare_char(c, s)
54
60
  end
55
61
 
56
62
  failures = 0
57
- chain.each do |s|
63
+ chain.each do |s|
58
64
 
59
65
  c = 0
60
- while (compare_char(c,s[0])) do
61
- puts s
66
+ while (compare_char(c,s[0])) do
67
+ puts s
62
68
  c = STDIN.getch
69
+ exit if c == "\u0003"
70
+ exit if c == "\u0004"
63
71
  puts c.chr
64
- if (compare_char(c,s[0]))
65
- puts "not good yet"
72
+ if (compare_char(c,s[0]))
73
+ puts "not good yet"
66
74
  failures += 1
67
75
  end
68
76
  end
@@ -1,3 +1,3 @@
1
1
  module GeekTypist
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geek_typist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-09 00:00:00.000000000 Z
12
+ date: 2013-08-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -75,7 +75,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
75
75
  version: '0'
76
76
  segments:
77
77
  - 0
78
- hash: -1822921689007043311
78
+ hash: -1809338756958828167
79
79
  required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  none: false
81
81
  requirements:
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  version: '0'
85
85
  segments:
86
86
  - 0
87
- hash: -1822921689007043311
87
+ hash: -1809338756958828167
88
88
  requirements: []
89
89
  rubyforge_project:
90
90
  rubygems_version: 1.8.25