talk_like_a_pirate 0.0.5 → 0.0.6

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
  SHA1:
3
- metadata.gz: 2ba1542bb2d408ce91fddef7a6ed2e82385c1804
4
- data.tar.gz: 8195bc83e94536f2887016a7c39dad776c8f0b73
3
+ metadata.gz: 21719ae4e6616e108be5a05a12826e0271950d3f
4
+ data.tar.gz: 39a93c6e990f33b6b539703d91d5618589b2b694
5
5
  SHA512:
6
- metadata.gz: c4cc9b9256e697db5aa8854202192911701a488db780b5db59f78b703946d6fad12568f1f3c7b2c8c7bec97dde8c1e7e5d48d58b6144d8a3fa8657ec3f189247
7
- data.tar.gz: 33ea4a5c0d5457d9ff2c476b45c452488391e98bd5f069ec22d6916cc5c3f1666d1632ba58a96e7f8249016f098c59cf3fc6d586c4ee4347e3c4ea34ba3ed976
6
+ metadata.gz: 1652ede1f66dffe8f2f26a3a4f3338d321fb8e79c75ee49310362957bb6abb58fb65cc7aaa57f19466d3e08f9dc8416cc48a0bae6d1ece1d6b3cb86458833529
7
+ data.tar.gz: 2a36206aee8ad64c9b790bdf4810ad8eeae08c84bc11502a7767c249fda25d8899a44f3a18c439606161367b01d52dba1758bdbf0baef28845ee3d389fc7209f
@@ -16,13 +16,16 @@ private #####################################################################
16
16
 
17
17
  def self.translate_string(me_string)
18
18
  me_string.split(/ /).map do |word|
19
+
20
+ leading_punctuation, word, trailing_punctuation = extract_punctuation word
19
21
  capitalized = (word.slice(0,1) == word.slice(0,1).upcase)
20
22
  fully_capitalized = (word == word.upcase)
21
- word, punctuation = extract_punctuation word
23
+
22
24
  word = Object.const_defined?(:ActiveSupport) ? piratize_with_pluralization(word.downcase) : piratize(word.downcase)
25
+
23
26
  word = capitalize_first(word) if capitalized
24
27
  word = word.upcase if fully_capitalized
25
- word + punctuation
28
+ "#{leading_punctuation}#{word}#{trailing_punctuation}"
26
29
  end.join(" ")
27
30
  end
28
31
 
@@ -53,10 +56,11 @@ private #####################################################################
53
56
  end
54
57
 
55
58
  def self.extract_punctuation(word)
56
- parts = word.match(/\A([a-zA-Z\'\-]+)([^a-zA-Z\'\-]*)\Z/)
57
- word = parts[1] rescue word
58
- punctuation = parts[2] rescue ""
59
- return word, punctuation
59
+ leading_punctuation = word.match(/\A([^a-zA-Z]*)/)[1] rescue ""
60
+ trailing_punctuation = word.match(/[a-zA-Z]+([^a-zA-Z]*)\Z/)[1] rescue ""
61
+ word_length = word.length - leading_punctuation.length - trailing_punctuation.length
62
+ word = word[leading_punctuation.length, word_length]
63
+ return leading_punctuation, word, trailing_punctuation
60
64
  end
61
65
 
62
66
  def self.prepare_original_sentence(sentence)
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |s|
3
3
  s.name = 'talk_like_a_pirate'
4
- s.version = '0.0.5'
4
+ s.version = '0.0.6'
5
5
  s.authors = ['Steve Hodges']
6
6
  s.email = ['sjhodges@gmail.com']
7
7
  s.homepage = 'https://github.com/stevehodges/talk_like_a_pirate'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: talk_like_a_pirate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Hodges
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-06 00:00:00.000000000 Z
11
+ date: 2013-06-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Add a pirate translation layer to your Rails app! Talk, like a Pirate!
14
14
  email: