Class: Fab

Inherits:
Object
  • Object
show all
Defined in:
lib/sixarm_ruby_fab.rb,
lib/sixarm_ruby_fab/id.rb,
lib/sixarm_ruby_fab/geo.rb,
lib/sixarm_ruby_fab/date.rb,
lib/sixarm_ruby_fab/mime.rb,
lib/sixarm_ruby_fab/text.rb,
lib/sixarm_ruby_fab/time.rb,
lib/sixarm_ruby_fab/uuid.rb,
lib/sixarm_ruby_fab/agent.rb,
lib/sixarm_ruby_fab/basic.rb,
lib/sixarm_ruby_fab/email.rb,
lib/sixarm_ruby_fab/files.rb,
lib/sixarm_ruby_fab/names.rb,
lib/sixarm_ruby_fab/phone.rb,
lib/sixarm_ruby_fab/locale.rb,
lib/sixarm_ruby_fab/postal.rb,
lib/sixarm_ruby_fab/company.rb,
lib/sixarm_ruby_fab/twitter.rb,
lib/sixarm_ruby_fab/datetime.rb,
lib/sixarm_ruby_fab/internet.rb,
lib/sixarm_ruby_fab/password.rb,
lib/sixarm_ruby_fab/timezone.rb,
lib/sixarm_ruby_fab/username.rb

Constant Summary collapse

