Class: GenFormData

Inherits:
Object
  • Object
show all
Includes:
Faker
Defined in:
lib/SykGenData/generators/gen_form_data.rb

Instance Method Summary collapse

Instance Method Details

#get_about_meObject



98
99
100
101
# File 'lib/SykGenData/generators/gen_form_data.rb', line 98

def get_about_me
  quotes = [BackToTheFuture.quote, Friends.quote, HarryPotter.quote, GameOfThrones.quote, Lovecraft.fhtagn(3), Lovecraft.paragraph, RickAndMorty.quote, Seinfeld.quote, Simpsons.quote, StarWars.quote, StarWars.wookiee_sentence, TheFreshPrinceOfBelAir.quote, HitchhikersGuideToTheGalaxy.marvin_quote]
  quotes.sample
end

#get_countryObject



6
7
8
9
10
# File 'lib/SykGenData/generators/gen_form_data.rb', line 6

def get_country
  countries = ["Afghanistan","Albania","Algeria","American Samoa","Andorra","Angola","Antigua and Barbuda","Argentina","Armenia","Australia","Austria","Azerbaijan","Bahamas","Bahrain","Bangladesh","Barbados","Belarus","Belgium","Belize","Benin","Bermuda","Bhutan","Bolivia","Bosnia and Herzegovina","Botswana","Brazil","Brunei","Bulgaria","Burkina Faso","Burundi","Cambodia","Cameroon","Canada","Cape Verde","Central African Republic","Chad","Chile","China","Colombia","Comoros","Congo","Costa Rica","Côte d'Ivoire","Croatia","Cuba","Cyprus","Czech Republic","Denmark","Djibouti","Dominica","Dominican Republic","East Timor","Ecuador","Egypt","El Salvador","Equatorial Guinea","Eritrea","Estonia","Ethiopia","Fiji","Finland","France","Gabon","Gambia","Georgia","Germany","Ghana","Greece","Greenland","Grenada","Guam","Guatemala","Guinea","Guinea-Bissau","Guyana","Haiti","Honduras","Hong Kong","Hungary","Iceland","India","Indonesia","Iran","Iraq","Ireland","Israel","Italy","Japan","Jordan","Kazakhstan","Kenya","Kiribati","North Korea","South Korea","Kuwait","Kyrgyzstan","Laos","Latvia","Lebanon","Lesotho","Liberia","Libya","Liechtenstein","Lithuania","Luxembourg","Macedonia","Madagascar","Malawi","Malaysia","Maldives","Mali","Malta","Marshall Islands","Mauritania","Mauritius","Mexico","Micronesia","Moldova","Monaco","Mongolia","Montenegro","Morocco","Mozambique","Myanmar","Namibia","Nauru","Nepal","Netherlands","New Zealand","Nicaragua","Niger","Nigeria","Norway","Northern Mariana Islands","Oman","Pakistan","Palau","Palestine","Panama","Papua New Guinea","Paraguay","Peru","Philippines","Poland","Portugal","Puerto Rico","Qatar","Romania","Russia","Rwanda","Saint Kitts and Nevis","Saint Lucia", "Saint Vincent and the Grenadines","Samoa","San Marino", "Sao Tome and Principe","Saudi Arabia","Senegal","Serbia and Montenegro","Seychelles","Sierra Leone","Singapore","Slovakia","Slovenia","Solomon Islands","Somalia","South Africa","Spain","Sri Lanka","Sudan","Sudan, South","Suriname","Swaziland","Sweden","Switzerland","Syria","Taiwan","Tajikistan","Tanzania","Thailand","Togo","Tonga","Trinidad and Tobago","Tunisia","Turkey","Turkmenistan","Tuvalu","Uganda","Ukraine","United Arab Emirates","United Kingdom","United States","Uruguay","Uzbekistan","Vanuatu","Vatican City","Venezuela","Vietnam","Virgin Islands, British","Virgin Islands, U.S.","Yemen","Zambia","Zimbabwe"]

  countries.sample
end

#get_dob(min_years_old, max_years_old) ⇒ Object



26
27
28
# File 'lib/SykGenData/generators/gen_form_data.rb', line 26

def get_dob min_years_old, max_years_old
  Date.birthday(min_years_old, max_years_old).to_s.split('-').map {|x| x.to_i}
end

#get_emailObject



120
121
122
# File 'lib/SykGenData/generators/gen_form_data.rb', line 120

def get_email
  Internet.free_email
end

#get_fake_locationObject



12
13
14
15
16
# File 'lib/SykGenData/generators/gen_form_data.rb', line 12

