Class: Fab
- Inherits:
-
Object
- Object
- Fab
- 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 Attribute Summary collapse
-
#agent_list ⇒ Object
Returns the value of attribute agent_list.
-
#language_code_iso6391_list ⇒ Object
Returns the value of attribute language_code_iso6391_list.
Instance Method Summary collapse
- #agent ⇒ Object
-
#basename(options = {}) ⇒ Object
Fab a base name e.g.
-
#basename_extension(options = {}) ⇒ Object
Fab a file base name extension e.g.
-
#basename_intension(options = {}) ⇒ Object
Fab a file base name intension e.g.
-
#boolean ⇒ boolean
Fab a boolean, either true or false.
-
#city ⇒ Object
Fab a random city string.
-
#company_name(options = {}) ⇒ Object
Fab a company name.
-
#content_type(options = {}) ⇒ Object
Fab a random content type part e.g.
-
#content_type_part(options = {}) ⇒ Object
Fab a random content type part e.g.
-
#date(options = {}) ⇒ Object
Fab a random date.
-
#date_max ⇒ Object
Get.
-
#date_max=(x) ⇒ Object
Set.
-
#date_min ⇒ Object
Get.
-
#date_min=(x) ⇒ Object
Set.
-
#datetime(options = {}) ⇒ Object
Fab a random datetime.
-
#datetime_max ⇒ Object
Get.
-
#datetime_max=(x) ⇒ Object
Set.
-
#datetime_min ⇒ Object
Get.
-
#datetime_min=(x) ⇒ Object
Set.
-
#description(options = {}) ⇒ Object
Fab a random note.
-
#dirname(options = {}) ⇒ Object
Fab a directory name e.g.
-
#dirname_part(options = {}) ⇒ Object
Fab a directory path part e.g.
-
#email_address ⇒ Object
Fab an email address.
-
#family_name ⇒ Object
Fab a random last name.
-
#file_extension(options = {}) ⇒ Object
Fab a file extension.
-
#file_path(options = {}) ⇒ Object
Fab a file path.
-
#given_name ⇒ Object
Fab a random given name.
-
#id(options = {}) ⇒ Object
Fab a random id.
-
#ids(options = {}) ⇒ Object
Fab a list of random ids.
-
#job_title(options = {}) ⇒ Object
Fab a job title.
-
#language_code(options = {}) ⇒ Object
Fab a language code e.g.
-
#language_code_iso6391(options = {}) ⇒ Object
Fab a language code e.g.
-
#latitude ⇒ Object
Fab a random latitude.
-
#longitude ⇒ Object
Fab a random longitude.
-
#lorem(options = {}) ⇒ Object
Fab a random lorem ipsum string.
-
#middle_name ⇒ Object
Fab a random middle name.
-
#name(options = {}) ⇒ Object
Fab a random name.
-
#note(options = {}) ⇒ Object
Fab a random note.
-
#password(options = {}) ⇒ Object
Fab a random password.
-
#path(options = {}) ⇒ Object
Fab a path e.g.
-
#phone(options = {}) ⇒ Object
Fab a random phone number string.
-
#rating(options = {}) ⇒ Fixnum
Fab a rating, such as 1 to 5 stars.
-
#start_date(options = {}) ⇒ Object
Fab a random start date.
-
#start_date_and_stop_date(options = {}) ⇒ Object
Fab a random start date and stop date.
-
#start_datetime(options = {}) ⇒ Object
Fab a random start datetime.
-
#start_datetime_and_stop_datetime(options = {}) ⇒ Object
Fab a random start datetime and stop datetime.
-
#start_time(options = {}) ⇒ Object
Fab a random start time.
-
#start_time_and_stop_time(options = {}) ⇒ Object
Fab a random start time and stop time.
-
#stop_date(options = {}) ⇒ Object
Fab a random stop date.
-
#stop_datetime(options = {}) ⇒ Object
Fab a random stop datetime.
-
#stop_time(options = {}) ⇒ Object
Fab a random stop time.
-
#street_address ⇒ Object
Fab a random street address.
-
#time(options = {}) ⇒ Object
Fab a random time.
-
#time_max ⇒ Object
Get.
-
#time_max=(x) ⇒ Object
Set.
-
#time_min ⇒ Object
Get.
-
#time_min=(x) ⇒ Object
Set.
-
#twitter_favorite_count(options = {}) ⇒ Fixnum
Fab a Twitter favorite count.
-
#twitter_retweet_count(options = {}) ⇒ Fixnum
Fab a Twitter retweet count.
-
#twitter_screen_name(options = {}) ⇒ Fixnum
Fab a Twitter screen name.
-
#twitter_tweet_hash(options = {}) ⇒ Hash
Fab a Twitter tweet hash.
-
#twitter_tweet_id(options = {}) ⇒ Fixnum
Fab a Twitter tweet id.
-
#twitter_user_hash(options = {}) ⇒ Hash
Fab a Twitter user hash.
-
#twitter_user_id(options = {}) ⇒ Fixnum
Fab a Twitter user id.
-
#uri ⇒ Object
Fab a random URI.
-
#username(options = {}) ⇒ Object
Fab a username.
-
#usstate ⇒ Object
Fab a random US state abbreviation.
-
#uszip ⇒ Object
Fab a random US zip code.
-
#uuid(options = {}) ⇒ Object
Fab a random UUID.
-
#uuids(options = {}) ⇒ Object
Fab a list of random UUIDs.
Instance Attribute Details
#agent_list ⇒ Object
Returns the value of attribute agent_list.
10 11 12 |
# File 'lib/sixarm_ruby_fab/agent.rb', line 10 def agent_list @agent_list end |
#language_code_iso6391_list ⇒ Object
Returns the value of attribute language_code_iso6391_list.
10 11 12 |
# File 'lib/sixarm_ruby_fab/locale.rb', line 10 def language_code_iso6391_list @language_code_iso6391_list end |
Instance Method Details
#agent ⇒ Object
12 13 14 |
# File 'lib/sixarm_ruby_fab/agent.rb', line 12 def agent agent_list.sample 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]
28 29 30 31 32 |
# File 'lib/sixarm_ruby_fab/files.rb', line 28 def basename( = {}) intention = basename_intension([:intension_length] ? .merge(length: intension_length) : ) extention = basename_extension([:extension_length] ? .merge(length: extension_length) : ) "#{basename_intension}.#{basename_extension}" end |
#basename_extension(options = {}) ⇒ Object
Fab a file base name extension e.g. “txt”
Options:
* chars: a..z
* length: rand(1..5)
56 57 58 |
# File 'lib/sixarm_ruby_fab/files.rb', line 56 def basename_extension( = {}) ([:chars] || AZ).sample([: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)
43 44 45 |
# File 'lib/sixarm_ruby_fab/files.rb', line 43 def basename_intension( = {}) ([:chars] || AZ).sample([:size] || rand(1..30)).join end |
#boolean ⇒ boolean
Fab a boolean, either true or false.
7 8 9 |
# File 'lib/sixarm_ruby_fab/basic.rb', line 7 def boolean [true, false].sample end |
#city ⇒ Object
Fab a random city string. Delegates to Forgery::Address.city
17 18 19 |
# File 'lib/sixarm_ruby_fab/postal.rb', line 17 def city Forgery::Address.city end |
#company_name(options = {}) ⇒ Object
Fab a company name. Delegates to Forgery::Name.company_name.
8 9 10 |
# File 'lib/sixarm_ruby_fab/company.rb', line 8 def company_name( = {}) 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]
12 13 14 |
# File 'lib/sixarm_ruby_fab/mime.rb', line 12 def content_type( = {}) "#{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)
25 26 27 |
# File 'lib/sixarm_ruby_fab/mime.rb', line 25 def content_type_part( = {}) ([:chars] || AZ).sample([:size] || rand(1..20)).join end |
#date(options = {}) ⇒ Object
Fab a random date.
Options:
* min: today - 1000
* max: today + 1000
12 13 14 |
# File 'lib/sixarm_ruby_fab/date.rb', line 12 def date( = {}) rand(([:min] || date_min)..([:max] || date_max)) end |
#date_max ⇒ Object
Get. The default is today + 1000.
27 28 29 |
# File 'lib/sixarm_ruby_fab/date.rb', line 27 def date_max @date_max ||= Date.today + 1000 end |
#date_max=(x) ⇒ Object
Set.
32 33 34 |
# File 'lib/sixarm_ruby_fab/date.rb', line 32 def date_max=x @date_max=x end |
#date_min ⇒ Object
Get. The default is today - 1000.
17 18 19 |
# File 'lib/sixarm_ruby_fab/date.rb', line 17 def date_min @date_min ||= Date.today - 1000 end |
#date_min=(x) ⇒ Object
Set.
22 23 24 |
# File 'lib/sixarm_ruby_fab/date.rb', line 22 def date_min=x @date_min=x end |
#datetime(options = {}) ⇒ Object
Fab a random datetime.
Options:
* min: now - 1000
* max: now + 1000
12 13 14 |
# File 'lib/sixarm_ruby_fab/datetime.rb', line 12 def datetime( = {}) rand(([:min] || datetime_min)..([:max] || datetime_max)) end |
#datetime_max ⇒ Object
Get. The default is now + 1000.
27 28 29 |
# File 'lib/sixarm_ruby_fab/datetime.rb', line 27 def datetime_max @datetime_max ||= DateTime.now + 1000 end |
#datetime_max=(x) ⇒ Object
Set.
32 33 34 |
# File 'lib/sixarm_ruby_fab/datetime.rb', line 32 def datetime_max=x @datetime_max=x end |
#datetime_min ⇒ Object
Get. The default is now - 1000.
17 18 19 |
# File 'lib/sixarm_ruby_fab/datetime.rb', line 17 def datetime_min @datetime_min ||= DateTime.now - 1000 end |
#datetime_min=(x) ⇒ Object
Set.
22 23 24 |
# File 'lib/sixarm_ruby_fab/datetime.rb', line 22 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]
41 42 43 |
# File 'lib/sixarm_ruby_fab/text.rb', line 41 def description( = {}) ([:chars] || NOTE_CHARS).sample([: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]
71 72 73 74 75 76 |
# File 'lib/sixarm_ruby_fab/files.rb', line 71 def dirname( = {}) pathname = Pathname.new("/") parts = [:parts] || rand(2..6) parts.times.each{ pathname += dirname_part() } pathname.to_s end |
#dirname_part(options = {}) ⇒ Object
Fab a directory path part e.g. “mydir”.
Options:
* chars: a..z
* size: rand(1..20)
87 88 89 |
# File 'lib/sixarm_ruby_fab/files.rb', line 87 def dirname_part( = {}) ([:chars] || AZ).sample([:size] || rand(1..20)).join end |
#email_address ⇒ Object
Fab an email address. Delegate to Forgery::Email.address
8 9 10 |
# File 'lib/sixarm_ruby_fab/email.rb', line 8 def email_address Forgery::Email.address end |
#family_name ⇒ Object
Fab a random last name. Delegates to Forgery::Name.last_name
26 27 28 |
# File 'lib/sixarm_ruby_fab/names.rb', line 26 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
98 99 100 |
# File 'lib/sixarm_ruby_fab/files.rb', line 98 def file_extension( = {}) basename_extension() end |
#file_path(options = {}) ⇒ Object
Fab a file path. Delegates to #path.
TODO refactor this to streamline it
109 110 111 |
# File 'lib/sixarm_ruby_fab/files.rb', line 109 def file_path( = {}) path() end |
#given_name ⇒ Object
Fab a random given name. Delegates to Forgery::Name.first_name
8 9 10 |
# File 'lib/sixarm_ruby_fab/names.rb', line 8 def given_name Forgery::Name.first_name end |
#id(options = {}) ⇒ Object
Fab a random id.
Options:
* min: 1
* max: 30000
12 13 14 |
# File 'lib/sixarm_ruby_fab/id.rb', line 12 def id( = {}) rand(([:min] || 1)..([:max] || 30000)) end |
#ids(options = {}) ⇒ Object
Fab a list of random ids.
Options:
* size: 3
24 25 26 |
# File 'lib/sixarm_ruby_fab/id.rb', line 24 def ids( = {}) ([:size] || 3).times.map{ id() } end |
#job_title(options = {}) ⇒ Object
Fab a job title. Delegates to Forgery::Name.job_title.
17 18 19 |
# File 'lib/sixarm_ruby_fab/company.rb', line 17 def job_title( = {}) 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( = {}) language_code_iso6391() 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( = {}) LANGUAGE_CODE_ISO6391_LIST.sample end |
#latitude ⇒ Object
Fab a random latitude. Delegate to Forgery::Geo.latitude.
8 9 10 |
# File 'lib/sixarm_ruby_fab/geo.rb', line 8 def latitude Forgery::Geo.latitude end |
#longitude ⇒ Object
Fab a random longitude. Delegate to Forgery::Geo.longitude.
17 18 19 |
# File 'lib/sixarm_ruby_fab/geo.rb', line 17 def longitude Forgery::Geo.longitude 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]
54 55 56 |
# File 'lib/sixarm_ruby_fab/text.rb', line 54 def lorem( = {}) ([:chars] || NOTE_CHARS).sample([:size] || rand(20..200)).join.strip end |
#middle_name ⇒ Object
Fab a random middle name. Delegates to Forgery::Name.first_name
17 18 19 |
# File 'lib/sixarm_ruby_fab/names.rb', line 17 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]
15 16 17 |
# File 'lib/sixarm_ruby_fab/text.rb', line 15 def name( = {}) ([:chars] || NAME_CHARS).sample([: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]
28 29 30 |
# File 'lib/sixarm_ruby_fab/text.rb', line 28 def note( = {}) ([:chars] || NOTE_CHARS).sample([:size] || rand(1..200)).join.strip end |
#password(options = {}) ⇒ Object
Fab a random password.
Options:
* chars: a..z
* size: rand(9..40)
12 13 14 |
# File 'lib/sixarm_ruby_fab/password.rb', line 12 def password( = {}) ([:chars] || AZ).sample([:size] || rand(9..40)).join end |
#path(options = {}) ⇒ Object
Fab a path e.g. “/mydir1/mydir2/myfile.txt”
9 10 11 |
# File 'lib/sixarm_ruby_fab/files.rb', line 9 def path( = {}) (Pathname.new("") + dirname() + basename()).to_s end |
#phone(options = {}) ⇒ Object
Fab a random phone number string. Delegates to Forgery::Address.phone.
8 9 10 |
# File 'lib/sixarm_ruby_fab/phone.rb', line 8 def phone( = {}) Forgery::Address.phone end |
#rating(options = {}) ⇒ Fixnum
Fab a rating, such as 1 to 5 stars.
Options:
* min: 1
* max: 5
20 21 22 |
# File 'lib/sixarm_ruby_fab/basic.rb', line 20 def ( = {}) rand(([:min] || 1)..([:max] || 5)) end |
#start_date(options = {}) ⇒ Object
Fab a random start date. Delegates to #date.
41 42 43 |
# File 'lib/sixarm_ruby_fab/date.rb', line 41 def start_date( = {}) date() 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.
60 61 62 |
# File 'lib/sixarm_ruby_fab/date.rb', line 60 def start_date_and_stop_date( = {}) [start_date(), stop_date()].sort end |
#start_datetime(options = {}) ⇒ Object
Fab a random start datetime. Delegates to #datetime.
41 42 43 |
# File 'lib/sixarm_ruby_fab/datetime.rb', line 41 def start_datetime( = {}) datetime() 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.
60 61 62 |
# File 'lib/sixarm_ruby_fab/datetime.rb', line 60 def start_datetime_and_stop_datetime( = {}) [start_datetime(), stop_datetime()].sort end |
#start_time(options = {}) ⇒ Object
Fab a random start time. Delegates to #time.
41 42 43 |
# File 'lib/sixarm_ruby_fab/time.rb', line 41 def start_time( = {}) time() 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.
60 61 62 |
# File 'lib/sixarm_ruby_fab/time.rb', line 60 def start_time_and_stop_time( = {}) [start_time(), stop_time()].sort end |
#stop_date(options = {}) ⇒ Object
Fab a random stop date. Delegates to #date.
50 51 52 |
# File 'lib/sixarm_ruby_fab/date.rb', line 50 def stop_date( = {}) date() end |
#stop_datetime(options = {}) ⇒ Object
Fab a random stop datetime. Delegates to #datetime.
50 51 52 |
# File 'lib/sixarm_ruby_fab/datetime.rb', line 50 def stop_datetime( = {}) datetime() end |
#stop_time(options = {}) ⇒ Object
Fab a random stop time. Delegates to #time.
50 51 52 |
# File 'lib/sixarm_ruby_fab/time.rb', line 50 def stop_time( = {}) time() end |
#street_address ⇒ Object
Fab a random street address. Delegates to Forgery::Address.street_address.
8 9 10 |
# File 'lib/sixarm_ruby_fab/postal.rb', line 8 def street_address Forgery::Address.street_address end |
#time(options = {}) ⇒ Object
Fab a random time.
Options:
* min
* max
12 13 14 |
# File 'lib/sixarm_ruby_fab/time.rb', line 12 def time( = {}) rand(([:min] || time_min)..([:max] || time_max)) end |
#time_max ⇒ Object
Get. The default is now + 1000.
27 28 29 |
# File 'lib/sixarm_ruby_fab/time.rb', line 27 def time_max @time_max ||= Time.now + 1000 end |
#time_max=(x) ⇒ Object
Set.
32 33 34 |
# File 'lib/sixarm_ruby_fab/time.rb', line 32 def time_max=x @time_max=x end |
#time_min ⇒ Object
Get. The default is now - 1000.
17 18 19 |
# File 'lib/sixarm_ruby_fab/time.rb', line 17 def time_min @time_min ||= Time.now - 1000 end |
#time_min=(x) ⇒ Object
Set.
22 23 24 |
# File 'lib/sixarm_ruby_fab/time.rb', line 22 def time_min=x @time_min=x end |
#twitter_favorite_count(options = {}) ⇒ Fixnum
Fab a Twitter favorite count.
Options:
* min: 0
* max: 999
67 68 69 |
# File 'lib/sixarm_ruby_fab/twitter.rb', line 67 def twitter_favorite_count( = {}) rand(([:min] || 0)..([:max] || 999)) end |
#twitter_retweet_count(options = {}) ⇒ Fixnum
Fab a Twitter retweet count.
Options:
* min: 0
* max: 999
54 55 56 |
# File 'lib/sixarm_ruby_fab/twitter.rb', line 54 def twitter_retweet_count( = {}) rand(([:min] || 0)..([:max] || 999)) end |
#twitter_screen_name(options = {}) ⇒ Fixnum
Fab a Twitter screen name. This delegates to Fab.username.
Options:
* none
12 13 14 |
# File 'lib/sixarm_ruby_fab/twitter.rb', line 12 def twitter_screen_name( = {}) username() end |
#twitter_tweet_hash(options = {}) ⇒ Hash
Fab a Twitter tweet hash.
Options:
* any; merge this hash into the tweet hash.
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 |
# File 'lib/sixarm_ruby_fab/twitter.rb', line 92 def twitter_tweet_hash(={}) id = [:id] || ["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() end |
#twitter_tweet_id(options = {}) ⇒ Fixnum
Fab a Twitter tweet id.
Options:
* min: 1000000000
* max: 9000000000
80 81 82 |
# File 'lib/sixarm_ruby_fab/twitter.rb', line 80 def twitter_tweet_id( = {}) rand(([:min] || 1000000000)..([:max] || 9000000000)) end |
#twitter_user_hash(options = {}) ⇒ Hash
Fab a Twitter user hash.
Options:
* any; merge this hash into the user hash.
37 38 39 40 41 42 43 |
# File 'lib/sixarm_ruby_fab/twitter.rb', line 37 def twitter_user_hash( = {}) id = [:id] || ["id"] || twitter_user_id { "id" => id.to_i, "id_str" => id.to_s }.merge() end |
#twitter_user_id(options = {}) ⇒ Fixnum
Fab a Twitter user id.
Options:
* min
* max
25 26 27 |
# File 'lib/sixarm_ruby_fab/twitter.rb', line 25 def twitter_user_id( = {}) rand(([:min] || 10000000)..([:max] || 100000000)) end |
#uri ⇒ Object
Fab a random URI. Delegates to Forgery::Internet.uri.
8 9 10 |
# File 'lib/sixarm_ruby_fab/internet.rb', line 8 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]
12 13 14 |
# File 'lib/sixarm_ruby_fab/username.rb', line 12 def username( = {}) ([:chars] || AZ).sample([:size] || rand(5..15)).join end |
#usstate ⇒ Object
Fab a random US state abbreviation. Delegates to Forgery::Address.state_abbrev.
26 27 28 |
# File 'lib/sixarm_ruby_fab/postal.rb', line 26 def usstate Forgery::Address.state_abbrev end |
#uszip ⇒ Object
Fab a random US zip code. Delegates to Forgery::Address.zip.
35 36 37 |
# File 'lib/sixarm_ruby_fab/postal.rb', line 35 def uszip Forgery::Address.zip end |
#uuid(options = {}) ⇒ Object
Fab a random UUID.
Options:
* none
11 12 13 |
# File 'lib/sixarm_ruby_fab/uuid.rb', line 11 def uuid( = {}) SecureRandom.uuid end |
#uuids(options = {}) ⇒ Object
Fab a list of random UUIDs.
Options:
* size: 3
23 24 25 |
# File 'lib/sixarm_ruby_fab/uuid.rb', line 23 def uuids( = {}) ([:size] || 3).times.map{ uuid() } end |