mirror of
https://github.com/askn/faker.git
synced 2023-08-10 21:13:01 +03:00
Update to Crystal 0.19.4
This commit is contained in:
parent
fb5c4708f7
commit
ae84c91f94
212
src/data.cr
212
src/data.cr
File diff suppressed because one or more lines are too long
@ -3,7 +3,7 @@ require "./faker/*"
|
||||
|
||||
module Faker
|
||||
def self.numerify(number_string)
|
||||
number_string = number_string as String
|
||||
number_string = number_string.as String
|
||||
number_string.sub(/#/) { (rand(9) + 1).to_s }.gsub(/#/) { rand(10).to_s }
|
||||
end
|
||||
|
||||
@ -30,13 +30,13 @@ module Faker
|
||||
end
|
||||
|
||||
def self.fetch(data)
|
||||
data = data as Array
|
||||
fetched = data.sample as String
|
||||
data = data.as Array
|
||||
fetched = data.sample.as String
|
||||
if fetched.match(/^\//) && fetched.match(/\/$/) # A regex
|
||||
fetched = Faker.regexify(fetched)
|
||||
end
|
||||
|
||||
Faker.parse(fetched) as String
|
||||
Faker.parse(fetched).as String
|
||||
end
|
||||
|
||||
def self.parse(st)
|
||||
|
@ -5,7 +5,7 @@ module Faker
|
||||
end
|
||||
|
||||
def self.credit_card_expiry_date
|
||||
credit_card_expiry_date = Faker.fetch(Data["business"]["credit_card_expiry_dates"]) as String
|
||||
credit_card_expiry_date = Faker.fetch(Data["business"]["credit_card_expiry_dates"]).as String
|
||||
Time.parse(credit_card_expiry_date, "%Y-%m-%d")
|
||||
end
|
||||
|
||||
|
@ -18,12 +18,12 @@ module Faker
|
||||
end
|
||||
|
||||
def self.material
|
||||
product_name = Data["commerce"]["product_name"] as Hash
|
||||
product_name = Data["commerce"]["product_name"].as Hash
|
||||
Faker.fetch(product_name["material"])
|
||||
end
|
||||
|
||||
def self.product_name
|
||||
product_name = Data["commerce"]["product_name"] as Hash
|
||||
product_name = Data["commerce"]["product_name"].as Hash
|
||||
Faker.fetch(product_name["adjective"]) + " " + Faker.fetch(product_name["material"]) + " " + Faker.fetch(product_name["product"])
|
||||
end
|
||||
|
||||
|
@ -9,12 +9,12 @@ module Faker
|
||||
end
|
||||
|
||||
def self.catch_phrase
|
||||
data = Data["company"]["buzzwords"] as Array(Array(String))
|
||||
data = Data["company"]["buzzwords"].as Array(Array(String))
|
||||
Faker.fetch(data.flatten)
|
||||
end
|
||||
|
||||
def self.bs
|
||||
data = Data["company"]["bs"] as Array(Array(String))
|
||||
data = Data["company"]["bs"].as Array(Array(String))
|
||||
Faker.fetch(data.flatten)
|
||||
end
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
module Faker
|
||||
class Finance
|
||||
CREDIT_CARD_TYPES = (Data["credit_card"] as Hash).keys
|
||||
CREDIT_CARD_TYPES = (Data["credit_card"].as(Hash)).keys
|
||||
|
||||
def self.credit_card(types : Array = [] of Array(String))
|
||||
types = CREDIT_CARD_TYPES if types.empty?
|
||||
|
@ -11,13 +11,13 @@ module Faker
|
||||
end
|
||||
|
||||
def self.word
|
||||
words = Data["lorem"]["words"] as Array
|
||||
words = Data["lorem"]["words"].as Array
|
||||
Faker.fetch(words)
|
||||
end
|
||||
|
||||
def self.words(num = 3, supplemental = false)
|
||||
words = Data["lorem"]["words"] as Array(String)
|
||||
words += (Data["lorem"]["supplemental"] as Array(String)) if supplemental
|
||||
words = Data["lorem"]["words"].as Array(String)
|
||||
words += (Data["lorem"]["supplemental"].as Array(String)) if supplemental
|
||||
|
||||
words.shuffle[0, num]
|
||||
end
|
||||
|
@ -7,7 +7,7 @@ module Faker
|
||||
{% end %}
|
||||
|
||||
def self.title
|
||||
title = Data["name"]["title"] as Hash
|
||||
title = Data["name"]["title"].as Hash
|
||||
Faker.fetch(title["descriptor"]) + " " + Faker.fetch(title["level"]) + " " + Faker.fetch(title["job"])
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user