gibber 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 353e2679a904621390600a086baae467bc0f8663
4
- data.tar.gz: f52b571b90afa94507fff63c08927546623060f7
3
+ metadata.gz: 0847b7e884e31eb1e706bf2bb51fa6fd0bb77500
4
+ data.tar.gz: 187bc73dff3098aeb1177578836741b566f050e0
5
5
  SHA512:
6
- metadata.gz: 0c363fe6eece656de6e6f8f38439e4a73603171cacf49e1f25cc47117fec16bddae83d31806ee9cadb9d35084facd114d61c51f9a90bcfcb94447c558b1fa947
7
- data.tar.gz: 12cf7b78d43de7bccafc2cba2a02fab24811f5f42fab77ee82db963eeacbd9f83c2ba6d438a54454f55d16f42308ee0df74a1a8ade97c9cdf7b36b318676a9d7
6
+ metadata.gz: 16207dca51a54af5defe47877adf6f5d8334761ceee17ae94482973ed538bf55cd83a3051a6dada89c7ddfc870b43fddfd66640bf83a9b9f35b9718bf37537cc
7
+ data.tar.gz: efac5556d8aecdb7c78d5433e43155a29be823ccc7ba954466aa83c8887f13aa8f5d802299534ceda6a2c012ae5fb08befcaa24387042d39b395c318d35908ac
@@ -1,3 +1,3 @@
1
1
  class Gibber
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/gibber.rb CHANGED
@@ -14,14 +14,14 @@ class Gibber
14
14
  private
15
15
 
16
16
  # recursive if missing translation
17
- def replace_word(word)
17
+ def replace_word(word, tries_left=100)
18
18
  return word if blank?(word) || numeric?(word) || !wordy?(word)
19
19
 
20
20
  possible_keys = keys_within_margin_for_word(word)
21
21
  if translation = translation_at_keys(*possible_keys)
22
22
  conditional_capitalize(word, translation)
23
23
  else
24
- replace_word(word[0..-2])
24
+ tries_left == 0 ? ['I','V','X'].sample : replace_word(word[0..-2], tries_left - 1)
25
25
  end
26
26
  end
27
27
 
data/test/tests.rb CHANGED
@@ -100,6 +100,6 @@ class TestGibber < MiniTest::Test
100
100
 
101
101
  gibber = Gibber.new
102
102
  result = text.gsub(/[.?!]/, '\0|').split('|').map { |sentence| gibber.replace(sentence) }.join("")
103
- puts result
103
+ # no error
104
104
  end
105
105
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gibber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timon Vonk