AZ =
("a".."z").to_a
NAME_CHARS =
"aabcdeeefghiijklmnoopqrrssttuuvwxyz".split(//)
NOTE_CHARS =
"aabcdeeefghiijklmnoopqrrssttuuvwxyz     ..,,;;-+'*".split(//)
AGENT_LIST =
[
  "Mozilla/5.0 (iPhone; CPU iPhone OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9A405",
  "Mozilla/5.0 (iPhone; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B179",
  "Mozilla/5.0 (Linux; U; Android 2.3.5; en-us; SCH-I500 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
  "Mozilla/5.0 (Linux; U; Android 4.0.3; en-us; EVO Build/IML74K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30"
]
CHARS =
('a'..'z').to_a
LANGUAGE_CODE_ISO6391_LIST =
[
  'en',  # English
  'fr',  # French
  'de',  # German
  'ja',  # Japanese
]

Instance Method Summary collapse

Instance Method Details

#agentObject



12
13
14
# File 'lib/sixarm_ruby_fab/agent.rb', line 12

def agent
  agent_list.sample
end

#agent_listObject



16
17
18
# File 'lib/sixarm_ruby_fab/agent.rb', line 16

def agent_list
  @agent_list ||= AGENT_LIST
end

#agent_list=(x) ⇒ Object



20
21
22
# File 'lib/sixarm_ruby_fab/agent.rb', line 20

def agent_list=x
  @agent_list=x
end

#basename(options = {}) ⇒ Object

Fab a base name e.g. “myfile.txt”

The base name has two parts:

* The "intension" e.g. "myfile"
* The "extension" e.g. "txt"

Options:

* chars: a..z
* intension_length: [sent to #basename_intension as :length]
* extension_length: [sent to #basename_extension as :length]


30
31
32
33
34
# File 'lib/sixarm_ruby_fab/files.rb', line 30

def basename(options = {})
  intension = basename_intension(options[:intension_length] ? options.merge(length: intension_length) : options)
  extension = basename_extension(options[:extension_length] ? options.merge(length: extension_length) : options)
  "#{intension}.#{extension}"
end

#basename_extension(options = {}) ⇒ Object

Fab a file base name extension e.g. “txt”

Options:

* chars: a..z
* length: rand(1..5)


58
59
60
# File 'lib/sixarm_ruby_fab/files.rb', line 58

def basename_extension(options = {})
  (options[:chars] || AZ).sample(options[:size] || rand(1..5)).join
end

#basename_intension(options = {}) ⇒ Object

Fab a file base name intension e.g. “myfile”

Options:

* chars: a..z
* length: rand(1..30)


45
46
47
# File 'lib/sixarm_ruby_fab/files.rb', line 45

def basename_intension(options = {})
  (options[:chars] || AZ).sample(options[:size] || rand(1..30)).join
end

#booleanboolean

Fab a boolean, either true or false.

Returns:

  • (boolean)

    either true or false.



9
10
11
# File 'lib/sixarm_ruby_fab/basic.rb', line 9

def boolean
  [true, false].sample
end

#cityObject

Fab a random city string. Delegates to Forgery::Address.city



19
20
21
# File 'lib/sixarm_ruby_fab/postal.rb', line 19

def city
  Forgery::Address.city 
end

#company_name(options = {}) ⇒ Object

Fab a company name. Delegates to Forgery::Name.company_name.



10
11
12
# File 'lib/sixarm_ruby_fab/company.rb', line 10

def company_name(options = {})
  Forgery::Name.company_name
end

#content_type(options = {}) ⇒ Object

Fab a random content type part e.g. “image/jpeg”.

Options:

* chars: a..z
* size: rand(1..20) [per part]


14
15
16
# File 'lib/sixarm_ruby_fab/mime.rb', line 14

def content_type(options = {})
  "#{content_type_part(options)}/#{content_type_part(options)}"
end

#content_type_part(options = {}) ⇒ Object

Fab a random content type part e.g. “image”.

Options:

* chars: a..z
* size: rand(1..20)


27
28
29
# File 'lib/sixarm_ruby_fab/mime.rb', line 27

def content_type_part(options = {})
  (options[:chars] || AZ).sample(options[:size] || rand(1..20)).join
end

#date(options = {}) ⇒ Object

Fab a random date.

Options:

* min: today - 1000 
* max: today + 1000


14
15
16
# File 'lib/sixarm_ruby_fab/date.rb', line 14

def date(options = {})
  rand((options[:min] || date_min)..(options[:max] || date_max))
end

#date_maxObject

Get. The default is today + 1000.



29
30
31
# File 'lib/sixarm_ruby_fab/date.rb', line 29

def date_max
  @date_max ||= Date.today + 1000
end

#date_max=(x) ⇒ Object

Set.



34
35
36
# File 'lib/sixarm_ruby_fab/date.rb', line 34

def date_max=x
  @date_max=x
end

#date_minObject

Get. The default is today - 1000.



19
20
21
# File 'lib/sixarm_ruby_fab/date.rb', line 19

def date_min
  @date_min ||= Date.today - 1000
end

#date_min=(x) ⇒ Object

Set.



24
25
26
# File 'lib/sixarm_ruby_fab/date.rb', line 24

def date_min=x
  @date_min=x
end

#datetime(options = {}) ⇒ Object

Fab a random datetime.

Options:

* min: now - 1000 
* max: now + 1000


14
15
16
# File 'lib/sixarm_ruby_fab/datetime.rb', line 14

def datetime(options = {})
  rand((options[:min] || datetime_min)..(options[:max] || datetime_max))
end

#datetime_maxObject

Get. The default is now + 1000.



29
30
31
# File 'lib/sixarm_ruby_fab/datetime.rb', line 29

def datetime_max
  @datetime_max ||= DateTime.now + 1000
end

#datetime_max=(x) ⇒ Object

Set.



34
35
36
# File 'lib/sixarm_ruby_fab/datetime.rb', line 34

def datetime_max=x
  @datetime_max=x
end

#datetime_minObject

Get. The default is now - 1000.



19
20
21
# File 'lib/sixarm_ruby_fab/datetime.rb', line 19

def datetime_min
  @datetime_min ||= DateTime.now - 1000
end

#datetime_min=(x) ⇒ Object

Set.



24
25
26
# File 'lib/sixarm_ruby_fab/datetime.rb', line 24

def datetime_min=x
  @datetime_min=x
end

#description(options = {}) ⇒ Object

Fab a random note.

Options:

* chars: NOTE_CHARS
* size: rand(20..200) [actual size may be less because we strip the string]


43
44
45
# File 'lib/sixarm_ruby_fab/text.rb', line 43

def description(options = {})
  (options[:chars] || NOTE_CHARS).sample(options[:size] || rand(20..200)).join.strip
end

#dirname(options = {}) ⇒ Object

Fab a directory name e.g. “/mydir1/mydir2”. This calls #dirname_part rand times.

Options:

* parts: rand(2..6) [how many parts to use]
* chars: a..z [sent to #dirname_part]
* length: 1..20 per part [sent to #dirname_part]


73
74
75
76
77
78
# File 'lib/sixarm_ruby_fab/files.rb', line 73

def dirname(options = {})
  pathname = Pathname.new("/")
  parts = options[:parts] || rand(2..6)
  parts.times.each{ pathname += dirname_part(options) }
  pathname.to_s
end

#dirname_part(options = {}) ⇒ Object

Fab a directory path part e.g. “mydir”.

Options:

* chars: a..z
* size: rand(1..20)


89
90
91
# File 'lib/sixarm_ruby_fab/files.rb', line 89

def dirname_part(options = {})
  (options[:chars] || AZ).sample(options[:size] || rand(1..20)).join
end

#email_addressObject

Fab an email address. Delegate to Forgery::Email.address



10
11
12
# File 'lib/sixarm_ruby_fab/email.rb', line 10

def email_address
  Forgery::Email.address
end

#family_nameObject

Fab a random last name. Delegates to Forgery::Name.last_name



28
29
30
# File 'lib/sixarm_ruby_fab/names.rb', line 28

def family_name 
  Forgery::Name.last_name
end

#file_extension(options = {}) ⇒ Object

Fab a file extension. Delegates to #basename_extension.

TODO refactor this to streamline it



100
101
102
# File 'lib/sixarm_ruby_fab/files.rb', line 100

def file_extension(options = {})
  basename_extension(options)
end

#file_path(options = {}) ⇒ Object

Fab a file path. Delegates to #path.

TODO refactor this to streamline it



111
112
113
# File 'lib/sixarm_ruby_fab/files.rb', line 111

def file_path(options = {})
  path(options)
end

#given_nameObject

Fab a random given name. Delegates to Forgery::Name.first_name



10
11
12
# File 'lib/sixarm_ruby_fab/names.rb', line 10

def given_name 
  Forgery::Name.first_name
end

#id(options = {}) ⇒ Object

Fab a random id.

Options:

* min: 1
* max: 30000


14
15
16
# File 'lib/sixarm_ruby_fab/id.rb', line 14

def id(options = {})
  rand((options[:min] || 1)..(options[:max] || 30000))
end

#ids(options = {}) ⇒ Object

Fab a list of random ids.

Options:

* size: 3


26
27
28
# File 'lib/sixarm_ruby_fab/id.rb', line 26

def ids(options = {})
  (options[:size] || 3).times.map{ id(options) }
end

#job_title(options = {}) ⇒ Object

Fab a job title. Delegates to Forgery::Name.job_title.



19
20
21
# File 'lib/sixarm_ruby_fab/company.rb', line 19

def job_title(options = {})
  Forgery::Name.job_title
end

#language_code(options = {}) ⇒ Object

Fab a language code e.g. “en” for English. Delegates to #language_code_iso6391



17
18
19
# File 'lib/sixarm_ruby_fab/locale.rb', line 17

def language_code(options = {})
  language_code_iso6391(options)
end

#language_code_iso6391(options = {}) ⇒ Object

Fab a language code e.g. “en” for English. Samples from LANGUAGE_CODE_ISO6391_LIST.



26
27
28
# File 'lib/sixarm_ruby_fab/locale.rb', line 26

def language_code_iso6391(options = {})
  LANGUAGE_CODE_ISO6391_LIST.sample
end

#language_code_iso6391_listObject



30
31
32
# File 'lib/sixarm_ruby_fab/locale.rb', line 30

def language_code_iso6391_list
  @language_code_iso6391_list ||= LANGUAGE_CODE_ISO6391_LIST
end

#language_code_iso6391_list=(x) ⇒ Object



34
35
36
# File 'lib/sixarm_ruby_fab/locale.rb', line 34

def language_code_iso6391_list=x
  @language_code_iso6391_list=x
end

#latitudeObject

Fab a random latitude.



9
10
11
# File 'lib/sixarm_ruby_fab/geo.rb', line 9

def latitude
  rand * 180.0 - 90.0
end

#latitude_degreesObject

Return a latitude’s degrees component in the range -180 to +180 as an integer.



14
15
16
# File 'lib/sixarm_ruby_fab/geo.rb', line 14

def latitude_degrees
  rand(360)-180
end

#latitude_directionObject

Return a latitude’s direction component, either “N” (north) or “S” (south)



29
30
31
# File 'lib/sixarm_ruby_fab/geo.rb', line 29

def latitude_direction
  ["N","S"].sample
end

#latitude_minutesObject

Return a latitude’s minutes component in the range 0 to 60 as an integer.



19
20
21
# File 'lib/sixarm_ruby_fab/geo.rb', line 19

def latitude_minutes
  rand(60)
end

#latitude_secondsObject

Return a latitude’s seconds component in the range 0 to 60 as an integer.



24
25
26
# File 'lib/sixarm_ruby_fab/geo.rb', line 24

def latitude_seconds
  rand(60)
end

#longitudeObject

Fab a random longitude. Delegate to Forgery::Geo.longitude.



38
39
40
# File 'lib/sixarm_ruby_fab/geo.rb', line 38

def longitude
  rand * 360.0 - 180.0
end

#longitude_degreesObject

Return a longitude’s degrees component in the range -180 to +180 as an integer.



43
44
45
# File 'lib/sixarm_ruby_fab/geo.rb', line 43

def longitude_degrees
  rand(360)-180
end

#longitude_directionObject

Return a longitude’s direction component, either “E” (east) or “W” (west)



58
59
60
# File 'lib/sixarm_ruby_fab/geo.rb', line 58

def longitude_direction
  ["E","W"].sample
end

#longitude_minutesObject

Return a longitude’s minutes component in the range 0 to 60 as an integer.



48
49
50
# File 'lib/sixarm_ruby_fab/geo.rb', line 48

def longitude_minutes
  rand(60)
end

#longitude_secondsObject

Return a longitude’s seconds component in the range 0 to 60 as an integer.



53
54
55
# File 'lib/sixarm_ruby_fab/geo.rb', line 53

def longitude_seconds
  rand(60)
end

#lorem(options = {}) ⇒ Object

Fab a random lorem ipsum string.

Options:

* chars: NOTE_CHARS
* size: rand(20..200) [actual size may be less because we strip the string]


56
57
58
# File 'lib/sixarm_ruby_fab/text.rb', line 56

def lorem(options = {})
  (options[:chars] || NOTE_CHARS).sample(options[:size] || rand(20..200)).join.strip
end

#middle_nameObject

Fab a random middle name. Delegates to Forgery::Name.first_name



19
20
21
# File 'lib/sixarm_ruby_fab/names.rb', line 19

def middle_name 
  Forgery::Name.first_name
end

#name(options = {}) ⇒ Object

Fab a random name.

Options:

* chars: NAME_CHARS
* size: rand(10..30) [actual size may be less because we strip the string]


17
18
19
# File 'lib/sixarm_ruby_fab/text.rb', line 17

def name(options = {})
  (options[:chars] || NAME_CHARS).sample(options[:size] || rand(10..30)).join.strip
end

#note(options = {}) ⇒ Object

Fab a random note.

Options:

* chars: NOTE_CHARS
* size: rand(1..200) [actual size may be less because we strip the string]


30
31
32
# File 'lib/sixarm_ruby_fab/text.rb', line 30

def note(options = {})
  (options[:chars] || NOTE_CHARS).sample(options[:size] || rand(1..200)).join.strip
end

#password(options = {}) ⇒ Object

Fab a random password.

Options:

* chars: a..z
* size: rand(9..40)


14
15
16
# File 'lib/sixarm_ruby_fab/password.rb', line 14

def password(options = {})
  (options[:chars] || AZ).sample(options[:size] || rand(9..40)).join
end

#path(options = {}) ⇒ Object

Fab a path e.g. “/mydir1/mydir2/myfile.txt”



11
12
13
# File 'lib/sixarm_ruby_fab/files.rb', line 11

def path(options = {})
  (Pathname.new("") + dirname(options) + basename(options)).to_s
end

#phone(options = {}) ⇒ Object

Fab a random phone number string. Delegates to Forgery::Address.phone.



10
11
12
# File 'lib/sixarm_ruby_fab/phone.rb', line 10

def phone(options = {})
  Forgery::Address.phone
end

#rating(options = {}) ⇒ Integer

Fab a rating, such as 1 to 5 stars.

Options:

* min: 1
* max: 5

Returns:

  • (Integer)

    a random number



30
31
32
# File 'lib/sixarm_ruby_fab/basic.rb', line 30

def rating(options = {})
  rand((options[:min] || 1)..(options[:max] || 5))
end

#start_date(options = {}) ⇒ Object

Fab a random start date. Delegates to #date.



43
44
45
# File 'lib/sixarm_ruby_fab/date.rb', line 43

def start_date(options = {})
  date(options)
end

#start_date_and_stop_date(options = {}) ⇒ Object

Fab a random start date and stop date. The start is less than or equal to the stop. Delegates to #start_date and #stop_date.



62
63
64
# File 'lib/sixarm_ruby_fab/date.rb', line 62

def start_date_and_stop_date(options = {})
  [start_date(options), stop_date(options)].sort
end

#start_datetime(options = {}) ⇒ Object

Fab a random start datetime. Delegates to #datetime.



43
44
45
# File 'lib/sixarm_ruby_fab/datetime.rb', line 43

def start_datetime(options = {})
  datetime(options)
end

#start_datetime_and_stop_datetime(options = {}) ⇒ Object

Fab a random start datetime and stop datetime. The start is less than or equal to the stop. Delegates to #start_datetime and #stop_datetime.



62
63
64
# File 'lib/sixarm_ruby_fab/datetime.rb', line 62

def start_datetime_and_stop_datetime(options = {})
  [start_datetime(options), stop_datetime(options)].sort
end

#start_time(options = {}) ⇒ Object

Fab a random start time. Delegates to #time.



43
44
45
# File 'lib/sixarm_ruby_fab/time.rb', line 43

def start_time(options = {})
  time(options)
end

#start_time_and_stop_time(options = {}) ⇒ Object

Fab a random start time and stop time. The start is less than or equal to the stop. Delegates to #start_time and #stop_time.



62
63
64
# File 'lib/sixarm_ruby_fab/time.rb', line 62

def start_time_and_stop_time(options = {})
  [start_time(options), stop_time(options)].sort
end

#stop_date(options = {}) ⇒ Object

Fab a random stop date. Delegates to #date.



52
53
54
# File 'lib/sixarm_ruby_fab/date.rb', line 52

def stop_date(options = {})
  date(options)
end

#stop_datetime(options = {}) ⇒ Object

Fab a random stop datetime. Delegates to #datetime.



52
53
54
# File 'lib/sixarm_ruby_fab/datetime.rb', line 52

def stop_datetime(options = {})
  datetime(options)
end

#stop_time(options = {}) ⇒ Object

Fab a random stop time. Delegates to #time.



52
53
54
# File 'lib/sixarm_ruby_fab/time.rb', line 52

def stop_time(options = {})
  time(options)
end

#street_addressObject

Fab a random street address. Delegates to Forgery::Address.street_address.



10
11
12
# File 'lib/sixarm_ruby_fab/postal.rb', line 10

def street_address
  Forgery::Address.street_address 
end

#symSymbol

Fab a symbol, such as :abcdefgh

Returns:

  • (Symbol)


17
18
19
# File 'lib/sixarm_ruby_fab/basic.rb', line 17

def sym
  ('a'..'z').to_a.sample(rand(10..20)).join.to_sym
end

#time(options = {}) ⇒ Object

Fab a random time.

Options:

* min
* max


14
15
16
# File 'lib/sixarm_ruby_fab/time.rb', line 14

def time(options = {})
  rand((options[:min] || time_min)..(options[:max] || time_max))
end

#time_maxObject

Get. The default is now + 1000.



29
30
31
# File 'lib/sixarm_ruby_fab/time.rb', line 29

def time_max
  @time_max ||= Time.now + 1000
end

#time_max=(x) ⇒ Object

Set.



34
35
36
# File 'lib/sixarm_ruby_fab/time.rb', line 34

def time_max=x
  @time_max=x
end

#time_minObject

Get. The default is now - 1000.



19
20
21
# File 'lib/sixarm_ruby_fab/time.rb', line 19

def time_min
  @time_min ||= Time.now - 1000
end

#time_min=(x) ⇒ Object

Set.



24
25
26
# File 'lib/sixarm_ruby_fab/time.rb', line 24

def time_min=x
  @time_min=x
end

#timezone_database_nameObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
# File 'lib/sixarm_ruby_fab/timezone.rb', line 5

def timezone_database_name
  [
    "Africa/Abidjan",
    "Africa/Accra",
    "Africa/Algiers",
    "Africa/Bissau",
    "Africa/Cairo",
    "Africa/Casablanca",
    "Africa/Ceuta",
    "Africa/El_Aaiun",
    "Africa/Johannesburg",
    "Africa/Juba",
    "Africa/Khartoum",
    "Africa/Lagos",
    "Africa/Maputo",
    "Africa/Monrovia",
    "Africa/Nairobi",
    "Africa/Ndjamena",
    "Africa/Tripoli",
    "Africa/Tunis",
    "Africa/Windhoek",
    "America/Adak",
    "America/Anchorage",
    "America/Araguaina",
    "America/Argentina/Buenos_Aires",
    "America/Argentina/Catamarca",
    "America/Argentina/Cordoba",
    "America/Argentina/Jujuy",
    "America/Argentina/La_Rioja",
    "America/Argentina/Mendoza",
    "America/Argentina/Rio_Gallegos",
    "America/Argentina/Salta",
    "America/Argentina/San_Juan",
    "America/Argentina/San_Luis",
    "America/Argentina/Tucuman",
    "America/Argentina/Ushuaia",
    "America/Asuncion",
    "America/Atikokan",
    "America/Bahia",
    "America/Bahia_Banderas",
    "America/Barbados",
    "America/Belem",
    "America/Belize",
    "America/Blanc-Sablon",
    "America/Boa_Vista",
    "America/Bogota",
    "America/Boise",
    "America/Cambridge_Bay",
    "America/Campo_Grande",
    "America/Cancun",
    "America/Caracas",
    "America/Cayenne",
    "America/Chicago",
    "America/Chihuahua",
    "America/Costa_Rica",
    "America/Creston",
    "America/Cuiaba",
    "America/Curacao",
    "America/Danmarkshavn",
    "America/Dawson",
    "America/Dawson_Creek",
    "America/Denver",
    "America/Detroit",
    "America/Edmonton",
    "America/Eirunepe",
    "America/El_Salvador",
    "America/Fort_Nelson",
    "America/Fortaleza",
    "America/Glace_Bay",
    "America/Godthab",
    "America/Goose_Bay",
    "America/Grand_Turk",
    "America/Guatemala",
    "America/Guayaquil",
    "America/Guyana",
    "America/Halifax",
    "America/Havana",
    "America/Hermosillo",
    "America/Indiana/Indianapolis",
    "America/Indiana/Knox",
    "America/Indiana/Marengo",
    "America/Indiana/Petersburg",
    "America/Indiana/Tell_City",
    "America/Indiana/Vevay",
    "America/Indiana/Vincennes",
    "America/Indiana/Winamac",
    "America/Inuvik",
    "America/Iqaluit",
    "America/Jamaica",
    "America/Juneau",
    "America/Kentucky/Louisville",
    "America/Kentucky/Monticello",
    "America/La_Paz",
    "America/Lima",
    "America/Los_Angeles",
    "America/Maceio",
    "America/Managua",
    "America/Manaus",
    "America/Martinique",
    "America/Matamoros",
    "America/Mazatlan",
    "America/Menominee",
    "America/Merida",
    "America/Metlakatla",
    "America/Mexico_City",
    "America/Miquelon",
    "America/Moncton",
    "America/Monterrey",
    "America/Montevideo",
    "America/Nassau",
    "America/New_York",
    "America/Nipigon",
    "America/Nome",
    "America/Noronha",
    "America/North_Dakota/Beulah",
    "America/North_Dakota/Center",
    "America/North_Dakota/New_Salem",
    "America/Ojinaga",
    "America/Panama",
    "America/Pangnirtung",
    "America/Paramaribo",
    "America/Phoenix",
    "America/Port_of_Spain",
    "America/Port-au-Prince",
    "America/Porto_Velho",
    "America/Puerto_Rico",
    "America/Punta_Arenas",
    "America/Rainy_River",
    "America/Rankin_Inlet",
    "America/Recife",
    "America/Regina",
    "America/Resolute",
    "America/Rio_Branco",
    "America/Santarem",
    "America/Santiago",
    "America/Santo_Domingo",
    "America/Sao_Paulo",
    "America/Scoresbysund",
    "America/Sitka",
    "America/St_Johns",
    "America/Swift_Current",
    "America/Tegucigalpa",
    "America/Thule",
    "America/Thunder_Bay",
    "America/Tijuana",
    "America/Toronto",
    "America/Vancouver",
    "America/Whitehorse",
    "America/Winnipeg",
    "America/Yakutat",
    "America/Yellowknife",
    "Antarctica/Casey",
    "Antarctica/Davis",
    "Antarctica/DumontDUrville",
    "Antarctica/Macquarie",
    "Antarctica/Mawson",
    "Antarctica/Palmer",
    "Antarctica/Rothera",
    "Antarctica/Syowa",
    "Antarctica/Troll",
    "Antarctica/Vostok",
    "Asia/Almaty",
    "Asia/Amman",
    "Asia/Anadyr",
    "Asia/Aqtau",
    "Asia/Aqtobe",
    "Asia/Ashgabat",
    "Asia/Atyrau",
    "Asia/Baghdad",
    "Asia/Baku",
    "Asia/Bangkok",
    "Asia/Barnaul",
    "Asia/Beirut",
    "Asia/Bishkek",
    "Asia/Brunei",
    "Asia/Chita",
    "Asia/Choibalsan",
    "Asia/Colombo",
    "Asia/Damascus",
    "Asia/Dhaka",
    "Asia/Dili",
    "Asia/Dubai",
    "Asia/Dushanbe",
    "Asia/Famagusta",
    "Asia/Gaza",
    "Asia/Hebron",
    "Asia/Ho_Chi_Minh",
    "Asia/Hong_Kong",
    "Asia/Hovd",
    "Asia/Irkutsk",
    "Asia/Jakarta",
    "Asia/Jayapura",
    "Asia/Jerusalem",
    "Asia/Kabul",
    "Asia/Kamchatka",
    "Asia/Karachi",
    "Asia/Kathmandu",
    "Asia/Khandyga",
    "Asia/Kolkata",
    "Asia/Krasnoyarsk",
    "Asia/Kuala_Lumpur",
    "Asia/Kuching",
    "Asia/Macau",
    "Asia/Magadan",
    "Asia/Makassar",
    "Asia/Manila",
    "Asia/Novokuznetsk",
    "Asia/Novosibirsk",
    "Asia/Omsk",
    "Asia/Oral",
    "Asia/Pontianak",
    "Asia/Pyongyang",
    "Asia/Qatar",
    "Asia/Qyzylorda",
    "Asia/Riyadh",
    "Asia/Sakhalin",
    "Asia/Samarkand",
    "Asia/Seoul",
    "Asia/Shanghai",
    "Asia/Singapore",
    "Asia/Srednekolymsk",
    "Asia/Taipei",
    "Asia/Tashkent",
    "Asia/Tbilisi",
    "Asia/Tehran",
    "Asia/Thimphu",
    "Asia/Tokyo",
    "Asia/Tomsk",
    "Asia/Ulaanbaatar",
    "Asia/Urumqi",
    "Asia/Ust-Nera",
    "Asia/Vladivostok",
    "Asia/Yakutsk",
    "Asia/Yangon",
    "Asia/Yekaterinburg",
    "Asia/Yerevan",
    "Atlantic/Azores",
    "Atlantic/Bermuda",
    "Atlantic/Canary",
    "Atlantic/Cape_Verde",
    "Atlantic/Faroe",
    "Atlantic/Madeira",
    "Atlantic/Reykjavik",
    "Atlantic/South_Georgia",
    "Atlantic/Stanley",
    "Australia/Adelaide",
    "Australia/Brisbane",
    "Australia/Broken_Hill",
    "Australia/Currie",
    "Australia/Darwin",
    "Australia/Eucla",
    "Australia/Hobart",
    "Australia/Lindeman",
    "Australia/Lord_Howe",
    "Australia/Melbourne",
    "Australia/Perth",
    "Australia/Sydney",
    "Europe/Amsterdam",
    "Europe/Andorra",
    "Europe/Astrakhan",
    "Europe/Athens",
    "Europe/Belgrade",
    "Europe/Berlin",
    "Europe/Brussels",
    "Europe/Bucharest",
    "Europe/Budapest",
    "Europe/Chisinau",
    "Europe/Copenhagen",
    "Europe/Dublin",
    "Europe/Gibraltar",
    "Europe/Helsinki",
    "Europe/Istanbul",
    "Europe/Kaliningrad",
    "Europe/Kiev",
    "Europe/Kirov",
    "Europe/Lisbon",
    "Europe/London",
    "Europe/Luxembourg",
    "Europe/Madrid",
    "Europe/Malta",
    "Europe/Minsk",
    "Europe/Monaco",
    "Europe/Moscow",
    "Europe/Nicosia",
    "Europe/Oslo",
    "Europe/Paris",
    "Europe/Prague",
    "Europe/Riga",
    "Europe/Rome",
    "Europe/Samara",
    "Europe/Saratov",
    "Europe/Simferopol",
    "Europe/Sofia",
    "Europe/Stockholm",
    "Europe/Tallinn",
    "Europe/Tirane",
    "Europe/Ulyanovsk",
    "Europe/Uzhgorod",
    "Europe/Vienna",
    "Europe/Vilnius",
    "Europe/Volgograd",
    "Europe/Warsaw",
    "Europe/Zaporozhye",
    "Europe/Zurich",
    "Indian/Chagos",
    "Indian/Christmas",
    "Indian/Cocos",
    "Indian/Kerguelen",
    "Indian/Mahe",
    "Indian/Maldives",
    "Indian/Mauritius",
    "Indian/Reunion",
    "Pacific/Apia",
    "Pacific/Auckland",
    "Pacific/Bougainville",
    "Pacific/Chatham",
    "Pacific/Chuuk",
    "Pacific/Easter",
    "Pacific/Efate",
    "Pacific/Enderbury",
    "Pacific/Fakaofo",
    "Pacific/Fiji",
    "Pacific/Funafuti",
    "Pacific/Galapagos",
    "Pacific/Gambier",
    "Pacific/Guadalcanal",
    "Pacific/Guam",
    "Pacific/Honolulu",
    "Pacific/Kiritimati",
    "Pacific/Kosrae",
    "Pacific/Kwajalein",
    "Pacific/Majuro",
    "Pacific/Marquesas",
    "Pacific/Nauru",
    "Pacific/Niue",
    "Pacific/Norfolk",
    "Pacific/Noumea",
    "Pacific/Pago_Pago",
    "Pacific/Palau",
    "Pacific/Pitcairn",
    "Pacific/Pohnpei",
    "Pacific/Port_Moresby",
    "Pacific/Rarotonga",
    "Pacific/Tahiti",
    "Pacific/Tarawa",
    "Pacific/Tongatapu",
    "Pacific/Wake",
    "Pacific/Wallis",
  ].sample
end

#twitter_favorite_count(options = {}) ⇒ Integer

Fab a Twitter favorite count.

Options:

* min: 0
* max: 999

Returns:

  • (Integer)

    a favorite count



69
70
71
# File 'lib/sixarm_ruby_fab/twitter.rb', line 69

def twitter_favorite_count(options = {})
  rand((options[:min] || 0)..(options[:max] || 999))
end

#twitter_retweet_count(options = {}) ⇒ Integer

Fab a Twitter retweet count.

Options:

* min: 0
* max: 999

Returns:

  • (Integer)

    a retweet count



56
57
58
# File 'lib/sixarm_ruby_fab/twitter.rb', line 56

def twitter_retweet_count(options = {})
  rand((options[:min] || 0)..(options[:max] || 999))
end

#twitter_screen_name(options = {}) ⇒ Integer

Fab a Twitter screen name. This delegates to Fab.username.

Options:

* none

Returns:

  • (Integer)

    a screen name



14
15
16
# File 'lib/sixarm_ruby_fab/twitter.rb', line 14

def twitter_screen_name(options = {})
  username(options)
end

#twitter_tweet_hash(options = {}) ⇒ Hash

Fab a Twitter tweet hash.

Options:

* any; merge this hash into the tweet hash.

Returns:

  • (Hash)

    a tweet hash



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/sixarm_ruby_fab/twitter.rb', line 94

def twitter_tweet_hash(options={})
  id = options[:id] || options["id"] || Fab.twitter_tweet_id
  {
    "created_at" => Fab.time.httpdate,
    "id" => id.to_i,
    "id_str" => id.to_s,
    "text" => Fab.lorem,
    "source" => "web",
    "truncated" => false,
    "in_reply_to_status_id" => nil,
    "in_reply_to_status_id_str" => nil,
    "in_reply_to_user_id" => nil,
    "in_reply_to_user_id_str" => nil,
    "in_reply_to_screen_name" => nil,
    "user" => Fab.twitter_user_hash,
    "geo" => nil,
    "coordinates" => nil,
    "place" => nil,
    "contributors" => nil,
    "retweet_count" => Fab.twitter_retweet_count,
    "favorite_count" => Fab.twitter_favorite_count,
    "favorited" => Fab.boolean,
    "retweeted" => Fab.boolean,
    "lang" => Fab.language_code
  }.merge(options)
end

#twitter_tweet_id(options = {}) ⇒ Integer

Fab a Twitter tweet id.

Options:

* min: 1000000000
* max: 9000000000

Returns:

  • (Integer)

    a tweet id



82
83
84
# File 'lib/sixarm_ruby_fab/twitter.rb', line 82

def twitter_tweet_id(options = {})
  rand((options[:min] || 1000000000)..(options[:max] || 9000000000))
end

#twitter_user_hash(options = {}) ⇒ Hash

Fab a Twitter user hash.

Options:

* any; merge this hash into the user hash.

Returns:

  • (Hash)

    a Twitter user hash



39
40
41
42
43
44
45
# File 'lib/sixarm_ruby_fab/twitter.rb', line 39

def twitter_user_hash(options = {})
  id = options[:id] || options["id"] || twitter_user_id
  {
    "id" => id.to_i,
    "id_str" => id.to_s
  }.merge(options)
end

#twitter_user_id(options = {}) ⇒ Integer

Fab a Twitter user id.

Options:

* min
* max

Returns:

  • (Integer)

    a user id



27
28
29
# File 'lib/sixarm_ruby_fab/twitter.rb', line 27

def twitter_user_id(options = {})
  rand((options[:min] || 10000000)..(options[:max] || 100000000))
end

#uriObject

Fab a random URI. Delegates to Forgery::Internet.uri.



10
11
12
# File 'lib/sixarm_ruby_fab/internet.rb', line 10

def uri 
  Forgery::Internet.uri
end

#username(options = {}) ⇒ Object

Fab a username.

Options:

* chars: a..z
* size: rand(10..30) [actual size may be less because we strip the string]


14
15
16
# File 'lib/sixarm_ruby_fab/username.rb', line 14

def username(options = {})
  (options[:chars] || AZ).sample(options[:size] || rand(5..15)).join
end

#usstateObject

Fab a random US state abbreviation. Delegates to Forgery::Address.state_abbrev.



28
29
30
# File 'lib/sixarm_ruby_fab/postal.rb', line 28

def usstate 
  Forgery::Address.state_abbrev 
end

#uszipObject

Fab a random US zip code. Delegates to Forgery::Address.zip.



37
38
39
# File 'lib/sixarm_ruby_fab/postal.rb', line 37

def uszip
  Forgery::Address.zip 
end

#uuid(options = {}) ⇒ Object

Fab a random UUID.

Options:

* none


13
14
15
# File 'lib/sixarm_ruby_fab/uuid.rb', line 13

def uuid(options = {})
  SecureRandom.uuid
end

#uuids(options = {}) ⇒ Object

Fab a list of random UUIDs.

Options:

* size: 3


25
26
27
# File 'lib/sixarm_ruby_fab/uuid.rb', line 25

def uuids(options = {})
  (options[:size] || 3).times.map{ uuid(options) }
end