random_data 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/License.txt +20 -0
- data/Manifest.txt +30 -0
- data/README.txt +99 -0
- data/Rakefile +4 -0
- data/config/hoe.rb +71 -0
- data/config/requirements.rb +17 -0
- data/lib/random_data/array_randomizer.rb +18 -0
- data/lib/random_data/contact_info.rb +24 -0
- data/lib/random_data/dates.rb +21 -0
- data/lib/random_data/locations.rb +106 -0
- data/lib/random_data/names.rb +49 -0
- data/lib/random_data/text.rb +71 -0
- data/lib/random_data/version.rb +9 -0
- data/lib/random_data.rb +17 -0
- data/log/debug.log +0 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +74 -0
- data/setup.rb +1585 -0
- data/tasks/deployment.rake +27 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +9 -0
- data/test/test_helper.rb +4 -0
- data/test/test_random_data.rb +89 -0
- data/website/index.html +228 -0
- data/website/index.txt +143 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +141 -0
- data/website/template.rhtml +48 -0
- metadata +81 -0
data/History.txt
ADDED
data/License.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2007 Mike Subelsky, subelsky.com
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
History.txt
|
2
|
+
License.txt
|
3
|
+
Manifest.txt
|
4
|
+
README.txt
|
5
|
+
Rakefile
|
6
|
+
config/hoe.rb
|
7
|
+
config/requirements.rb
|
8
|
+
lib/random_data.rb
|
9
|
+
lib/random_data/array_randomizer.rb
|
10
|
+
lib/random_data/contact_info.rb
|
11
|
+
lib/random_data/dates.rb
|
12
|
+
lib/random_data/locations.rb
|
13
|
+
lib/random_data/names.rb
|
14
|
+
lib/random_data/text.rb
|
15
|
+
lib/random_data/version.rb
|
16
|
+
log/debug.log
|
17
|
+
script/destroy
|
18
|
+
script/generate
|
19
|
+
script/txt2html
|
20
|
+
setup.rb
|
21
|
+
tasks/deployment.rake
|
22
|
+
tasks/environment.rake
|
23
|
+
tasks/website.rake
|
24
|
+
test/test_helper.rb
|
25
|
+
test/test_random_data.rb
|
26
|
+
website/index.html
|
27
|
+
website/index.txt
|
28
|
+
website/javascripts/rounded_corners_lite.inc.js
|
29
|
+
website/stylesheets/screen.css
|
30
|
+
website/template.rhtml
|
data/README.txt
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
= Random
|
2
|
+
|
3
|
+
This plugin defines a Random singleton class that has a bunch of class methods to quickly generate random test for testing and developmental use.
|
4
|
+
|
5
|
+
== Installation
|
6
|
+
|
7
|
+
<tt>sudo gem install random_data</tt>
|
8
|
+
|
9
|
+
== Methods
|
10
|
+
|
11
|
+
=== Contact Methods
|
12
|
+
Random.phone, Random.international_phone, Random.email
|
13
|
+
|
14
|
+
=== Time/Date Methods
|
15
|
+
Random.date
|
16
|
+
|
17
|
+
=== Location Methods
|
18
|
+
Random.address_line_1, Random.address_line_2, Random.zipcode, Random.state, Random.country, Random.city,
|
19
|
+
|
20
|
+
=== Name Methods
|
21
|
+
Random.firstname, Random.initial, Random.lastname,
|
22
|
+
|
23
|
+
=== Text Methods
|
24
|
+
Random.alphanumeric, Random.paragraphs
|
25
|
+
|
26
|
+
Note that some methods take parameters to bound or limit the amount of data returned. See RDocs for details.
|
27
|
+
|
28
|
+
|
29
|
+
== Examples
|
30
|
+
|
31
|
+
>>Random.alphanumeric
|
32
|
+
=> "cfbutm3vYfhZXil0"
|
33
|
+
|
34
|
+
>> Random.alphanumeric(5)
|
35
|
+
=> "XYVyn"
|
36
|
+
|
37
|
+
>> Random.paragraphs
|
38
|
+
=> "Ulysses, fighting evil and tyranny with all his power and with all of his might. Ulysses, fighting evil and tyranny with all his power and with all
|
39
|
+
of his might. \n\nHe's got style, a groovy style, and a car that just won't stop. \n\n"
|
40
|
+
|
41
|
+
>> Random.paragraphs(3)
|
42
|
+
=> "Excepteur sint occaecat cupidatat non proident sunt in culpa qui officia deserunt mollit anim id est laborum. Down the road that's where I'll always be.
|
43
|
+
He's got style, a groovy style, and a car that just won't stop. I've gotten burned over Cheryl Tiegs and blown up for Raquel Welch, but when I end up in the
|
44
|
+
hay it's only hay hey hey. Hey there where ya goin, not exactly knowin'. \n\nLorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor
|
45
|
+
incididunt ut labore et dolore magna aliqua. I might jump an open drawbridge or Tarzan from a vine, beause I'm the unknown stuntman that makes Eastwood look so
|
46
|
+
fine. He just keeps on movin' and ladies keep improvin'. Rolling down to Dallas - who is providin my palace?. Every stop I make I make a new friend; Can't
|
47
|
+
stay for long just turn around and I'm gone again. \n\nAlways fighting all the evil forces bringing peace and justice to all. \n\n"
|
48
|
+
|
49
|
+
>> Random.firstname
|
50
|
+
=> "Thomas"
|
51
|
+
|
52
|
+
>> Random.initial
|
53
|
+
=> "E"
|
54
|
+
|
55
|
+
>> Random.lastname
|
56
|
+
=> "Robinson"
|
57
|
+
|
58
|
+
>> Random.date
|
59
|
+
=> Sun, 09 Sep 2007
|
60
|
+
|
61
|
+
(Returns an actual date object, shown here in its to_s form)
|
62
|
+
|
63
|
+
>> Random.date(1000)
|
64
|
+
=> Sun, 26 Nov 2006
|
65
|
+
|
66
|
+
>> Random.email
|
67
|
+
=> "zrodriguez@example.com"
|
68
|
+
|
69
|
+
>> Random.phone
|
70
|
+
=> "564-103-8353"
|
71
|
+
|
72
|
+
>> Random.international_phone
|
73
|
+
=> "011-24-37-9704"
|
74
|
+
|
75
|
+
>> Random.address_line_1
|
76
|
+
=> "38367 Adams Rd"
|
77
|
+
|
78
|
+
>> Random.address_line_2
|
79
|
+
=> "Lot 247"
|
80
|
+
|
81
|
+
>> Random.zipcode
|
82
|
+
=> 22904
|
83
|
+
|
84
|
+
(Note that the zipcodes are totally random and may not be real zipcodes)
|
85
|
+
|
86
|
+
>> Random.state
|
87
|
+
=> "MD"
|
88
|
+
|
89
|
+
>> Random.state_full
|
90
|
+
=> "New Mexico"
|
91
|
+
|
92
|
+
>> Random.country
|
93
|
+
=> "Philippines"
|
94
|
+
|
95
|
+
== Contact
|
96
|
+
Let me know if you have patches, comments, or suggestions: mailto:mike@subelsky.com
|
97
|
+
|
98
|
+
== Copyright
|
99
|
+
Copyright (c) 2007 {Mike Subelsky}[http://subelsky.com/], Baltimore, Maryland, released under the MIT license
|
data/Rakefile
ADDED
data/config/hoe.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'random_data/version'
|
2
|
+
|
3
|
+
AUTHOR = 'Mike Subelsky' # can also be an array of Authors
|
4
|
+
EMAIL = "mike@subelsky.com"
|
5
|
+
DESCRIPTION = "A Ruby gem that provides a Random singleton class with a series of methods for generating random test data including names, mailing addresses, dates, phone numbers, e-mail addresses, and text."
|
6
|
+
GEM_NAME = 'random_data' # what ppl will type to install your gem
|
7
|
+
RUBYFORGE_PROJECT = 'random-data' # The unix name for your project
|
8
|
+
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
9
|
+
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
10
|
+
|
11
|
+
@config_file = "~/.rubyforge/user-config.yml"
|
12
|
+
@config = nil
|
13
|
+
RUBYFORGE_USERNAME = "unknown"
|
14
|
+
|
15
|
+
def rubyforge_username
|
16
|
+
unless @config
|
17
|
+
begin
|
18
|
+
@config = YAML.load(File.read(File.expand_path(@config_file)))
|
19
|
+
rescue
|
20
|
+
puts <<-EOS
|
21
|
+
ERROR: No rubyforge config file found: #{@config_file}
|
22
|
+
Run 'rubyforge setup' to prepare your env for access to Rubyforge
|
23
|
+
- See http://newgem.rubyforge.org/rubyforge.html for more details
|
24
|
+
EOS
|
25
|
+
exit
|
26
|
+
end
|
27
|
+
end
|
28
|
+
RUBYFORGE_USERNAME.replace @config["username"]
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
REV = nil
|
33
|
+
# UNCOMMENT IF REQUIRED:
|
34
|
+
# REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
|
35
|
+
VERS = RandomData::VERSION::STRING + (REV ? ".#{REV}" : "")
|
36
|
+
RDOC_OPTS = ['--quiet', '--title', 'random_data documentation',
|
37
|
+
"--opname", "index.html",
|
38
|
+
"--line-numbers",
|
39
|
+
"--main", "README",
|
40
|
+
"--inline-source"]
|
41
|
+
|
42
|
+
class Hoe
|
43
|
+
def extra_deps
|
44
|
+
@extra_deps.reject! { |x| Array(x).first == 'hoe' }
|
45
|
+
@extra_deps
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Generate all the Rake tasks
|
50
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
51
|
+
hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
52
|
+
p.author = AUTHOR
|
53
|
+
p.description = DESCRIPTION
|
54
|
+
p.email = EMAIL
|
55
|
+
p.summary = DESCRIPTION
|
56
|
+
p.url = HOMEPATH
|
57
|
+
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
58
|
+
p.test_globs = ["test/**/test_*.rb"]
|
59
|
+
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
|
60
|
+
|
61
|
+
# == Optional
|
62
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\\n\\n")
|
63
|
+
#p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
|
64
|
+
|
65
|
+
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
|
70
|
+
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
71
|
+
hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
include FileUtils
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
%w[rake hoe newgem rubigen].each do |req_gem|
|
6
|
+
begin
|
7
|
+
require req_gem
|
8
|
+
rescue LoadError
|
9
|
+
puts "This Rakefile requires the '#{req_gem}' RubyGem."
|
10
|
+
puts "Installation: gem install #{req_gem} -y"
|
11
|
+
exit
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
|
16
|
+
|
17
|
+
require 'random_data'
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Extends the Array class with a function used to randomly choose elements. Note that if you are using Rails, ActiveSupport recently was updated to include a similar
|
2
|
+
# function. This code checks for the presence of that method and does not try to replace it. They work the same though so no worries.
|
3
|
+
|
4
|
+
module ArrayRandomizer
|
5
|
+
|
6
|
+
# Randomly chooses an element from an array
|
7
|
+
# >> [1,2,3].rand = 3
|
8
|
+
# [].rand = nil
|
9
|
+
|
10
|
+
def rand
|
11
|
+
return self[Kernel.rand(self.size)]
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
unless Array.respond_to?(:rand)
|
17
|
+
Array.send :include, ArrayRandomizer
|
18
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module RandomData
|
2
|
+
# Methods for randomly generating contact data like phone numbers and e-mail addresses
|
3
|
+
|
4
|
+
module ContactInfo
|
5
|
+
|
6
|
+
# Returns a randomly-generated string of digits that roughly resembles a US telephone number. Not guaranteed to be a valid area code.
|
7
|
+
def phone
|
8
|
+
"#{rand(900) + 100}-#{rand(900)+100}-#{rand(10000)+1000}"
|
9
|
+
end
|
10
|
+
|
11
|
+
# Returns a randomly-generated string of digits that roughly resembles an international telephone number as dialed from the US.
|
12
|
+
# Not guaranteed to be a valid number but just good enough to get some sample data going.
|
13
|
+
|
14
|
+
def international_phone
|
15
|
+
"011-#{rand(100) + 1}-#{rand(100)+10}-#{rand(10000)+1000}"
|
16
|
+
end
|
17
|
+
|
18
|
+
# Returns an e-mail address of the form "{first_initial}{last_name}@{domain}"
|
19
|
+
def email
|
20
|
+
domains = %w(yahoo.com gmail.com privacy.net webmail.com msn.com hotmail.com example.com privacy.net)
|
21
|
+
"#{(initial + lastname).downcase}\@#{domains.rand}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
module RandomData
|
4
|
+
|
5
|
+
# Defines methods for random date generation
|
6
|
+
|
7
|
+
module Dates
|
8
|
+
|
9
|
+
# Returns a date within a specified range of days (plus or minus half what you specify). The default is ten days, so by default you will
|
10
|
+
# get a date within plus or minus five days of today.
|
11
|
+
#
|
12
|
+
# Example:
|
13
|
+
#
|
14
|
+
# >> Random.date.to_s = "2007-09-16"
|
15
|
+
|
16
|
+
def date(dayrange=10)
|
17
|
+
(Date.today + (rand(dayrange*2) - dayrange))
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
module RandomData
|
2
|
+
|
3
|
+
# Defines methods to return random location data.
|
4
|
+
|
5
|
+
module Locations
|
6
|
+
|
7
|
+
@@streetnames = %w( Park Washington Maple Oak Lincoln Walnut Elm Jefferson Highland Madison Pine Cedar Sunset Jackson Franklin Willow 3rd Wilson 2nd Laurel
|
8
|
+
5th Chestnut 4th Adams Virginia Linden Woodland Cherry Rose 1st)
|
9
|
+
|
10
|
+
@@street_types = %w(St Ave Rd Blvd Trl Ter Rdg Pl Pkwy Ct Circle)
|
11
|
+
|
12
|
+
# Returns the first line of a US maiiling address (street number, street name, street type)
|
13
|
+
#
|
14
|
+
# Example:
|
15
|
+
#
|
16
|
+
#Random.address_line_1 = "24317 Jefferson Blvd"
|
17
|
+
|
18
|
+
def address_line_1
|
19
|
+
"#{rand(40000)} #{@@streetnames.rand} #{@@street_types.rand}"
|
20
|
+
end
|
21
|
+
|
22
|
+
@@line2types = ["Apt", "Bsmt", "Bldg", "Dept", "Fl", "Frnt", "Hngr", "Lbby", "Lot", "Lowr", "Ofc", "Ph", "Pier", "Rear", "Rm", "Side", "Slip", "Spc", "Stop", "Ste", "Trlr", "Unit", "Uppr"]
|
23
|
+
|
24
|
+
# Returns the first line of a US maiiling address (street number, street name, street type)
|
25
|
+
#
|
26
|
+
# Example:
|
27
|
+
#
|
28
|
+
#Random.address_line_1 = "24317 Jefferson Blvd"
|
29
|
+
|
30
|
+
def address_line_2
|
31
|
+
"#{@@line2types.rand} #{rand(999)}"
|
32
|
+
end
|
33
|
+
|
34
|
+
# Returns a random 5-digit string, not guaranteed to be a legitimate zip code.
|
35
|
+
def zipcode
|
36
|
+
rand(89999) + 10000
|
37
|
+
end
|
38
|
+
|
39
|
+
# from technoweenie: http://svn.techno-weenie.net/projects/plugins/us_states/lib/us_states.rb
|
40
|
+
@@us_states = [["Alaska", "AK"], ["Alabama", "AL"], ["Arkansas", "AR"], ["Arizona", "AZ"],
|
41
|
+
["California", "CA"], ["Colorado", "CO"], ["Connecticut", "CT"], ["District of Columbia", "DC"],
|
42
|
+
["Delaware", "DE"], ["Florida", "FL"], ["Georgia", "GA"], ["Hawaii", "HI"], ["Iowa", "IA"],
|
43
|
+
["Idaho", "ID"], ["Illinois", "IL"], ["Indiana", "IN"], ["Kansas", "KS"], ["Kentucky", "KY"],
|
44
|
+
["Louisiana", "LA"], ["Massachusetts", "MA"], ["Maryland", "MD"], ["Maine", "ME"], ["Michigan", "MI"],
|
45
|
+
["Minnesota", "MN"], ["Missouri", "MO"], ["Mississippi", "MS"], ["Montana", "MT"], ["North Carolina", "NC"],
|
46
|
+
["North Dakota", "ND"], ["Nebraska", "NE"], ["New Hampshire", "NH"], ["New Jersey", "NJ"],
|
47
|
+
["New Mexico", "NM"], ["Nevada", "NV"], ["New York", "NY"], ["Ohio", "OH"], ["Oklahoma", "OK"],
|
48
|
+
["Oregon", "OR"], ["Pennsylvania", "PA"], ["Rhode Island", "RI"], ["South Carolina", "SC"], ["South Dakota", "SD"],
|
49
|
+
["Tennessee", "TN"], ["Texas", "TX"], ["Utah", "UT"], ["Virginia", "VA"], ["Vermont", "VT"],
|
50
|
+
["Washington", "WA"], ["Wisconsin", "WI"], ["West Virginia", "WV"], ["Wyoming", "WY"]]
|
51
|
+
|
52
|
+
# Returns a state 2-character abbreviation
|
53
|
+
#Random.state = "IL"
|
54
|
+
|
55
|
+
def state
|
56
|
+
@@us_states.rand[1]
|
57
|
+
end
|
58
|
+
|
59
|
+
# Returns a full state name
|
60
|
+
#Random.state_full = "Texas"
|
61
|
+
|
62
|
+
def state_full
|
63
|
+
@@us_states.rand[0]
|
64
|
+
end
|
65
|
+
|
66
|
+
# from http://siteresources.worldbank.org/DATASTATISTICS/Resources/CLASS.XLS
|
67
|
+
@@countries = ["Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia",
|
68
|
+
"Austria", "Azerbaijan", "Bahamas, The", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan",
|
69
|
+
"Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon",
|
70
|
+
"Canada", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Channel Islands", "Chile", "China", "Colombia", "Comoros", "Congo, Dem. Rep.",
|
71
|
+
"Congo, Rep.", "Costa Rica", "Côte d'Ivoire", "Croatia", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "Ecuador",
|
72
|
+
"Egypt, Arab Rep.", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Faeroe Islands", "Fiji", "Finland", "France", "French Polynesia",
|
73
|
+
"Gabon", "Gambia, The", "Georgia", "Germany", "Ghana", "Greece", "Greenland", "Grenada", "Guam", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana", "Haiti",
|
74
|
+
"Honduras", "Hong Kong, China", "Hungary", "Iceland", "India", "Indonesia", "Iran, Islamic Rep.", "Iraq", "Ireland", "Isle of Man", "Israel", "Italy", "Jamaica",
|
75
|
+
"Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, Dem. Rep.", "Korea, Rep.", "Kuwait", "Kyrgyz Republic", "Lao PDR", "Latvia", "Lebanon", "Lesotho",
|
76
|
+
"Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macao, China", "Macedonia, FYR", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta",
|
77
|
+
"Marshall Islands", "Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia, Fed. Sts.", "Moldova", "Monaco", "Mongolia", "Montenegro", "Morocco",
|
78
|
+
"Mozambique", "Myanmar", "Namibia", "Nepal", "Netherlands", "Netherlands Antilles", "New Caledonia", "New Zealand", "Nicaragua", "Niger", "Nigeria",
|
79
|
+
"Northern Mariana Islands", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal",
|
80
|
+
"Puerto Rico", "Qatar", "Romania", "Russian Federation", "Rwanda", "Samoa", "San Marino", "São Tomé and Principe", "Saudi Arabia", "Senegal", "Serbia",
|
81
|
+
"Seychelles", "Sierra Leone", "Singapore", "Slovak Republic", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "Spain", "Sri Lanka", "St. Kitts and Nevis",
|
82
|
+
"St. Lucia", "St. Vincent and the Grenadines", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syrian Arab Republic", "Tajikistan", "Tanzania", "Thailand",
|
83
|
+
"Timor-Leste", "Togo", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom",
|
84
|
+
"United States", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela, RB", "Vietnam", "Virgin Islands (U.S.)", "West Bank and Gaza", "Yemen, Rep.", "Zambia", "Zimbabwe"]
|
85
|
+
|
86
|
+
# Returns a country name, as listed by the World Bank
|
87
|
+
#
|
88
|
+
#Random.country = "Kenya"
|
89
|
+
|
90
|
+
def country
|
91
|
+
@@countries.rand
|
92
|
+
end
|
93
|
+
|
94
|
+
@@cities = %w(Midway Mount\ Pleasant Greenwood Franklin Oak Grove Centerville Salem Georgetown Fairview Riverside Rotorua Tauranga Whakatane Taupo Wanganui
|
95
|
+
Nababeep Aggeneys Pofadder Polokwane Bela Bela Goukamma Karatara Tswane Prieska Upington Hoopstad Bultfontein Wesselsbron Bothaville Trompsburg
|
96
|
+
Henneman Musina Ogies Kgatlahong Tembisa Tekoza Sebokeng Muntaung Umnkomaaz)
|
97
|
+
|
98
|
+
# Returns a generic city name, with an attempt to have some internationl appeal
|
99
|
+
#
|
100
|
+
# Random.city = "Tekoza"
|
101
|
+
|
102
|
+
def city
|
103
|
+
@@cities.rand
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module RandomData
|
2
|
+
|
3
|
+
# Methods to create realistic-looking names
|
4
|
+
module Names
|
5
|
+
|
6
|
+
# Returns a random letter
|
7
|
+
|
8
|
+
def initial
|
9
|
+
|
10
|
+
choice = rand(26) + 66
|
11
|
+
|
12
|
+
if choice == 91
|
13
|
+
return nil
|
14
|
+
else
|
15
|
+
return choice.chr
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
@@lastnames = %w( SMITH JOHNSON WILLIAMS JONES BROWN DAVIS MILLER WILSON MOORE TAYLOR ANDERSON THOMAS JACKSON WHITE HARRIS MARTIN THOMPSON GARCIA MARTINEZ
|
22
|
+
ROBINSON CLARK RODRIGUEZ LEWIS LEE WALKER )
|
23
|
+
|
24
|
+
# Returns a random lastname
|
25
|
+
#
|
26
|
+
# >> Random.lastname
|
27
|
+
#
|
28
|
+
# "Harris"
|
29
|
+
|
30
|
+
def lastname
|
31
|
+
@@lastnames.rand.capitalize
|
32
|
+
end
|
33
|
+
|
34
|
+
@@firstnames = %w(JAMES JOHN ROBERT MICHAEL WILLIAM DAVID RICHARD CHARLES JOSEPH THOMAS CHRISTOPHER DANIEL PAUL MARK DONALD GEORGE KENNETH STEVEN EDWARD BRIAN
|
35
|
+
RONALD ANTHONY KEVIN JASON MARY PATRICIA LINDA BARBARA ELIZABETH JENNIFER MARIA SUSAN MARGARET DOROTHY LISA NANCY KAREN BETTY HELEN SANDRA
|
36
|
+
DONNA CAROL RUTH SHARON MICHELLE LAURA SARAH KIMBERLY DEBORAH)
|
37
|
+
|
38
|
+
# Returns a random firstname
|
39
|
+
#
|
40
|
+
# >> Random.firstname
|
41
|
+
#
|
42
|
+
# "Sandra"
|
43
|
+
|
44
|
+
def firstname
|
45
|
+
@@firstnames.rand.capitalize
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|