mirror of
https://github.com/askn/faker.git
synced 2023-08-10 21:13:01 +03:00
add character, ip_v6 && Business
This commit is contained in:
parent
30f4048ba4
commit
0ad1c1c623
16
src/faker/business.cr
Normal file
16
src/faker/business.cr
Normal file
@ -0,0 +1,16 @@
|
||||
module Faker
|
||||
class Business
|
||||
def self.credit_card_number
|
||||
Faker.fetch(Data["business"]["credit_card_numbers"])
|
||||
end
|
||||
|
||||
def self.credit_card_expiry_date
|
||||
credit_card_expiry_date = Faker.fetch(Data["business"]["credit_card_expiry_dates"]) as String
|
||||
Time.parse(credit_card_expiry_date, "%Y-%m-%d")
|
||||
end
|
||||
|
||||
def self.credit_card_type
|
||||
Faker.fetch(Data["business"]["credit_card_types"])
|
||||
end
|
||||
end
|
||||
end
|
@ -1,7 +1,7 @@
|
||||
module Faker
|
||||
class Commerce
|
||||
def self.color
|
||||
Faker.fetch(Data["commerce"]["color"])
|
||||
Faker.fetch(Data["color"]["name"])
|
||||
end
|
||||
|
||||
def self.department
|
||||
|
@ -9,16 +9,18 @@ module Faker
|
||||
end
|
||||
|
||||
def self.catch_phrase
|
||||
[Faker.fetch(Data["company"]["buzzword_1"]), Faker.fetch(Data["company"]["buzzword_2"]), Faker.fetch(Data["company"]["buzzword_3"])].join(" ")
|
||||
data = Data["company"]["buzzwords"] as Array(Array(String))
|
||||
Faker.fetch(data.flatten)
|
||||
end
|
||||
|
||||
def self.bs
|
||||
[Faker.fetch(Data["company"]["bs_1"]), Faker.fetch(Data["company"]["bs_2"]), Faker.fetch(Data["company"]["bs_3"])].join(" ")
|
||||
data = Data["company"]["bs"] as Array(Array(String))
|
||||
Faker.fetch(data.flatten)
|
||||
end
|
||||
|
||||
Formats = [
|
||||
->{ [Name.last_name, suffix].join(' ') },
|
||||
->{ [Name.last_name, Name.last_name].join('-') },
|
||||
->{ [Name.last_name, suffix].join(" ") },
|
||||
->{ [Name.last_name, Name.last_name].join("-") },
|
||||
->{ "%s, %s and %s" % [Name.last_name, Name.last_name, Name.last_name] },
|
||||
]
|
||||
end
|
||||
|
@ -45,6 +45,12 @@ module Faker
|
||||
].join('.')
|
||||
end
|
||||
|
||||
def self.ip_v6_address
|
||||
ip_v6_space = (0..65535).to_a
|
||||
container = (1..8).map { |_| ip_v6_space.sample }
|
||||
container.map { |n| n.to_s(16) }.join(':')
|
||||
end
|
||||
|
||||
def self.url
|
||||
"http://#{domain_name}/#{user_name}"
|
||||
end
|
||||
|
@ -1,6 +1,10 @@
|
||||
module Faker
|
||||
# Based on Perl"s Text::Lorem
|
||||
class Lorem
|
||||
def self.character
|
||||
characters(1)
|
||||
end
|
||||
|
||||
def self.characters(char_count = 255)
|
||||
chars = ("a".."z").to_a + (0..9).to_a
|
||||
Array(String).new(char_count < 0 ? 0 : char_count, "").map { chars.sample }.join("")
|
||||
@ -12,8 +16,8 @@ module Faker
|
||||
end
|
||||
|
||||
def self.words(num = 3, supplemental = false)
|
||||
words = Data["lorem"]["words"] as Array
|
||||
words += (Data["lorem"]["supplemental"] as Array) if supplemental
|
||||
words = Data["lorem"]["words"] as Array(String)
|
||||
words += (Data["lorem"]["supplemental"] as Array(String)) if supplemental
|
||||
|
||||
words.shuffle[0, num]
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user