prudding 0.0.0 → 0.0.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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/prudding.rb +23 -11
  3. metadata +2 -3
  4. data/lib/string.rb +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7524bbf11a5ebf4b41c96b04c27ce1f9bd4d2b9e34a192787b7feb0b906f895d
4
- data.tar.gz: ca53abfa610de9696527b1256005a9a36a35cbbe404925b451f2a2beba1c0945
3
+ metadata.gz: bb9bff88c46b46c2efe1455348fa3e7ad9ae913ce2614fa1b9a3545adfab7978
4
+ data.tar.gz: 7e5b5fab580d177ac6b70b6651e68a4a916fc0e4081e310c2690183dbc807016
5
5
  SHA512:
6
- metadata.gz: eb298331c2b3df08cac383b2dc510300b388fca66eeba5dd4a7e3256bc91b80474d9a316be48deba5a098f0e80c62899dea33ae12ff61b4396b27228653ce843
7
- data.tar.gz: 1835d2588be5bcbf093347e380d6094cfde76b248984a46179f19f831fc28c8e323b92f04629212c4166a19d8295c6315fa31e6397f9dd41e2c2fa063bb19c07
6
+ metadata.gz: 94d2166c2a64be9b0427fce9eb3f1c0670a06c1ecd0eee6305cbc65e2f3f53d055957b59f70dad6c5b9c32129d71f401ed28c1a3ddfbf4b2e6ba0ad7088c9963
7
+ data.tar.gz: ab27bbefc14482b38b79dea3eede3cc559ee57b230a3cbeb8f2a927a7518b771512867ebb802364b272249a3d901890f967e462f9829dbe9f782f0cd3b767bf4
data/lib/prudding.rb CHANGED
@@ -4,17 +4,29 @@ class Prudding
4
4
  end
5
5
 
6
6
  def to_prudding
7
- @words.map do |w|
8
- if (idx = w.chars.index { |c| c =~ /[aeiou]/ }) && w.length > 3
9
- if idx > 0
10
- w.chars.insert(idx, "r").join('')
11
- else
12
- w
13
- end
14
- else
15
- w
16
- end
17
- end.join(" ")
7
+ @words.map { |word| process(word) }.join(" ")
8
+ end
9
+
10
+ private
11
+
12
+ PLE_WORD = /^(p)(le)(.*)(\.?)/i
13
+ BEN_WORD = /^([bcdfgkptw])([aeiou])(.*)/i
14
+ ING_WORD = /(.*)(ing)(.*)$/i
15
+
16
+ def process(word)
17
+ return word
18
+
19
+ if (match = word.match(PLE_WORD))
20
+ captures = match.captures.clone
21
+ captures[1] = 're'
22
+ captures.join('')
23
+ elsif (match = word.match(BEN_WORD))
24
+ match.captures.insert(1, 'r').join('')
25
+ elsif (match = word.match(ING_WORD))
26
+ match.captures.insert(1, 'r').join('')
27
+ else
28
+ word
29
+ end
18
30
  end
19
31
  end
20
32
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prudding
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Starling
@@ -17,8 +17,7 @@ extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
19
  - lib/prudding.rb
20
- - lib/string.rb
21
- homepage: http://rubygems.org/gems/prudding
20
+ homepage: https://github.com/samstarling/prudding
22
21
  licenses:
23
22
  - MIT
24
23
  metadata: {}
data/lib/string.rb DELETED
@@ -1,6 +0,0 @@
1
- class String
2
- def prudding
3
- prud = Prudding.new(self)
4
- prud.to_prudding
5
- end
6
- end