blundersaur 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Jeremy Stephens
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,16 @@
1
+ = blundersaur
2
+
3
+ Blundersaur is a library of Ruby methods to simulate data entry mistakes.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
12
+ * Send me a pull request. Bonus points for topic branches.
13
+
14
+ == Copyright
15
+
16
+ Copyright (c) 2010 Jeremy Stephens. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,52 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "blundersaur"
8
+ gem.summary = %Q{A library of Ruby methods to simulate data entry mistakes}
9
+ gem.description = %Q{A library of Ruby methods to simulate data entry mistakes}
10
+ gem.email = "viking415@gmail.com"
11
+ gem.homepage = "http://github.com/viking/blundersaur"
12
+ gem.authors = ["Jeremy Stephens"]
13
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
14
+ end
15
+ Jeweler::GemcutterTasks.new
16
+ rescue LoadError
17
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
18
+ end
19
+
20
+ require 'rake/testtask'
21
+ Rake::TestTask.new(:test) do |test|
22
+ test.libs << 'lib' << 'test'
23
+ test.pattern = 'test/**/test_*.rb'
24
+ test.verbose = true
25
+ end
26
+
27
+ begin
28
+ require 'rcov/rcovtask'
29
+ Rcov::RcovTask.new do |test|
30
+ test.libs << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+ rescue LoadError
35
+ task :rcov do
36
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
37
+ end
38
+ end
39
+
40
+ task :test => :check_dependencies
41
+
42
+ task :default => :test
43
+
44
+ require 'rake/rdoctask'
45
+ Rake::RDocTask.new do |rdoc|
46
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
47
+
48
+ rdoc.rdoc_dir = 'rdoc'
49
+ rdoc.title = "blundersaur #{version}"
50
+ rdoc.rdoc_files.include('README*')
51
+ rdoc.rdoc_files.include('lib/**/*.rb')
52
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.0
@@ -0,0 +1,62 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{blundersaur}
8
+ s.version = "0.0.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Jeremy Stephens"]
12
+ s.date = %q{2010-02-03}
13
+ s.description = %q{A library of Ruby methods to simulate data entry mistakes}
14
+ s.email = %q{viking415@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "blundersaur.gemspec",
27
+ "lib/blundersaur.rb",
28
+ "lib/blundersaur/extensions.rb",
29
+ "lib/blundersaur/extensions/string.rb",
30
+ "lib/blundersaur/keyboards.rb",
31
+ "lib/blundersaur/keyboards/qwerty.rb",
32
+ "test.watchr",
33
+ "test/blundersaur/extensions/test_string.rb",
34
+ "test/blundersaur/keyboards/test_qwerty.rb",
35
+ "test/blundersaur/test_extensions.rb",
36
+ "test/helper.rb",
37
+ "test/test_blundersaur.rb"
38
+ ]
39
+ s.homepage = %q{http://github.com/viking/blundersaur}
40
+ s.rdoc_options = ["--charset=UTF-8"]
41
+ s.require_paths = ["lib"]
42
+ s.rubygems_version = %q{1.3.5}
43
+ s.summary = %q{A library of Ruby methods to simulate data entry mistakes}
44
+ s.test_files = [
45
+ "test/blundersaur/test_extensions.rb",
46
+ "test/blundersaur/extensions/test_string.rb",
47
+ "test/blundersaur/keyboards/test_qwerty.rb",
48
+ "test/helper.rb",
49
+ "test/test_blundersaur.rb"
50
+ ]
51
+
52
+ if s.respond_to? :specification_version then
53
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
54
+ s.specification_version = 3
55
+
56
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
57
+ else
58
+ end
59
+ else
60
+ end
61
+ end
62
+
@@ -0,0 +1,5 @@
1
+ module Blundersaur
2
+ end
3
+
4
+ require File.join(File.dirname(__FILE__), "blundersaur", "keyboards")
5
+ require File.join(File.dirname(__FILE__), "blundersaur", "extensions")
@@ -0,0 +1,6 @@
1
+ module Blundersaur
2
+ module Extensions
3
+ end
4
+ end
5
+
6
+ require File.join(File.dirname(__FILE__), "extensions", "string")
@@ -0,0 +1,43 @@
1
+ module Blundersaur
2
+ module Extensions
3
+ module String
4
+ def fat_finger!
5
+ i = rand(self.length)
6
+ chars = Keyboards::Qwerty.keys_near(self[i])
7
+ char = chars[rand(chars.length)]
8
+ self[i..i] = (rand(2) == 1 ? [self[i], char] : [char, self[i]]).pack("cc")
9
+ self
10
+ end
11
+
12
+ def fat_finger
13
+ self.dup.fat_finger!
14
+ end
15
+
16
+ def stutter!
17
+ i = rand(self.length)
18
+ self[i..i] = self[i..i] * 2
19
+ self
20
+ end
21
+
22
+ def stutter
23
+ self.dup.stutter!
24
+ end
25
+
26
+ def mistype!
27
+ i = rand(self.length)
28
+ chars = Keyboards::Qwerty.keys_near(self[i])
29
+ char = chars[rand(chars.length)]
30
+ self[i] = char
31
+ self
32
+ end
33
+
34
+ def mistype
35
+ self.dup.mistype!
36
+ end
37
+ end
38
+ end
39
+ end
40
+
41
+ String.class_eval do
42
+ include Blundersaur::Extensions::String
43
+ end
@@ -0,0 +1,6 @@
1
+ module Blundersaur
2
+ module Keyboards
3
+ end
4
+ end
5
+
6
+ require File.join(File.dirname(__FILE__), "keyboards", "qwerty")
@@ -0,0 +1,15 @@
1
+ module Blundersaur
2
+ module Keyboards
3
+ module Qwerty
4
+ ROWS = [
5
+ nil, ?q, ?w, ?e, ?r, ?t, ?y, ?u, ?i, ?o, ?p, nil,
6
+ nil, ?a, ?s, ?d, ?f, ?g, ?h, ?j, ?k, ?l, nil,
7
+ nil, ?z, ?x, ?c, ?v, ?b, ?n, ?m, nil
8
+ ]
9
+ def self.keys_near(char)
10
+ i = ROWS.index(char)
11
+ ROWS.values_at(i-1, i+1).compact
12
+ end
13
+ end
14
+ end
15
+ end
data/test.watchr ADDED
@@ -0,0 +1,4 @@
1
+ require 'autowatchr'
2
+
3
+ Autowatchr.new(self) do |config|
4
+ end
@@ -0,0 +1,29 @@
1
+ require File.join(File.dirname(__FILE__), "..", "..", "helper")
2
+
3
+ module Blundersaur
4
+ module Extensions
5
+ class TestString < Test::Unit::TestCase
6
+ def test_included
7
+ assert ::String.included_modules.include?(Extensions::String)
8
+ end
9
+
10
+ def test_fat_finger
11
+ result = "hello".fat_finger
12
+ assert_not_equal result, "hello"
13
+ assert_match /^[gj]?h[gj]?[wr]?e[wr]?k?lk?k?lk?[ip]?o[ip]?$/, result
14
+ end
15
+
16
+ def test_stutter
17
+ result = "hello".stutter
18
+ assert_not_equal result, "hello"
19
+ assert_match /^h{1,2}e{1,2}l{1,2}l{1,2}o{1,2}$/, result
20
+ end
21
+
22
+ def test_mistype
23
+ result = "hello".mistype
24
+ assert_not_equal result, "hello"
25
+ assert_match /^[gjh][wre][kl][kl][ipo]$/, result
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,41 @@
1
+ require File.join(File.dirname(__FILE__), "..", "..", "helper")
2
+
3
+ module Blundersaur
4
+ module Keyboards
5
+ class TestQwerty < Test::Unit::TestCase
6
+ def test_keys_near
7
+ expected = {
8
+ ?q => [?w],
9
+ ?w => [?q, ?e],
10
+ ?e => [?w, ?r],
11
+ ?r => [?e, ?t],
12
+ ?t => [?r, ?y],
13
+ ?y => [?t, ?u],
14
+ ?u => [?y, ?i],
15
+ ?i => [?u, ?o],
16
+ ?o => [?i, ?p],
17
+ ?p => [?o],
18
+ ?a => [?s],
19
+ ?s => [?a, ?d],
20
+ ?d => [?s, ?f],
21
+ ?f => [?d, ?g],
22
+ ?g => [?f, ?h],
23
+ ?h => [?g, ?j],
24
+ ?j => [?h, ?k],
25
+ ?k => [?j, ?l],
26
+ ?l => [?k],
27
+ ?z => [?x],
28
+ ?x => [?z, ?c],
29
+ ?c => [?x, ?v],
30
+ ?v => [?c, ?b],
31
+ ?b => [?v, ?n],
32
+ ?n => [?b, ?m],
33
+ ?m => [?n]
34
+ }
35
+ expected.each_pair do |char, set|
36
+ assert_equal set, Qwerty.keys_near(char)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,9 @@
1
+ require File.join(File.dirname(__FILE__), "..", "helper")
2
+
3
+ module Blundersaur
4
+ class TestExtensions < Test::Unit::TestCase
5
+ def test_truth
6
+ assert true
7
+ end
8
+ end
9
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,8 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
+ require 'blundersaur'
6
+
7
+ class Test::Unit::TestCase
8
+ end
@@ -0,0 +1,7 @@
1
+ require File.join(File.dirname(__FILE__), "helper")
2
+
3
+ class TestBlundersaur < Test::Unit::TestCase
4
+ def test_truth
5
+ assert true
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: blundersaur
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jeremy Stephens
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-02-03 00:00:00 -06:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: A library of Ruby methods to simulate data entry mistakes
17
+ email: viking415@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - LICENSE
24
+ - README.rdoc
25
+ files:
26
+ - .document
27
+ - .gitignore
28
+ - LICENSE
29
+ - README.rdoc
30
+ - Rakefile
31
+ - VERSION
32
+ - blundersaur.gemspec
33
+ - lib/blundersaur.rb
34
+ - lib/blundersaur/extensions.rb
35
+ - lib/blundersaur/extensions/string.rb
36
+ - lib/blundersaur/keyboards.rb
37
+ - lib/blundersaur/keyboards/qwerty.rb
38
+ - test.watchr
39
+ - test/blundersaur/extensions/test_string.rb
40
+ - test/blundersaur/keyboards/test_qwerty.rb
41
+ - test/blundersaur/test_extensions.rb
42
+ - test/helper.rb
43
+ - test/test_blundersaur.rb
44
+ has_rdoc: true
45
+ homepage: http://github.com/viking/blundersaur
46
+ licenses: []
47
+
48
+ post_install_message:
49
+ rdoc_options:
50
+ - --charset=UTF-8
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: "0"
58
+ version:
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: "0"
64
+ version:
65
+ requirements: []
66
+
67
+ rubyforge_project:
68
+ rubygems_version: 1.3.5
69
+ signing_key:
70
+ specification_version: 3
71
+ summary: A library of Ruby methods to simulate data entry mistakes
72
+ test_files:
73
+ - test/blundersaur/test_extensions.rb
74
+ - test/blundersaur/extensions/test_string.rb
75
+ - test/blundersaur/keyboards/test_qwerty.rb
76
+ - test/helper.rb
77
+ - test/test_blundersaur.rb