Module: Dummy::Internet

Extended by:
Internet
Included in:
Internet
Defined in:
lib/dummy/internet.rb

Instance Method Summary collapse

Instance Method Details

#emailObject



7
8
9
# File 'lib/dummy/internet.rb', line 7

def email
  "#{username}@#{HOSTS.rand}"
end

#passwordObject



23
24
25
# File 'lib/dummy/internet.rb', line 23

def password
  Digest::MD5.hexdigest(Dummy::Lorem.sentence)
end

#urlObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/dummy/internet.rb', line 27

def url
  name = ""
  protocol = "http"
  
  case rand(5)
  when 0, 1 then name = Name.first_name.gsub(/\W/, "").downcase
  when 2, 3 then name = Name.last_name.gsub(/\W/, "").downcase
  when 4 then name = "#{Name.first_name.gsub(/\W/, '').downcase}.#{Name.last_name.gsub(/\W/, '').downcase}"
  end
  
  case rand(10)
  when 0 then protocol = "https"
  when 1 then protocol = "ftp"
  end
  
  "#{protocol}://#{name}.#{DOMAINS.rand}"
end

#usernameObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/dummy/internet.rb', line 11

def username
  case rand(2)
  when 0
    Name.first_name.gsub(/\W/, "").downcase
  when 1
    parts = [ Name.first_name, Name.last_name ].each {|n| n.gsub!(/\W/, "") }
    parts = parts.join %w(. _)[Kernel.rand(2)].dup
    parts.downcase!
    parts
  end
end