Random-Data-Despegar
Install
gem install random_data_despegar
O manualmente => http://gems.despegar.com/#random_data_despegar
Generadores de datos random
Generadores
- ArrayRandomizer
- Booleans
- ContactInfo
- Dates
- Grammar
- Locations
- Names
- Numbers
- InvoiceData
- IdGenerator
- Text
ArrayRandomizer:
Random.rand #>> [1,2,3].rand = 3
Random.roulette # Takes an array of non-negative weights and returns the index selected by a
Booleans:
Random.boolean #Returns true or false randomly
ContactInfo:
# Returns a randomly-generated string of digits that roughly resembles a US telephone number. Not guaranteed to be a valid area code.
Random.phone
# Returns a randomly-generated string of digits that roughly resembles an international telephone number as dialed from the US.
Random.international_phone
# Returns an e-mail address of the form "{first_initial}{last_name}@{domain}"
Random.email
Dates:
# Returns a random date.
Random.date
# Returns a date within the specified Range. The Range can be Date or String objects.
Random.date_between
# Returns valid departure and return dates (Date and formated)
Random.departure_and_return_dates
# Returns a hash with birhdate for a specific passenger_type: adult, child or infant.
Random.passenger_birthdate(passenger_type)
Grammar:
# Random.grammatical_construct({:story => [:man, " bites ", :dog], :man => { :bob => "Bob"}, :dog => {:a =>"Rex", :b =>"Rover"}}, :story)
Random.grammatical_construct # => "Bob bites Rover"
Locations:
# 24317 Jefferson Blvd"
Random.address_line_1
Random.address_line_2
# Returns a random 5-digit string, not guaranteed to be a legitimate zip code.
Random.zipcode
# Returns brazilian cep
Random.cep
# Returns brazilian cpnj
Random.cpnj
# Returns a string providing something in the general form of a UK post code. Like the zip codes, this might
Random.uk_post_code
# Returns a state 2-character abbreviation
# Random.state_code = "IL"
Random.state_code
# Returns a full state name
#Random.state_full = "Texas"
Random.state_full
# Returns a country name, as listed by the World Bank
Random.country
# Returns a generic city name, with an attempt to have some internationl appeal
Random.city
Names:
Random.firstname
Random.firstname_male
Random.firstname_female
Random.initial
Random.lastname
Numbers:
Random.number
# parameter is the size of the number to be generated.
Random.number_with_size(size)
# Returns an alphanumeric number with size n
Random.alphanumeric_with_size(size) # params integer
# return a random bit, 0 or 1.
Random.bit
# return an array of n random bits.
Random.bits
# Return card numbers, based on a regex and card number length.
# regex will be a string
# length will be an integer
Random.random_card_number(card_regex)
InvoiceData:
# cr ec pa pe ve mx co cl ar br
Random.invoice_data_for "BR" #=> {:pf=>{:cedula=>"20532364131"
:cep=>"13301611"
:cpf=>"88227212710"}
IdGenerator:
# cr ec pa pe ve mx co cl ar br
Random.id_for "BR"
Text:
Random.alphanumeric
Random.paragraphs