mistaker 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c599e4bbea945f91c6e5b6333037e18c51323d7721b49e40e46d75bcef816a7b
4
- data.tar.gz: 53970a7bb6d7507f6204f0f425c4c2e21f3abaccca5df4978e1039b03a9047f7
3
+ metadata.gz: dc44bbcae87065146ea3df7c0852247abdd434823962f3751caa4baa3d0d0e6e
4
+ data.tar.gz: 88c561310e83bd73772b47f369ff106dd65600bd03c7d56959a087c2158fe2fb
5
5
  SHA512:
6
- metadata.gz: 027f082c6bf5efbc9440781bab619bc5d453a4104f86ce350ef6d5a5c0f3b38c3ea2229540b4f9f69bb973e2b7d3fbfb397e8da1d15da1fc7f10dc408db573e3
7
- data.tar.gz: b3f73c5379f18970d9795161e539e0d67c97d0fc56a0479812e9fd83c5111b4534dc1a41813caa5eb2b9a39a6ef2e07a35e737eab9a1a004a76cf16c0516d36a
6
+ metadata.gz: 20d4cf04a104dc08820399d474bf536e2063716280a6313ad79488be5e4588ecacc7d01cbe4b1a82eaf3117c09ee5b1662e941876c040c12e4b17a50c8ce2aa1
7
+ data.tar.gz: 56fe4af0fdfee998130d1150bfa68215f596ffedd4a40d3c4072395fbd565cacef6e04a96da88e71d0358769698824efda8606383249a5b0cc444b0f8b78ac1c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mistaker (0.1.0)
4
+ mistaker (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -21,20 +21,28 @@ Or install it yourself as:
21
21
  ## Usage
22
22
 
23
23
  ```ruby
24
-
25
- Mistaker::Name.mistake 'FALLOUT'
26
-
24
+ Mistaker::Word.mistake "GRATEFUL" #=> "GRATEFU"
25
+ Mistaker::Word.mistake "GRATEFUL" #=> "GRATAFUL"
26
+ Mistaker::Word.mistake "GRATEFUL" #=> "GRAEFUL"
27
+ Mistaker::Word.mistake "GRATEFUL" #=> "GRATEFULL"
28
+
29
+ Mistaker::Name.mistake "KIM DEAL" #=> "KIM FEAL"
30
+ Mistaker::Name.mistake "KIM DEAL" #=> "KIM DEL"
31
+ Mistaker::Name.mistake "KIM DEAL" #=> "KIM DEALL"
32
+ Mistaker::Name.mistake "KIM DEAL" #=> "KIM DEAP"
33
+
34
+ Mistaker::Date.mistake '09/04/1982' #=> "1928-09-04"
35
+ Mistaker::Date.mistake '09/04/1982' #=> "0019-82-09"
36
+ Mistaker::Date.mistake '09/04/1982' #=> "1932-09-04"
37
+
38
+ Mistaker::Number.mistake '12345' #=> "12335"
39
+ Mistaker::Number.mistake '12345' #=> "72345"
40
+ Mistaker::Number.mistake '12345' #=> "13345"
27
41
  ```
28
42
 
29
- ## Development
30
-
31
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
32
-
33
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
34
-
35
43
  ## Contributing
36
44
 
37
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/mistaker. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/mistaker/blob/master/CODE_OF_CONDUCT.md).
45
+ Bug reports and pull requests are welcome on GitHub at https://github.com/xdotcommer/mistaker. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/xdotcommer/mistaker/blob/master/CODE_OF_CONDUCT.md).
38
46
 
39
47
 
40
48
  ## License
@@ -43,4 +51,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
43
51
 
44
52
  ## Code of Conduct
45
53
 
46
- Everyone interacting in the Mistaker project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/mistaker/blob/master/CODE_OF_CONDUCT.md).
54
+ Everyone interacting in the Mistaker project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/xdotcommer/mistaker/blob/master/CODE_OF_CONDUCT.md).
data/lib/mistaker.rb CHANGED
@@ -2,6 +2,7 @@ require "mistaker/version"
2
2
  require "mistaker/base"
3
3
  require "mistaker/date"
4
4
  require "mistaker/number"
5
+ require "mistaker/word"
5
6
  require "mistaker/name"
