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/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

#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