Permalink
Browse files

fixed german umlauts in domain names

  • Loading branch information...
1 parent 8345409 commit b6149bc1b855ce4f800d3e0e5264b2d70816719a @jeanmartin committed May 30, 2011
Showing with 14 additions and 3 deletions.
  1. +14 −3 lib/faker/internet.rb
View
@@ -12,17 +12,28 @@ def free_email(name = nil)
def user_name(name = nil)
return name.scan(/\w+/).shuffle.join(%w(. _).rand).downcase if name
- [
+ fix_umlauts([
Proc.new { Name.first_name.gsub(/\W/, '').downcase },
Proc.new {
[ Name.first_name, Name.last_name ].map {|n|
n.gsub(/\W/, '')
}.join(%w(. _).rand).downcase }
- ].rand.call
+ ].rand.call)
end
def domain_name
- [ domain_word, domain_suffix ].join('.')
+ [ fix_umlauts(domain_word), domain_suffix ].join('.')
+ end
+
+ def fix_umlauts(string)
+ string.gsub(/[äöüß]/i) do |match|
+ case match.downcase
+ when "ä" 'ae'
+ when "ö" 'oe'
+ when "ü" 'ue'
+ when "ß" 'ss'
+ end
+ end
end
def domain_word

0 comments on commit b6149bc

Please sign in to comment.