6
7
 
7
8
  module Mistaker
@@ -9,12 +10,12 @@ module Mistaker
9
10
 
10
11
  NUMBER_MAX = 5
11
12
  DATE_MAX = 8
12
- NAME_MAX = 7
13
+ NAME_MAX = 6
13
14
 
14
15
  ONE_DIGIT_UP, ONE_DIGIT_DOWN, NUMERIC_KEY_PAD, DIGIT_SHIFT, MISREAD, KEY_SWAP = (0..NUMBER_MAX).to_a
15
16
  MONTH_DAY_SWAP, ONE_DECADE_DOWN, Y2K = ((NUMBER_MAX + 1)..DATE_MAX).to_a
16
17
 
17
- DROPPED_LETTER, DOUBLE_LETTER, MISREAD_LETTER, MISTYPED_LETTER, EXTRA_LETTER, VOWEL_REPLACEMENT, CONSONANT_REPLACEMENT = (0..NAME_MAX).to_a
18
+ DROPPED_LETTER, DOUBLE_LETTER, MISREAD_LETTER, MISTYPED_LETTER, EXTRA_LETTER, MISHEARD_LETTER = (0..NAME_MAX).to_a
18
19
 
19
20
  MISREAD_NUMBERS = {
20
21
  '0' => '8',
data/lib/mistaker/name.rb CHANGED
@@ -1,31 +1,4 @@
1
1
  module Mistaker
2
- class Name < Base
3
- def reformat(str)
4
- str.to_s.tr('^A-z ', '').upcase
5
- end
6
-
7
- def mistake(err_type = rand.rand(NAME_MAX), index = nil)
8
- @str = reformat(@str)
9
- @length = @str.length
10
-
11
- index ||= rand.rand(@length)
12
-
13
- case err_type
14
- when DROPPED_LETTER
15
- @str.slice! index
16
- when DOUBLE_LETTER
17
- @str.insert(index, @str[index])
18
- when MISREAD_LETTER
19
- @str[index] = MISREAD_LETTERS[@str[index]]
20
- when MISTYPED_LETTER
21
- @str[index] = MISTYPED_LETTERS[@str[index]]
22
- when EXTRA_LETTER
23
- @str << EXTRA_LETTERS[@str[@length - 1]]
24
- when MISHEARD_LETTERS
25
- @str = "#{ @str.slice(0...index) }#{ MISHEARD_LETTERS[@str[index]] }#{ @str.slice((index+1)..@length) }"
26
- end
27
-
28
- @str
29
- end
2
+ class Name < Word
30
3
  end
31
4
  end
@@ -1,3 +1,3 @@
1
1
  module Mistaker
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -0,0 +1,31 @@
1
+ module Mistaker
2
+ class Word < Base
3
+ def reformat(str)
4
+ str.to_s.tr('^A-z ', '').upcase
5
+ end
6
+
7
+ def mistake(err_type = rand.rand(NAME_MAX), index = nil)
8
+ @str = reformat(@str)
9
+ @length = @str.length
10
+
11
+ index ||= rand.rand(@length)
12
+
13
+ case err_type
14
+ when DROPPED_LETTER
15
+ @str.slice! index
16
+ when DOUBLE_LETTER
17
+ @str.insert(index, @str[index])
18
+ when MISREAD_LETTER
19
+ @str[index] = MISREAD_LETTERS[@str[index]]
20
+ when MISTYPED_LETTER
21
+ @str[index] = MISTYPED_LETTERS[@str[index]]
22
+ when EXTRA_LETTER
23
+ @str << EXTRA_LETTERS[@str[@length - 1]]
24
+ when MISHEARD_LETTER
25
+ @str = "#{ @str.slice(0...index) }#{ MISHEARD_LETTERS[@str[index]] }#{ @str.slice((index+1)..@length) }"
26
+ end
27
+
28
+ @str
29
+ end
30
+ end
31
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mistaker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Cowden
@@ -34,6 +34,7 @@ files:
34
34
  - lib/mistaker/name.rb
35
35
  - lib/mistaker/number.rb
36
36
  - lib/mistaker/version.rb
37
+ - lib/mistaker/word.rb
37
38
  - mistaker.gemspec
38
39
  homepage:
39
40
  licenses: