umlautify 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/umlautify/version.rb +1 -1
- data/lib/umlautify.rb +16 -7
- data/spec/umlautify_spec.rb +26 -3
- metadata +4 -4
data/lib/umlautify/version.rb
CHANGED
data/lib/umlautify.rb
CHANGED
@@ -1,14 +1,23 @@
|
|
1
|
-
|
1
|
+
# Encoding: utf-8
|
2
|
+
require 'umlautify/version'
|
2
3
|
|
3
4
|
module Umlautify
|
4
5
|
class ::String
|
5
6
|
def umlautify!
|
6
|
-
umlaut_map
|
7
|
-
"O" => "\u00D6", "U" => "\u00DC", "Y" => "\u0178",
|
8
|
-
"a" => "\u00E4", "e" => "\u00EB", "i" => "\u00EF",
|
9
|
-
"o" => "\u00F6", "u" => "\u00FC", "y" => "\u00FF" }
|
10
|
-
umlaut_map.each { |key, value| self.gsub!(key, value) }
|
11
|
-
self
|
7
|
+
gsub!(/[aeiouyAEIOUY]/, umlaut_map)
|
12
8
|
end
|
9
|
+
|
10
|
+
def umlautify
|
11
|
+
gsub(/[aeiouyAEIOUY]/, umlaut_map)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def umlaut_map
|
17
|
+
{ 'A' => "\u00C4", 'E' => "\u00CB", 'I' => "\u00CF",
|
18
|
+
'O' => "\u00D6", 'U' => "\u00DC", 'Y' => "\u0178",
|
19
|
+
'a' => "\u00E4", 'e' => "\u00EB", 'i' => "\u00EF",
|
20
|
+
'o' => "\u00F6", 'u' => "\u00FC", 'y' => "\u00FF" }
|
21
|
+
end
|
13
22
|
end
|
14
23
|
end
|
data/spec/umlautify_spec.rb
CHANGED
@@ -6,14 +6,37 @@ module Umlautify
|
|
6
6
|
describe ".umlautify!" do
|
7
7
|
|
8
8
|
it "should sprinkle band names with umlauts liberally" do
|
9
|
-
|
9
|
+
"Motorhead".umlautify!.should == "Mötörhëäd"
|
10
10
|
end
|
11
11
|
|
12
|
-
it "should handle all
|
13
|
-
|
12
|
+
it "should handle all vowels" do
|
13
|
+
"aeiouAEIOUyY".umlautify!.should == "äëïöüÄËÏÖÜÿŸ"
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should modify in place" do
|
17
|
+
first = "this_string"
|
18
|
+
second = first.umlautify!
|
19
|
+
second.should == "thïs_strïng" && first.should == "thïs_strïng"
|
14
20
|
end
|
15
21
|
|
16
22
|
end
|
23
|
+
|
24
|
+
describe ".umlautify" do
|
25
|
+
|
26
|
+
it "should sprinkle band names with umlauts liberally" do
|
27
|
+
"Motley Crue".umlautify.should == "Mötlëÿ Crüë"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should handle all vowels" do
|
31
|
+
"aeiouAEIOUyY".umlautify.should == "äëïöüÄËÏÖÜÿŸ"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "shouldn't mutate" do
|
35
|
+
first = "this_string"
|
36
|
+
second = first.umlautify
|
37
|
+
second.should == "thïs_strïng" && first.should == "this_string"
|
38
|
+
end
|
39
|
+
end
|
17
40
|
end
|
18
41
|
end
|
19
42
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: umlautify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -91,7 +91,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
91
91
|
version: '0'
|
92
92
|
segments:
|
93
93
|
- 0
|
94
|
-
hash:
|
94
|
+
hash: -3623908183622498923
|
95
95
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
96
|
none: false
|
97
97
|
requirements:
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
version: '0'
|
101
101
|
segments:
|
102
102
|
- 0
|
103
|
-
hash:
|
103
|
+
hash: -3623908183622498923
|
104
104
|
requirements: []
|
105
105
|
rubyforge_project:
|
106
106
|
rubygems_version: 1.8.24
|