def get_fake_location
  location = [RickAndMorty.location, Simpsons.location, StarTrek.location, StarWars.planet, Zelda.location, Witcher.location, Lovecraft.location, HarryPotter.location, HitchhikersGuideToTheGalaxy.location, HitchhikersGuideToTheGalaxy.planet, HitchhikersGuideToTheGalaxy.starship]

  location.sample
end

#get_first_nameObject



18
19
20
# File 'lib/SykGenData/generators/gen_form_data.rb', line 18

def get_first_name
  Name.first_name
end

#get_hobbyObject



57
58
59
60
61
62
63
64
65
66
# File 'lib/SykGenData/generators/gen_form_data.rb', line 57

def get_hobby
  case Random.new.rand(0..2)
  when 0
    'dance'
  when 1
    'reading'
  when 2
    'cricket'
  end
end

#get_last_nameObject



22
23
24
# File 'lib/SykGenData/generators/gen_form_data.rb', line 22

def get_last_name
  Name.last_name
end

#get_long_passwordObject



107
108
109
# File 'lib/SykGenData/generators/gen_form_data.rb', line 107

def get_long_password
  Internet.password(64, 128, true, true)
end

#get_long_usernameObject

Concatenates usernames from get_username until it has a string 64 characters long



87
88
89
90
91
92
93
94
95
96
# File 'lib/SykGenData/generators/gen_form_data.rb', line 87

def get_long_username
  def get_long_username_recursion username
    if username.length < 64
      get_long_username_recursion username += '_' + get_username
    else
      username.slice 0...64
    end
  end
  get_long_username_recursion get_username
end

#get_long_username_recursion(username) ⇒ Object



88
89
90
91
92
93
94
# File 'lib/SykGenData/generators/gen_form_data.rb', line 88

def get_long_username_recursion username
  if username.length < 64
    get_long_username_recursion username += '_' + get_username
  else
    username.slice 0...64
  end
end

#get_marital_statusObject



46
47
48
49
50
51
52
53
54
55
# File 'lib/SykGenData/generators/gen_form_data.rb', line 46

def get_marital_status
  case Random.new.rand(0..2)
  when 0
    'single'
  when 1
    'married'
  when 2
    'divorced'
  end
end

#get_numeric_stringObject



111
112
113
114
115
116
117
118
# File 'lib/SykGenData/generators/gen_form_data.rb', line 111

def get_numeric_string
  string = Random.new.rand(0..9).to_s
  final_length = Random.new.rand(8..16)
  while string.length < final_length
    string += Random.new.rand(0..9).to_s
  end
  string
end

#get_passwordObject



103
104
105
# File 'lib/SykGenData/generators/gen_form_data.rb', line 103

def get_password
  Internet.password(8, 16, true, true)
end

#get_phone_numberObject



68
69
70
71
72
73
74
# File 'lib/SykGenData/generators/gen_form_data.rb', line 68

def get_phone_number
  phone_number = '07'
  while phone_number.length<11
    phone_number += Random.new.rand(0..9).to_s
  end
  phone_number
end

#get_usernameObject



76
77
78
79
80
81
82
83
84
# File 'lib/SykGenData/generators/gen_form_data.rb', line 76

def get_username
  characters = [Ancient.god, Ancient.primordial, Ancient.titan, Ancient.hero, DragonBall.character, Artist.name, BackToTheFuture.character, Book.genre, DrWho.character, DrWho.villian, DrWho.specie, HarryPotter.character, LordOfTheRings.character, Lovecraft.deity, RickAndMorty.character, Seinfeld.character, Simpsons.character, StarTrek.character, StarTrek.villain, StarWars.character, TheFreshPrinceOfBelAir.character, Superhero.descriptor]

  username = characters.sample
  username += Random.new.rand(0..9).to_s
  username += Random.new.rand(0..9).to_s
  username += Random.new.rand(0..9).to_s
  username.gsub(/\s+/, "")
end

#get_visa_cc_numberObject



30
31
32
33
34
35
36
# File 'lib/SykGenData/generators/gen_form_data.rb', line 30

def get_visa_cc_number
  cc_number = '4'
  while cc_number.length < 16
    cc_number += rand(0..9).to_s
  end
  cc_number
end

#get_visa_sec_codeObject



38
39
40
41
42
43
44
# File 'lib/SykGenData/generators/gen_form_data.rb', line 38

def get_visa_sec_code
  sec_code = ''
  while sec_code.length < 3
    sec_code += rand(0..9).to_s
  end
  sec_code
end